forked from organicmaps/organicmaps
[android] Fixed review notes
This commit is contained in:
parent
227395e5b9
commit
f9cda01b18
14 changed files with 62 additions and 54 deletions
|
@ -81,7 +81,8 @@ void PrepareClassRefs(JNIEnv * env)
|
|||
// boolean fromCatalog,
|
||||
// boolean isVisible)
|
||||
g_bookmarkCategoryConstructor =
|
||||
jni::GetConstructorID(env, g_bookmarkCategoryClass, "(JLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IIZZ)V");
|
||||
jni::GetConstructorID(env, g_bookmarkCategoryClass, "(JLjava/lang/String;Ljava/lang/String;"
|
||||
"Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IIZZ)V");
|
||||
}
|
||||
|
||||
void OnAsyncLoadingStarted(JNIEnv * env)
|
||||
|
|
|
@ -21,8 +21,6 @@
|
|||
android:paddingRight="@dimen/margin_double_and_half"
|
||||
android:paddingTop="@dimen/placeholder_margin_top"
|
||||
mapsme:imgSrcDefault="@drawable/img_empty_bookmarks"
|
||||
mapsme:titleDefault="@string/empty_bookmarks_list_title"
|
||||
mapsme:subTitleDefault="@string/empty_bookmarks_list_subtitle"/>
|
||||
|
||||
mapsme:titleDefault="@string/bookmarks_empty_list_title"
|
||||
mapsme:subTitleDefault="@string/bookmarks_empty_list_message"/>
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
|
||||
|
|
|
@ -33,10 +33,10 @@
|
|||
android:id="@+id/more_btn"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="left|bottom"
|
||||
android:gravity="left|top"
|
||||
android:layout_gravity="start|bottom"
|
||||
android:gravity="start|top"
|
||||
android:textColor="?attr/colorAccent"
|
||||
android:text="@string/more"
|
||||
android:text="@string/category_desc_more"
|
||||
android:background="@android:color/transparent"/>
|
||||
</LinearLayout>
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
|
|
|
@ -5,10 +5,13 @@
|
|||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/height_item_oneline"
|
||||
android:gravity="left|center_vertical"
|
||||
android:paddingLeft="@dimen/margin_base"
|
||||
android:gravity="start|center_vertical"
|
||||
android:paddingTop="@dimen/margin_half"
|
||||
android:textAppearance="@style/MwmTextAppearance.Body3"
|
||||
android:fontFamily="@string/robotoMedium"
|
||||
android:text="@string/bookmarks"
|
||||
tools:targetApi="jelly_bean"/>
|
||||
tools:targetApi="jelly_bean"
|
||||
android:paddingEnd="@dimen/margin_base"
|
||||
android:paddingRight="@dimen/margin_base"
|
||||
android:paddingStart="@dimen/margin_base"
|
||||
android:paddingLeft="@dimen/margin_base"/>
|
||||
|
|
|
@ -274,7 +274,7 @@ public abstract class BaseBookmarkCategoriesFragment extends BaseMwmRecyclerFrag
|
|||
}
|
||||
|
||||
@NonNull
|
||||
private Intent makeBookmarksListIntent(BookmarkCategory category)
|
||||
private Intent makeBookmarksListIntent(@NonNull BookmarkCategory category)
|
||||
{
|
||||
return new Intent(getActivity(), BookmarkListActivity.class)
|
||||
.putExtra(BookmarksListFragment.EXTRA_CATEGORY, category);
|
||||
|
|
|
@ -152,14 +152,15 @@ public class BookmarkCategoriesAdapter extends BaseBookmarkCategoryAdapter<Recyc
|
|||
BookmarkCategory.Author author = category.getAuthor();
|
||||
CharSequence authorName = author == null
|
||||
? null
|
||||
: getAuthorRepresentation(author);
|
||||
: getAuthorRepresentation(author, getContext());
|
||||
categoryHolder.getAuthorName().setText(authorName);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private String getAuthorRepresentation(@NonNull BookmarkCategory.Author author)
|
||||
private static String getAuthorRepresentation(@NonNull BookmarkCategory.Author author,
|
||||
@NonNull Context context)
|
||||
{
|
||||
return PHRASE_SEPARATOR + BookmarkCategory.Author.getRepresentation(getContext(), author);
|
||||
return PHRASE_SEPARATOR + BookmarkCategory.Author.getRepresentation(context, author);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.mapswithme.maps.bookmarks;
|
||||
|
||||
import android.location.Location;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -28,6 +29,7 @@ import static com.mapswithme.maps.bookmarks.Holders.BookmarkViewHolder.calculate
|
|||
|
||||
public class BookmarkListAdapter extends RecyclerView.Adapter<Holders.BaseBookmarkHolder>
|
||||
{
|
||||
@NonNull
|
||||
private final BookmarkCategory mCategory;
|
||||
|
||||
// view types
|
||||
|
@ -50,7 +52,7 @@ public class BookmarkListAdapter extends RecyclerView.Adapter<Holders.BaseBookma
|
|||
@Nullable
|
||||
private RecyclerClickListener mClickListener;
|
||||
|
||||
BookmarkListAdapter(BookmarkCategory category)
|
||||
BookmarkListAdapter(@NonNull BookmarkCategory category)
|
||||
{
|
||||
mCategory = category;
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import android.webkit.WebViewClient;
|
|||
|
||||
import com.mapswithme.maps.R;
|
||||
import com.mapswithme.maps.auth.BaseWebViewMwmFragment;
|
||||
import com.mapswithme.util.UiUtils;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
|
@ -90,7 +91,7 @@ public class BookmarksCatalogFragment extends BaseWebViewMwmFragment
|
|||
}
|
||||
|
||||
@NonNull
|
||||
public String getCatalogUrlOrThrow()
|
||||
private String getCatalogUrlOrThrow()
|
||||
{
|
||||
Bundle args = getArguments();
|
||||
String result = args != null ? args.getString(EXTRA_BOOKMARKS_CATALOG_URL) : null;
|
||||
|
@ -113,7 +114,7 @@ public class BookmarksCatalogFragment extends BaseWebViewMwmFragment
|
|||
@Nullable
|
||||
private WebResourceError mError;
|
||||
|
||||
public WebViewBookmarksCatalogClient(@NonNull BookmarksCatalogFragment frag)
|
||||
WebViewBookmarksCatalogClient(@NonNull BookmarksCatalogFragment frag)
|
||||
{
|
||||
mReference = new WeakReference<>(frag);
|
||||
}
|
||||
|
@ -134,9 +135,8 @@ public class BookmarksCatalogFragment extends BaseWebViewMwmFragment
|
|||
return;
|
||||
}
|
||||
|
||||
frag.mWebView.setVisibility(View.VISIBLE);
|
||||
frag.mProgressView.setVisibility(View.GONE);
|
||||
frag.mRetryBtn.setVisibility(View.GONE);
|
||||
UiUtils.show(frag.mWebView);
|
||||
UiUtils.hide(frag.mProgressView, frag.mRetryBtn);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -148,9 +148,8 @@ public class BookmarksCatalogFragment extends BaseWebViewMwmFragment
|
|||
if ((frag = mReference.get()) == null)
|
||||
return;
|
||||
|
||||
frag.mWebView.setVisibility(View.GONE);
|
||||
frag.mProgressView.setVisibility(View.GONE);
|
||||
frag.mRetryBtn.setVisibility(View.VISIBLE);
|
||||
UiUtils.show(frag.mRetryBtn);
|
||||
UiUtils.hide(frag.mWebView, frag.mProgressView);
|
||||
}
|
||||
|
||||
private void retry()
|
||||
|
|
|
@ -28,7 +28,7 @@ import com.mapswithme.maps.widget.placepage.Sponsored;
|
|||
import com.mapswithme.maps.widget.recycler.RecyclerClickListener;
|
||||
import com.mapswithme.maps.widget.recycler.RecyclerLongClickListener;
|
||||
import com.mapswithme.util.BottomSheetHelper;
|
||||
import com.mapswithme.util.Utils;
|
||||
import com.mapswithme.util.UiUtils;
|
||||
import com.mapswithme.util.sharing.ShareOption;
|
||||
import com.mapswithme.util.sharing.SharingHelper;
|
||||
|
||||
|
@ -70,9 +70,9 @@ public class BookmarksListFragment extends BaseMwmRecyclerFragment
|
|||
super.onViewCreated(view, savedInstanceState);
|
||||
configureAdapter();
|
||||
setHasOptionsMenu(true);
|
||||
boolean isEmptyDataSet = getAdapter().getItemCount() == 0;
|
||||
getRecyclerView().setVisibility(isEmptyDataSet ? View.GONE : View.VISIBLE);
|
||||
showPlaceholder(isEmptyDataSet);
|
||||
boolean isEmpty = getAdapter().getItemCount() == 0;
|
||||
UiUtils.showIf(!isEmpty, getRecyclerView());
|
||||
showPlaceholder(isEmpty);
|
||||
ActionBar bar = ((AppCompatActivity) getActivity()).getSupportActionBar();
|
||||
if (bar != null)
|
||||
bar.setTitle(mCategory.getName());
|
||||
|
|
|
@ -12,17 +12,19 @@ import com.mapswithme.maps.R;
|
|||
import com.mapswithme.maps.bookmarks.data.BookmarkCategory;
|
||||
import com.mapswithme.maps.bookmarks.data.BookmarkManager;
|
||||
import com.mapswithme.util.SharedPropertiesUtils;
|
||||
import com.mapswithme.util.StorageUtils;
|
||||
import com.mapswithme.util.UiUtils;
|
||||
import com.mapswithme.util.sharing.TargetUtils;
|
||||
|
||||
public class CachedBookmarkCategoriesFragment extends BaseBookmarkCategoriesFragment implements
|
||||
BookmarkManager.BookmarksCatalogListener
|
||||
{
|
||||
@SuppressWarnings("NullableProblems")
|
||||
@NonNull
|
||||
private ViewGroup mEmptyViewContainer;
|
||||
@SuppressWarnings("NullableProblems")
|
||||
@NonNull
|
||||
private View mPayloadContainer;
|
||||
@SuppressWarnings("NullableProblems")
|
||||
@NonNull
|
||||
private View mProgressContainer;
|
||||
|
||||
|
@ -38,7 +40,7 @@ public class CachedBookmarkCategoriesFragment extends BaseBookmarkCategoriesFrag
|
|||
View closeHeaderBtn = root.findViewById(R.id.header_close);
|
||||
closeHeaderBtn.setOnClickListener(new CloseHeaderClickListener());
|
||||
boolean isClosed = SharedPropertiesUtils.isCatalogCategoriesHeaderClosed(getContext());
|
||||
closeHeaderBtn.setVisibility(isClosed ? View.GONE : View.VISIBLE);
|
||||
UiUtils.showIf(!isClosed, closeHeaderBtn);
|
||||
return root;
|
||||
}
|
||||
|
||||
|
|
|
@ -221,7 +221,7 @@ public class Holders
|
|||
|
||||
abstract void bind(int position);
|
||||
|
||||
static boolean isSectionEmpty(BookmarkCategory category, @Section int section)
|
||||
static boolean isSectionEmpty(@NonNull BookmarkCategory category, @Section int section)
|
||||
{
|
||||
switch (section)
|
||||
{
|
||||
|
@ -236,7 +236,7 @@ public class Holders
|
|||
}
|
||||
}
|
||||
|
||||
static int getSectionForPosition(BookmarkCategory category, int position)
|
||||
static int getSectionForPosition(@NonNull BookmarkCategory category, int position)
|
||||
{
|
||||
if (position == getDescSectionPosition(category))
|
||||
return SECTION_DESC;
|
||||
|
@ -248,39 +248,40 @@ public class Holders
|
|||
throw new IllegalArgumentException("There is no section in position " + position);
|
||||
}
|
||||
|
||||
static int getDescSectionPosition(BookmarkCategory category)
|
||||
static int getDescSectionPosition(@NonNull BookmarkCategory category)
|
||||
{
|
||||
if (isSectionEmpty(category, SECTION_DESC))
|
||||
return -1;
|
||||
return RecyclerView.NO_POSITION;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int getTracksSectionPosition(BookmarkCategory category)
|
||||
static int getTracksSectionPosition(@NonNull BookmarkCategory category)
|
||||
{
|
||||
if (isSectionEmpty(category, SECTION_TRACKS))
|
||||
return -1;
|
||||
return RecyclerView.NO_POSITION;
|
||||
|
||||
return getDescItemCount(category);
|
||||
}
|
||||
|
||||
static int getBookmarksSectionPosition(BookmarkCategory category)
|
||||
static int getBookmarksSectionPosition(@NonNull BookmarkCategory category)
|
||||
{
|
||||
if (isSectionEmpty(category, SECTION_BMKS))
|
||||
return -1;
|
||||
return RecyclerView.NO_POSITION;
|
||||
|
||||
int beforeCurrentSectionItemsCount = getTracksSectionPosition(category);
|
||||
return (beforeCurrentSectionItemsCount == -1 ? getDescItemCount(category)
|
||||
: beforeCurrentSectionItemsCount)
|
||||
return (beforeCurrentSectionItemsCount == RecyclerView.NO_POSITION
|
||||
? getDescItemCount(category)
|
||||
: beforeCurrentSectionItemsCount)
|
||||
+ getTrackItemCount(category);
|
||||
}
|
||||
|
||||
private static int getTrackItemCount(BookmarkCategory category)
|
||||
private static int getTrackItemCount(@NonNull BookmarkCategory category)
|
||||
{
|
||||
return category.getTracksCount() + (isSectionEmpty(category, SECTION_TRACKS) ? 0 : 1);
|
||||
}
|
||||
|
||||
static int getDescItemCount(BookmarkCategory category)
|
||||
static int getDescItemCount(@NonNull BookmarkCategory category)
|
||||
{
|
||||
return isSectionEmpty(category, SECTION_DESC) ? 0 : /* section header */ 1 + /* non empty desc */ 1;
|
||||
}
|
||||
|
@ -298,7 +299,7 @@ public class Holders
|
|||
mView.setOnLongClickListener(v -> onOpenActionMenu(v, listener));
|
||||
}
|
||||
|
||||
boolean onOpenActionMenu(View v, @Nullable RecyclerLongClickListener listener)
|
||||
boolean onOpenActionMenu(@NonNull View v, @Nullable RecyclerLongClickListener listener)
|
||||
{
|
||||
if (listener != null)
|
||||
listener.onLongItemClick(v, getAdapterPosition());
|
||||
|
@ -317,9 +318,9 @@ public class Holders
|
|||
@NonNull
|
||||
private final View mMore;
|
||||
|
||||
BookmarkViewHolder(@NonNull View itemView, BookmarkCategory categoryId)
|
||||
BookmarkViewHolder(@NonNull View itemView, @NonNull BookmarkCategory category)
|
||||
{
|
||||
super(itemView, categoryId);
|
||||
super(itemView, category);
|
||||
mIcon = itemView.findViewById(R.id.iv__bookmark_color);
|
||||
mName = itemView.findViewById(R.id.tv__bookmark_name);
|
||||
mDistance = itemView.findViewById(R.id.tv__bookmark_distance);
|
||||
|
@ -352,7 +353,7 @@ public class Holders
|
|||
mIcon.setImageResource(bookmark.getIcon().getSelectedResId());
|
||||
}
|
||||
|
||||
static int calculateBookmarkPosition(BookmarkCategory category, int position)
|
||||
static int calculateBookmarkPosition(@NonNull BookmarkCategory category, int position)
|
||||
{
|
||||
// Since bookmarks are always below tracks and header we should take it into account
|
||||
// during the bookmark's position calculation.
|
||||
|
@ -448,7 +449,7 @@ public class Holders
|
|||
mAuthor = itemView.findViewById(R.id.author);
|
||||
}
|
||||
|
||||
private void onMoreBtnClicked(View v)
|
||||
private void onMoreBtnClicked(@NonNull View v)
|
||||
{
|
||||
int lineCount = calcLineCount(mDescText, mCategory.getDescription());
|
||||
mDescText.setLines(lineCount);
|
||||
|
|
|
@ -280,7 +280,9 @@ public class BookmarkCategory implements Parcelable
|
|||
PRIVATE(BookmarksPageFactory.PRIVATE, FilterStrategy.PredicativeStrategy.makePrivateInstance()),
|
||||
CATALOG(BookmarksPageFactory.CATALOG, FilterStrategy.PredicativeStrategy.makeCatalogInstance());
|
||||
|
||||
@NonNull
|
||||
private BookmarksPageFactory mFactory;
|
||||
@NonNull
|
||||
private FilterStrategy mFilterStrategy;
|
||||
|
||||
Type(@NonNull BookmarksPageFactory pageFactory, @NonNull FilterStrategy filterStrategy)
|
||||
|
|
|
@ -283,13 +283,12 @@ public enum BookmarkManager
|
|||
|
||||
/**
|
||||
* @return total count - tracks + bookmarks
|
||||
* @param catId
|
||||
* should be used BookmarkCategory.size() - without JNI method call overhead
|
||||
* @param category
|
||||
*/
|
||||
@Deprecated
|
||||
public int getCategorySize(BookmarkCategory catId)
|
||||
public int getCategorySize(@NonNull BookmarkCategory category)
|
||||
{
|
||||
return nativeGetBookmarksCount(catId.getId()) + nativeGetTracksCount(catId.getId());
|
||||
return nativeGetBookmarksCount(category.getId()) + nativeGetTracksCount(category.getId());
|
||||
}
|
||||
|
||||
public int getCategoriesCount() { return nativeGetCategoriesCount(); }
|
||||
|
|
|
@ -16,7 +16,7 @@ public final class SharedPropertiesUtils
|
|||
private static final String PREFS_SHOW_EMULATE_BAD_STORAGE_SETTING = "ShowEmulateBadStorageSetting";
|
||||
private static final String PREFS_BACKUP_WIDGET_EXPANDED = "BackupWidgetExpanded";
|
||||
private static final String PREFS_WHATS_NEW_TITLE_CONCATENATION = "WhatsNewTitleConcatenation";
|
||||
private static final String PREFS_CATALOG_CATEGORIES_HEADER_CLOSED = "catalog_categories_header_closed";
|
||||
private static final String PREFS_CATALOG_CATEGORIES_HEADER_CLOSED = "CatalogCategoriesHeaderClosed";
|
||||
private static final SharedPreferences PREFS
|
||||
= PreferenceManager.getDefaultSharedPreferences(MwmApplication.get());
|
||||
|
||||
|
@ -79,13 +79,13 @@ public final class SharedPropertiesUtils
|
|||
PREFS.edit().putString(PREFS_WHATS_NEW_TITLE_CONCATENATION, concatenation).apply();
|
||||
}
|
||||
|
||||
public static boolean isCatalogCategoriesHeaderClosed(Context context)
|
||||
public static boolean isCatalogCategoriesHeaderClosed(@NonNull Context context)
|
||||
{
|
||||
return MwmApplication.prefs(context)
|
||||
.getBoolean(PREFS_CATALOG_CATEGORIES_HEADER_CLOSED, false);
|
||||
}
|
||||
|
||||
public static void setCatalogCategoriesHeaderClosed(Context context, boolean value)
|
||||
public static void setCatalogCategoriesHeaderClosed(@NonNull Context context, boolean value)
|
||||
{
|
||||
MwmApplication.prefs(context)
|
||||
.edit()
|
||||
|
|
Loading…
Add table
Reference in a new issue