forked from organicmaps/organicmaps
[bookmarks][android] Review fixes.
This commit is contained in:
parent
b261f09286
commit
9842f590e8
9 changed files with 212 additions and 149 deletions
|
@ -36,6 +36,7 @@ public class BookmarkListAdapter extends RecyclerView.Adapter<Holders.BaseBookma
|
|||
@Nullable
|
||||
private List<SortedBlock> mSortedResults;
|
||||
|
||||
@SuppressWarnings("NullableProblems")
|
||||
@NonNull
|
||||
private SectionsDataSource mSectionsDataSource;
|
||||
|
||||
|
@ -46,9 +47,9 @@ public class BookmarkListAdapter extends RecyclerView.Adapter<Holders.BaseBookma
|
|||
@Nullable
|
||||
private RecyclerLongClickListener mLongClickListener;
|
||||
|
||||
public static class SectionPosition
|
||||
static class SectionPosition
|
||||
{
|
||||
public static final int INVALID_POSITION = -1;
|
||||
static final int INVALID_POSITION = -1;
|
||||
|
||||
public final int sectionIndex;
|
||||
public final int itemIndex;
|
||||
|
@ -73,7 +74,7 @@ public class BookmarkListAdapter extends RecyclerView.Adapter<Holders.BaseBookma
|
|||
public abstract class SectionsDataSource
|
||||
{
|
||||
@NonNull
|
||||
protected final DataSource<BookmarkCategory> mDataSource;
|
||||
private final DataSource<BookmarkCategory> mDataSource;
|
||||
|
||||
SectionsDataSource(@NonNull DataSource<BookmarkCategory> dataSource)
|
||||
{
|
||||
|
@ -82,7 +83,7 @@ public class BookmarkListAdapter extends RecyclerView.Adapter<Holders.BaseBookma
|
|||
|
||||
public BookmarkCategory getCategory() { return mDataSource.getData(); }
|
||||
|
||||
protected boolean hasDescription()
|
||||
boolean hasDescription()
|
||||
{
|
||||
return !mDataSource.getData().getAnnotation().isEmpty() ||
|
||||
!mDataSource.getData().getDescription().isEmpty();
|
||||
|
@ -91,12 +92,13 @@ public class BookmarkListAdapter extends RecyclerView.Adapter<Holders.BaseBookma
|
|||
public abstract int getSectionsCount();
|
||||
public abstract boolean isEditable(int sectionIndex);
|
||||
public abstract boolean hasTitle(int sectionIndex);
|
||||
public abstract @Nullable String getTitle(int sectionIndex, Resources rs);
|
||||
@Nullable
|
||||
public abstract String getTitle(int sectionIndex, @NonNull Resources rs);
|
||||
public abstract int getItemsCount(int sectionIndex);
|
||||
public abstract int getItemsType(int sectionIndex);
|
||||
public abstract long getBookmarkId(SectionPosition pos);
|
||||
public abstract long getTrackId(SectionPosition pos);
|
||||
public abstract void onDelete(SectionPosition pos);
|
||||
public abstract long getBookmarkId(@NonNull SectionPosition pos);
|
||||
public abstract long getTrackId(@NonNull SectionPosition pos);
|
||||
public abstract void onDelete(@NonNull SectionPosition pos);
|
||||
}
|
||||
|
||||
private class CategorySectionsDataSource extends SectionsDataSource
|
||||
|
@ -140,7 +142,7 @@ public class BookmarkListAdapter extends RecyclerView.Adapter<Holders.BaseBookma
|
|||
public boolean hasTitle(int sectionIndex) { return true; }
|
||||
|
||||
@Nullable
|
||||
public String getTitle(int sectionIndex, Resources rs)
|
||||
public String getTitle(int sectionIndex, @NonNull Resources rs)
|
||||
{
|
||||
if (sectionIndex == mDescriptionSectionIndex)
|
||||
return rs.getString(R.string.description);
|
||||
|
@ -170,29 +172,25 @@ public class BookmarkListAdapter extends RecyclerView.Adapter<Holders.BaseBookma
|
|||
return TYPE_TRACK;
|
||||
if (sectionIndex == mBookmarksSectionIndex)
|
||||
return TYPE_BOOKMARK;
|
||||
return 0;
|
||||
throw new AssertionError("Invalid section index: " + sectionIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDelete(SectionPosition pos)
|
||||
public void onDelete(@NonNull SectionPosition pos)
|
||||
{
|
||||
calculateSections();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getBookmarkId(SectionPosition pos)
|
||||
public long getBookmarkId(@NonNull SectionPosition pos)
|
||||
{
|
||||
final long bookmarkId = BookmarkManager.INSTANCE.getBookmarkIdByPosition(
|
||||
getCategory().getId(), pos.itemIndex);
|
||||
return bookmarkId;
|
||||
return BookmarkManager.INSTANCE.getBookmarkIdByPosition(getCategory().getId(), pos.itemIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTrackId(SectionPosition pos)
|
||||
public long getTrackId(@NonNull SectionPosition pos)
|
||||
{
|
||||
final long trackId = BookmarkManager.INSTANCE.getTrackIdByPosition(
|
||||
getCategory().getId(), pos.itemIndex);
|
||||
return trackId;
|
||||
return BookmarkManager.INSTANCE.getTrackIdByPosition(getCategory().getId(), pos.itemIndex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -218,7 +216,7 @@ public class BookmarkListAdapter extends RecyclerView.Adapter<Holders.BaseBookma
|
|||
public boolean hasTitle(int sectionIndex) { return false; }
|
||||
|
||||
@Nullable
|
||||
public String getTitle(int sectionIndex, Resources rs) { return null; }
|
||||
public String getTitle(int sectionIndex, @NonNull Resources rs) { return null; }
|
||||
|
||||
@Override
|
||||
public int getItemsCount(int sectionIndex) { return mSearchResults.size(); }
|
||||
|
@ -227,13 +225,13 @@ public class BookmarkListAdapter extends RecyclerView.Adapter<Holders.BaseBookma
|
|||
public int getItemsType(int sectionIndex) { return TYPE_BOOKMARK; }
|
||||
|
||||
@Override
|
||||
public void onDelete(SectionPosition pos) { mSearchResults.remove(pos.itemIndex); }
|
||||
public void onDelete(@NonNull SectionPosition pos) { mSearchResults.remove(pos.itemIndex); }
|
||||
|
||||
@Override
|
||||
public long getBookmarkId(SectionPosition pos) { return mSearchResults.get(pos.itemIndex); }
|
||||
public long getBookmarkId(@NonNull SectionPosition pos) { return mSearchResults.get(pos.itemIndex); }
|
||||
|
||||
@Override
|
||||
public long getTrackId(SectionPosition pos)
|
||||
public long getTrackId(@NonNull SectionPosition pos)
|
||||
{
|
||||
throw new AssertionError("Tracks unsupported in search results.");
|
||||
}
|
||||
|
@ -274,16 +272,14 @@ public class BookmarkListAdapter extends RecyclerView.Adapter<Holders.BaseBookma
|
|||
@Override
|
||||
public boolean isEditable(int sectionIndex)
|
||||
{
|
||||
if (isDescriptionSection(sectionIndex))
|
||||
return false;
|
||||
return true;
|
||||
return !isDescriptionSection(sectionIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasTitle(int sectionIndex) { return true; }
|
||||
|
||||
@Nullable
|
||||
public String getTitle(int sectionIndex, Resources rs)
|
||||
public String getTitle(int sectionIndex, @NonNull Resources rs)
|
||||
{
|
||||
if (isDescriptionSection(sectionIndex))
|
||||
return rs.getString(R.string.description);
|
||||
|
@ -312,7 +308,7 @@ public class BookmarkListAdapter extends RecyclerView.Adapter<Holders.BaseBookma
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onDelete(SectionPosition pos)
|
||||
public void onDelete(@NonNull SectionPosition pos)
|
||||
{
|
||||
if (isDescriptionSection(pos.sectionIndex))
|
||||
throw new IllegalArgumentException("Delete failed. Invalid section index.");
|
||||
|
@ -332,12 +328,12 @@ public class BookmarkListAdapter extends RecyclerView.Adapter<Holders.BaseBookma
|
|||
mSortedBlocks.remove(blockIndex);
|
||||
}
|
||||
|
||||
public long getBookmarkId(SectionPosition pos)
|
||||
public long getBookmarkId(@NonNull SectionPosition pos)
|
||||
{
|
||||
return getSortedBlock(pos.sectionIndex).getBookmarkIds().get(pos.itemIndex);
|
||||
}
|
||||
|
||||
public long getTrackId(SectionPosition pos)
|
||||
public long getTrackId(@NonNull SectionPosition pos)
|
||||
{
|
||||
return getSortedBlock(pos.sectionIndex).getTrackIds().get(pos.itemIndex);
|
||||
}
|
||||
|
@ -377,7 +373,7 @@ public class BookmarkListAdapter extends RecyclerView.Adapter<Holders.BaseBookma
|
|||
return new SectionPosition(SectionPosition.INVALID_POSITION, SectionPosition.INVALID_POSITION);
|
||||
}
|
||||
|
||||
public void setSearchResults(@Nullable long[] searchResults)
|
||||
void setSearchResults(@Nullable long[] searchResults)
|
||||
{
|
||||
if (searchResults != null)
|
||||
{
|
||||
|
@ -392,7 +388,7 @@ public class BookmarkListAdapter extends RecyclerView.Adapter<Holders.BaseBookma
|
|||
refreshSections();
|
||||
}
|
||||
|
||||
public void setSortedResults(@Nullable SortedBlock[] sortedResults)
|
||||
void setSortedResults(@Nullable SortedBlock[] sortedResults)
|
||||
{
|
||||
if (sortedResults != null)
|
||||
mSortedResults = new ArrayList<>(Arrays.asList(sortedResults));
|
||||
|
@ -406,7 +402,7 @@ public class BookmarkListAdapter extends RecyclerView.Adapter<Holders.BaseBookma
|
|||
mClickListener = listener;
|
||||
}
|
||||
|
||||
public void setOnLongClickListener(@Nullable RecyclerLongClickListener listener)
|
||||
void setOnLongClickListener(@Nullable RecyclerLongClickListener listener)
|
||||
{
|
||||
mLongClickListener = listener;
|
||||
}
|
||||
|
@ -417,7 +413,8 @@ public class BookmarkListAdapter extends RecyclerView.Adapter<Holders.BaseBookma
|
|||
}
|
||||
|
||||
@Override
|
||||
public Holders.BaseBookmarkHolder onCreateViewHolder(ViewGroup parent, int viewType)
|
||||
@NonNull
|
||||
public Holders.BaseBookmarkHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType)
|
||||
{
|
||||
LayoutInflater inflater = LayoutInflater.from(parent.getContext());
|
||||
Holders.BaseBookmarkHolder holder = null;
|
||||
|
@ -456,7 +453,7 @@ public class BookmarkListAdapter extends RecyclerView.Adapter<Holders.BaseBookma
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(Holders.BaseBookmarkHolder holder, int position)
|
||||
public void onBindViewHolder(@NonNull Holders.BaseBookmarkHolder holder, int position)
|
||||
{
|
||||
SectionPosition sp = getSectionPosition(position);
|
||||
holder.bind(sp, mSectionsDataSource);
|
||||
|
@ -496,7 +493,7 @@ public class BookmarkListAdapter extends RecyclerView.Adapter<Holders.BaseBookma
|
|||
return itemCount;
|
||||
}
|
||||
|
||||
public void onDelete(int position)
|
||||
void onDelete(int position)
|
||||
{
|
||||
SectionPosition sp = getSectionPosition(position);
|
||||
mSectionsDataSource.onDelete(sp);
|
||||
|
@ -505,7 +502,7 @@ public class BookmarkListAdapter extends RecyclerView.Adapter<Holders.BaseBookma
|
|||
mSortedResults = null;
|
||||
}
|
||||
|
||||
public boolean isSearchResults()
|
||||
boolean isSearchResults()
|
||||
{
|
||||
return mSearchResults != null;
|
||||
}
|
||||
|
|
|
@ -71,8 +71,10 @@ public class BookmarksListFragment extends BaseMwmRecyclerFragment<BookmarkListA
|
|||
private boolean mSearchMode = false;
|
||||
private boolean mNeedUpdateSorting = true;
|
||||
|
||||
@SuppressWarnings("NullableProblems")
|
||||
@NonNull
|
||||
private ViewGroup mSearchContainer;
|
||||
@SuppressWarnings("NullableProblems")
|
||||
@NonNull
|
||||
private FloatingActionButton mFabViewOnMap;
|
||||
|
||||
|
@ -80,6 +82,7 @@ public class BookmarksListFragment extends BaseMwmRecyclerFragment<BookmarkListA
|
|||
@NonNull
|
||||
private BookmarkManager.BookmarksCatalogListener mCatalogListener;
|
||||
|
||||
@NonNull
|
||||
private final RecyclerView.OnScrollListener mRecyclerListener = new RecyclerView.OnScrollListener()
|
||||
{
|
||||
@Override
|
||||
|
@ -222,7 +225,7 @@ public class BookmarksListFragment extends BaseMwmRecyclerFragment<BookmarkListA
|
|||
private void configureRecycler()
|
||||
{
|
||||
RecyclerView.ItemDecoration decor = ItemDecoratorFactory
|
||||
.createDefaultDecorator(getContext(), LinearLayoutManager.VERTICAL);
|
||||
.createDefaultDecorator(requireContext(), LinearLayoutManager.VERTICAL);
|
||||
getRecyclerView().addItemDecoration(decor);
|
||||
getRecyclerView().addOnScrollListener(mRecyclerListener);
|
||||
}
|
||||
|
@ -526,7 +529,7 @@ public class BookmarksListFragment extends BaseMwmRecyclerFragment<BookmarkListA
|
|||
: R.menu.menu_bookmarks;
|
||||
BottomSheet bs = BottomSheetHelper.create(requireActivity(), bookmark.getTitle())
|
||||
.sheet(menuResId)
|
||||
.listener(menuItem -> onBookmarkMenuItemClicked(menuItem))
|
||||
.listener(this::onBookmarkMenuItemClicked)
|
||||
.build();
|
||||
BottomSheetHelper.tint(bs);
|
||||
bs.show();
|
||||
|
@ -553,7 +556,7 @@ public class BookmarksListFragment extends BaseMwmRecyclerFragment<BookmarkListA
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean onBookmarkMenuItemClicked(MenuItem menuItem)
|
||||
public boolean onBookmarkMenuItemClicked(@NonNull MenuItem menuItem)
|
||||
{
|
||||
BookmarkListAdapter adapter = getAdapter();
|
||||
Bookmark item = (Bookmark) adapter.getItem(mSelectedPosition);
|
||||
|
@ -588,7 +591,7 @@ public class BookmarksListFragment extends BaseMwmRecyclerFragment<BookmarkListA
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean onListMoreMenuItemClick(MenuItem menuItem)
|
||||
public boolean onListMoreMenuItemClick(@NonNull MenuItem menuItem)
|
||||
{
|
||||
switch (menuItem.getItemId())
|
||||
{
|
||||
|
@ -608,7 +611,7 @@ public class BookmarksListFragment extends BaseMwmRecyclerFragment<BookmarkListA
|
|||
return false;
|
||||
|
||||
case R.id.settings:
|
||||
Intent intent = new Intent(getContext(), UgcRouteEditSettingsActivity.class).putExtra(
|
||||
Intent intent = new Intent(requireContext(), UgcRouteEditSettingsActivity.class).putExtra(
|
||||
BaseUgcRouteActivity.EXTRA_BOOKMARK_CATEGORY,
|
||||
mCategoryDataSource.getData());
|
||||
startActivityForResult(intent, UgcRouteEditSettingsActivity.REQUEST_CODE);
|
||||
|
@ -665,7 +668,7 @@ public class BookmarksListFragment extends BaseMwmRecyclerFragment<BookmarkListA
|
|||
BottomSheet bs = BottomSheetHelper.create(requireActivity(),
|
||||
mCategoryDataSource.getData().getName())
|
||||
.sheet(R.menu.menu_bookmarks_list)
|
||||
.listener(menuItem -> onListMoreMenuItemClick(menuItem))
|
||||
.listener(this::onListMoreMenuItemClick)
|
||||
.build();
|
||||
|
||||
@BookmarkManager.SortingType int[] types = getAvailableSortingTypes();
|
||||
|
|
|
@ -2,10 +2,10 @@ package com.mapswithme.maps.bookmarks;
|
|||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.IdRes;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
@ -24,7 +24,7 @@ public class ChooseBookmarksSortingTypeFragment extends BaseMwmDialogFragment
|
|||
private static final String EXTRA_CURRENT_SORT_TYPE = "current_sort_type";
|
||||
|
||||
@Nullable
|
||||
ChooseSortingTypeListener mListener;
|
||||
private ChooseSortingTypeListener mListener;
|
||||
|
||||
public interface ChooseSortingTypeListener
|
||||
{
|
||||
|
@ -60,6 +60,7 @@ public class ChooseBookmarksSortingTypeFragment extends BaseMwmDialogFragment
|
|||
return STYLE_NO_TITLE;
|
||||
}
|
||||
|
||||
@IdRes
|
||||
private int getViewId(int sortingType)
|
||||
{
|
||||
if (sortingType >= 0)
|
||||
|
@ -84,12 +85,14 @@ public class ChooseBookmarksSortingTypeFragment extends BaseMwmDialogFragment
|
|||
|
||||
final Bundle args = getArguments();
|
||||
|
||||
UiUtils.hide(view.findViewById(R.id.sort_by_type));
|
||||
UiUtils.hide(view.findViewById(R.id.sort_by_distance));
|
||||
UiUtils.hide(view.findViewById(R.id.sort_by_time));
|
||||
UiUtils.hide(view, R.id.sort_by_type, R.id.sort_by_distance, R.id.sort_by_time);
|
||||
|
||||
if (args.getIntArray(EXTRA_SORTING_TYPES) == null)
|
||||
throw new AssertionError("Available sorting types can't be null.");
|
||||
|
||||
@BookmarkManager.SortingType
|
||||
int[] availableSortingTypes = args.getIntArray(EXTRA_SORTING_TYPES);
|
||||
|
||||
for (int i = 0; i < availableSortingTypes.length; ++i)
|
||||
UiUtils.show(view.findViewById(getViewId(availableSortingTypes[i])));
|
||||
|
||||
|
@ -108,7 +111,7 @@ public class ChooseBookmarksSortingTypeFragment extends BaseMwmDialogFragment
|
|||
onAttachInternal();
|
||||
}
|
||||
|
||||
protected void onAttachInternal()
|
||||
private void onAttachInternal()
|
||||
{
|
||||
mListener = (ChooseSortingTypeListener) (getParentFragment() == null ? getTargetFragment()
|
||||
: getParentFragment());
|
||||
|
@ -136,7 +139,7 @@ public class ChooseBookmarksSortingTypeFragment extends BaseMwmDialogFragment
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onCheckedChanged(RadioGroup group, int id)
|
||||
public void onCheckedChanged(RadioGroup group, @IdRes int id)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
|
|
|
@ -247,7 +247,7 @@ public class Holders
|
|||
private final TextView mName;
|
||||
@NonNull
|
||||
private final TextView mDistance;
|
||||
@Nullable
|
||||
@NonNull
|
||||
private View mMore;
|
||||
|
||||
BookmarkViewHolder(@NonNull View itemView)
|
||||
|
|
|
@ -64,8 +64,7 @@ public class Bookmark extends MapObject
|
|||
super.writeToParcel(dest, flags);
|
||||
dest.writeLong(mCategoryId);
|
||||
dest.writeLong(mBookmarkId);
|
||||
dest.writeInt(mIcon.getColor());
|
||||
dest.writeInt(mIcon.getType());
|
||||
dest.writeParcelable(mIcon, flags);
|
||||
dest.writeDouble(mMerX);
|
||||
dest.writeDouble(mMerY);
|
||||
}
|
||||
|
@ -78,7 +77,7 @@ public class Bookmark extends MapObject
|
|||
super(type, source);
|
||||
mCategoryId = source.readLong();
|
||||
mBookmarkId = source.readLong();
|
||||
mIcon = new Icon(source.readInt(), source.readInt());
|
||||
mIcon = source.readParcelable(Icon.class.getClassLoader());
|
||||
mMerX = source.readDouble();
|
||||
mMerY = source.readDouble();
|
||||
initXY();
|
||||
|
@ -167,6 +166,7 @@ public class Bookmark extends MapObject
|
|||
|
||||
public static native String nativeGetName(@IntRange(from = 0) long bookmarkId);
|
||||
|
||||
@NonNull
|
||||
public static native String nativeGetFeatureType(@IntRange(from = 0) long bookmarkId);
|
||||
|
||||
public static native ParcelablePointD nativeGetXY(@IntRange(from = 0) long bookmarkId);
|
||||
|
|
|
@ -942,7 +942,7 @@ public enum BookmarkManager
|
|||
|
||||
public interface BookmarksSortingListener
|
||||
{
|
||||
void onBookmarksSortingCompleted(SortedBlock[] sortedBlocks, long timestamp);
|
||||
void onBookmarksSortingCompleted(@NonNull SortedBlock[] sortedBlocks, long timestamp);
|
||||
void onBookmarksSortingCancelled(long timestamp);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,71 +1,78 @@
|
|||
package com.mapswithme.maps.bookmarks.data;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.support.annotation.DrawableRes;
|
||||
import android.support.annotation.IdRes;
|
||||
import android.support.annotation.IntDef;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import com.mapswithme.maps.R;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
public class Icon
|
||||
public class Icon implements Parcelable
|
||||
{
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@IntDef({ PREDEFINED_COLOR_NONE, PREDEFINED_COLOR_RED, PREDEFINED_COLOR_BLUE,
|
||||
PREDEFINED_COLOR_PURPLE, PREDEFINED_COLOR_YELLOW, PREDEFINED_COLOR_PINK,
|
||||
PREDEFINED_COLOR_BROWN, PREDEFINED_COLOR_GREEN, PREDEFINED_COLOR_ORANGE })
|
||||
public @interface PredefinedColor {}
|
||||
@interface PredefinedColor {}
|
||||
|
||||
public static final int PREDEFINED_COLOR_NONE = 0;
|
||||
public static final int PREDEFINED_COLOR_RED = 1;
|
||||
public static final int PREDEFINED_COLOR_BLUE = 2;
|
||||
public static final int PREDEFINED_COLOR_PURPLE = 3;
|
||||
public static final int PREDEFINED_COLOR_YELLOW = 4;
|
||||
public static final int PREDEFINED_COLOR_PINK = 5;
|
||||
public static final int PREDEFINED_COLOR_BROWN = 6;
|
||||
public static final int PREDEFINED_COLOR_GREEN = 7;
|
||||
public static final int PREDEFINED_COLOR_ORANGE = 8;
|
||||
static final int PREDEFINED_COLOR_NONE = 0;
|
||||
static final int PREDEFINED_COLOR_RED = 1;
|
||||
static final int PREDEFINED_COLOR_BLUE = 2;
|
||||
static final int PREDEFINED_COLOR_PURPLE = 3;
|
||||
static final int PREDEFINED_COLOR_YELLOW = 4;
|
||||
static final int PREDEFINED_COLOR_PINK = 5;
|
||||
static final int PREDEFINED_COLOR_BROWN = 6;
|
||||
static final int PREDEFINED_COLOR_GREEN = 7;
|
||||
static final int PREDEFINED_COLOR_ORANGE = 8;
|
||||
|
||||
public static final String[] PREDEFINED_COLOR_NAMES = { "placemark-red", "placemark-red",
|
||||
"placemark-blue", "placemark-purple",
|
||||
"placemark-yellow", "placemark-pink",
|
||||
"placemark-brown", "placemark-green",
|
||||
"placemark-orange" };
|
||||
private static final String[] PREDEFINED_COLOR_NAMES = { "placemark-red", "placemark-red",
|
||||
"placemark-blue", "placemark-purple",
|
||||
"placemark-yellow", "placemark-pink",
|
||||
"placemark-brown", "placemark-green",
|
||||
"placemark-orange" };
|
||||
|
||||
public static final int[] COLOR_ICONS_ON = { R.drawable.ic_bookmark_marker_red_on,
|
||||
R.drawable.ic_bookmark_marker_red_on,
|
||||
R.drawable.ic_bookmark_marker_blue_on,
|
||||
R.drawable.ic_bookmark_marker_purple_on,
|
||||
R.drawable.ic_bookmark_marker_yellow_on,
|
||||
R.drawable.ic_bookmark_marker_pink_on,
|
||||
R.drawable.ic_bookmark_marker_brown_on,
|
||||
R.drawable.ic_bookmark_marker_green_on,
|
||||
R.drawable.ic_bookmark_marker_orange_on };
|
||||
@DrawableRes
|
||||
private static final int[] COLOR_ICONS_ON = { R.drawable.ic_bookmark_marker_red_on,
|
||||
R.drawable.ic_bookmark_marker_red_on,
|
||||
R.drawable.ic_bookmark_marker_blue_on,
|
||||
R.drawable.ic_bookmark_marker_purple_on,
|
||||
R.drawable.ic_bookmark_marker_yellow_on,
|
||||
R.drawable.ic_bookmark_marker_pink_on,
|
||||
R.drawable.ic_bookmark_marker_brown_on,
|
||||
R.drawable.ic_bookmark_marker_green_on,
|
||||
R.drawable.ic_bookmark_marker_orange_on };
|
||||
|
||||
public static final int[] COLOR_ICONS_OFF = { R.drawable.ic_bookmark_marker_red_off,
|
||||
R.drawable.ic_bookmark_marker_red_off,
|
||||
R.drawable.ic_bookmark_marker_blue_off,
|
||||
R.drawable.ic_bookmark_marker_purple_off,
|
||||
R.drawable.ic_bookmark_marker_yellow_off,
|
||||
R.drawable.ic_bookmark_marker_pink_off,
|
||||
R.drawable.ic_bookmark_marker_brown_off,
|
||||
R.drawable.ic_bookmark_marker_green_off,
|
||||
R.drawable.ic_bookmark_marker_orange_off };
|
||||
@DrawableRes
|
||||
private static final int[] COLOR_ICONS_OFF = { R.drawable.ic_bookmark_marker_red_off,
|
||||
R.drawable.ic_bookmark_marker_red_off,
|
||||
R.drawable.ic_bookmark_marker_blue_off,
|
||||
R.drawable.ic_bookmark_marker_purple_off,
|
||||
R.drawable.ic_bookmark_marker_yellow_off,
|
||||
R.drawable.ic_bookmark_marker_pink_off,
|
||||
R.drawable.ic_bookmark_marker_brown_off,
|
||||
R.drawable.ic_bookmark_marker_green_off,
|
||||
R.drawable.ic_bookmark_marker_orange_off };
|
||||
|
||||
static int shift(int v, int bitCount) { return v << bitCount; }
|
||||
static int toARGB(int r, int g, int b)
|
||||
private static int shift(int v, int bitCount) { return v << bitCount; }
|
||||
private static int toARGB(int r, int g, int b)
|
||||
{
|
||||
return shift(255, 24) + shift(r, 16) + shift(g, 8) + b;
|
||||
}
|
||||
|
||||
public static final int[] ARGB_COLORS = { toARGB(229, 27, 35),
|
||||
toARGB(229, 27, 35),
|
||||
toARGB(0, 110, 199),
|
||||
toARGB(156, 39, 176),
|
||||
toARGB(255, 200, 0),
|
||||
toARGB(255, 65, 130),
|
||||
toARGB(121, 85, 72),
|
||||
toARGB(56, 142, 60),
|
||||
toARGB(255, 160, 0) };
|
||||
private static final int[] ARGB_COLORS = { toARGB(229, 27, 35),
|
||||
toARGB(229, 27, 35),
|
||||
toARGB(0, 110, 199),
|
||||
toARGB(156, 39, 176),
|
||||
toARGB(255, 200, 0),
|
||||
toARGB(255, 65, 130),
|
||||
toARGB(121, 85, 72),
|
||||
toARGB(56, 142, 60),
|
||||
toARGB(255, 160, 0) };
|
||||
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@IntDef({ BOOKMARK_ICON_TYPE_NONE,
|
||||
|
@ -89,79 +96,102 @@ public class Icon
|
|||
BOOKMARK_ICON_TYPE_SIGHTS,
|
||||
BOOKMARK_ICON_TYPE_SWIM,
|
||||
BOOKMARK_ICON_TYPE_WATER })
|
||||
public @interface BookmarkIconType {}
|
||||
@interface BookmarkIconType {}
|
||||
|
||||
public static final int BOOKMARK_ICON_TYPE_NONE = 0;
|
||||
public static final int BOOKMARK_ICON_TYPE_HOTEL = 1;
|
||||
public static final int BOOKMARK_ICON_TYPE_ANIMALS = 2;
|
||||
public static final int BOOKMARK_ICON_TYPE_BUDDHISM = 3;
|
||||
public static final int BOOKMARK_ICON_TYPE_BUILDING = 4;
|
||||
public static final int BOOKMARK_ICON_TYPE_CHRISTIANITY = 5;
|
||||
public static final int BOOKMARK_ICON_TYPE_ENTERTAINMENT = 6;
|
||||
public static final int BOOKMARK_ICON_TYPE_EXCHANGE = 7;
|
||||
public static final int BOOKMARK_ICON_TYPE_FOOD = 8;
|
||||
public static final int BOOKMARK_ICON_TYPE_GAS = 9;
|
||||
public static final int BOOKMARK_ICON_TYPE_JUDAISM = 10;
|
||||
public static final int BOOKMARK_ICON_TYPE_MEDICINE = 11;
|
||||
public static final int BOOKMARK_ICON_TYPE_MOUNTAIN = 12;
|
||||
public static final int BOOKMARK_ICON_TYPE_MUSEUM = 13;
|
||||
public static final int BOOKMARK_ICON_TYPE_ISLAM = 14;
|
||||
public static final int BOOKMARK_ICON_TYPE_PARK = 15;
|
||||
public static final int BOOKMARK_ICON_TYPE_PARKING = 16;
|
||||
public static final int BOOKMARK_ICON_TYPE_SHOP = 17;
|
||||
public static final int BOOKMARK_ICON_TYPE_SIGHTS = 18;
|
||||
public static final int BOOKMARK_ICON_TYPE_SWIM = 19;
|
||||
public static final int BOOKMARK_ICON_TYPE_WATER = 20;
|
||||
static final int BOOKMARK_ICON_TYPE_NONE = 0;
|
||||
static final int BOOKMARK_ICON_TYPE_HOTEL = 1;
|
||||
static final int BOOKMARK_ICON_TYPE_ANIMALS = 2;
|
||||
static final int BOOKMARK_ICON_TYPE_BUDDHISM = 3;
|
||||
static final int BOOKMARK_ICON_TYPE_BUILDING = 4;
|
||||
static final int BOOKMARK_ICON_TYPE_CHRISTIANITY = 5;
|
||||
static final int BOOKMARK_ICON_TYPE_ENTERTAINMENT = 6;
|
||||
static final int BOOKMARK_ICON_TYPE_EXCHANGE = 7;
|
||||
static final int BOOKMARK_ICON_TYPE_FOOD = 8;
|
||||
static final int BOOKMARK_ICON_TYPE_GAS = 9;
|
||||
static final int BOOKMARK_ICON_TYPE_JUDAISM = 10;
|
||||
static final int BOOKMARK_ICON_TYPE_MEDICINE = 11;
|
||||
static final int BOOKMARK_ICON_TYPE_MOUNTAIN = 12;
|
||||
static final int BOOKMARK_ICON_TYPE_MUSEUM = 13;
|
||||
static final int BOOKMARK_ICON_TYPE_ISLAM = 14;
|
||||
static final int BOOKMARK_ICON_TYPE_PARK = 15;
|
||||
static final int BOOKMARK_ICON_TYPE_PARKING = 16;
|
||||
static final int BOOKMARK_ICON_TYPE_SHOP = 17;
|
||||
static final int BOOKMARK_ICON_TYPE_SIGHTS = 18;
|
||||
static final int BOOKMARK_ICON_TYPE_SWIM = 19;
|
||||
static final int BOOKMARK_ICON_TYPE_WATER = 20;
|
||||
|
||||
public static final int[] TYPE_ICONS = { R.drawable.ic_bookmark_none,
|
||||
R.drawable.ic_bookmark_hotel,
|
||||
R.drawable.ic_bookmark_animals,
|
||||
R.drawable.ic_bookmark_buddhism,
|
||||
R.drawable.ic_bookmark_building,
|
||||
R.drawable.ic_bookmark_christianity,
|
||||
R.drawable.ic_bookmark_entertainment,
|
||||
R.drawable.ic_bookmark_money,
|
||||
R.drawable.ic_bookmark_food,
|
||||
R.drawable.ic_bookmark_gas,
|
||||
R.drawable.ic_bookmark_judaism,
|
||||
R.drawable.ic_bookmark_medicine,
|
||||
R.drawable.ic_bookmark_mountain,
|
||||
R.drawable.ic_bookmark_museum,
|
||||
R.drawable.ic_bookmark_islam,
|
||||
R.drawable.ic_bookmark_park,
|
||||
R.drawable.ic_bookmark_parking,
|
||||
R.drawable.ic_bookmark_shop,
|
||||
R.drawable.ic_bookmark_sights,
|
||||
R.drawable.ic_bookmark_swim,
|
||||
R.drawable.ic_bookmark_water };
|
||||
@DrawableRes
|
||||
private static final int[] TYPE_ICONS = { R.drawable.ic_bookmark_none,
|
||||
R.drawable.ic_bookmark_hotel,
|
||||
R.drawable.ic_bookmark_animals,
|
||||
R.drawable.ic_bookmark_buddhism,
|
||||
R.drawable.ic_bookmark_building,
|
||||
R.drawable.ic_bookmark_christianity,
|
||||
R.drawable.ic_bookmark_entertainment,
|
||||
R.drawable.ic_bookmark_money,
|
||||
R.drawable.ic_bookmark_food,
|
||||
R.drawable.ic_bookmark_gas,
|
||||
R.drawable.ic_bookmark_judaism,
|
||||
R.drawable.ic_bookmark_medicine,
|
||||
R.drawable.ic_bookmark_mountain,
|
||||
R.drawable.ic_bookmark_museum,
|
||||
R.drawable.ic_bookmark_islam,
|
||||
R.drawable.ic_bookmark_park,
|
||||
R.drawable.ic_bookmark_parking,
|
||||
R.drawable.ic_bookmark_shop,
|
||||
R.drawable.ic_bookmark_sights,
|
||||
R.drawable.ic_bookmark_swim,
|
||||
R.drawable.ic_bookmark_water };
|
||||
|
||||
@PredefinedColor
|
||||
private final int mColor;
|
||||
@BookmarkIconType
|
||||
private final int mType;
|
||||
|
||||
public Icon(@PredefinedColor int color, int type)
|
||||
public Icon(@PredefinedColor int color, @BookmarkIconType int type)
|
||||
{
|
||||
mColor = color;
|
||||
mType = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags)
|
||||
{
|
||||
dest.writeInt(mColor);
|
||||
dest.writeInt(mType);
|
||||
}
|
||||
|
||||
private Icon(Parcel in)
|
||||
{
|
||||
mColor = in.readInt();
|
||||
mType = in.readInt();
|
||||
}
|
||||
|
||||
@PredefinedColor
|
||||
public int getColor()
|
||||
{
|
||||
return mColor;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public String getName()
|
||||
{
|
||||
return PREDEFINED_COLOR_NAMES[mColor];
|
||||
}
|
||||
|
||||
@DrawableRes
|
||||
public int getCheckedResId()
|
||||
{
|
||||
return COLOR_ICONS_ON[mColor];
|
||||
}
|
||||
|
||||
@DrawableRes
|
||||
public int getUncheckedResId()
|
||||
{
|
||||
return COLOR_ICONS_OFF[mColor];
|
||||
|
@ -172,11 +202,13 @@ public class Icon
|
|||
return ARGB_COLORS[mColor];
|
||||
}
|
||||
|
||||
@BookmarkIconType
|
||||
public int getType()
|
||||
{
|
||||
return mType;
|
||||
}
|
||||
|
||||
@DrawableRes
|
||||
public int getResId()
|
||||
{
|
||||
return TYPE_ICONS[mType];
|
||||
|
@ -197,4 +229,17 @@ public class Icon
|
|||
{
|
||||
return mColor;
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<Icon> CREATOR = new Parcelable.Creator<Icon>()
|
||||
{
|
||||
public Icon createFromParcel(Parcel in)
|
||||
{
|
||||
return new Icon(in);
|
||||
}
|
||||
|
||||
public Icon[] newArray(int size)
|
||||
{
|
||||
return new Icon[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -8,9 +8,12 @@ import com.mapswithme.maps.Framework;
|
|||
import com.mapswithme.maps.api.ParsedMwmRequest;
|
||||
import com.mapswithme.maps.base.Initializable;
|
||||
import com.mapswithme.maps.bookmarks.data.FeatureId;
|
||||
import com.mapswithme.maps.intent.Factory;
|
||||
import com.mapswithme.util.Language;
|
||||
import com.mapswithme.util.Listeners;
|
||||
import com.mapswithme.util.concurrency.UiThread;
|
||||
import com.mapswithme.util.log.Logger;
|
||||
import com.mapswithme.util.log.LoggerFactory;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
|
@ -22,6 +25,9 @@ public enum SearchEngine implements NativeSearchListener,
|
|||
{
|
||||
INSTANCE;
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.INSTANCE.getLogger(LoggerFactory.Type.MISC);
|
||||
private static final String TAG = SearchEngine.class.getSimpleName();
|
||||
|
||||
// Query, which results are shown on the map.
|
||||
@Nullable
|
||||
private String mQuery;
|
||||
|
@ -187,12 +193,15 @@ public enum SearchEngine implements NativeSearchListener,
|
|||
}
|
||||
|
||||
@MainThread
|
||||
public boolean searchInBookmarks(String query, long categoryId, long timestamp)
|
||||
public boolean searchInBookmarks(@NonNull String query, long categoryId, long timestamp)
|
||||
{
|
||||
try
|
||||
{
|
||||
return nativeRunSearchInBookmarks(query.getBytes("utf-8"), categoryId, timestamp);
|
||||
} catch (UnsupportedEncodingException ignored) { }
|
||||
} catch (UnsupportedEncodingException ex)
|
||||
{
|
||||
LOGGER.w(TAG, "Unsupported encoding in bookmarks search.", ex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,10 @@ import android.graphics.drawable.BitmapDrawable;
|
|||
import android.graphics.drawable.Drawable;
|
||||
import android.support.annotation.AttrRes;
|
||||
import android.support.annotation.ColorInt;
|
||||
import android.support.annotation.DimenRes;
|
||||
import android.support.annotation.DrawableRes;
|
||||
import android.support.annotation.IdRes;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.graphics.drawable.DrawableCompat;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
@ -20,7 +23,8 @@ import com.mapswithme.maps.R;
|
|||
|
||||
public final class Graphics
|
||||
{
|
||||
public static Drawable drawCircle(int color, int sizeResId, Resources res)
|
||||
@NonNull
|
||||
public static Drawable drawCircle(int color, @DimenRes int sizeResId, @NonNull Resources res)
|
||||
{
|
||||
final int size = res.getDimensionPixelSize(sizeResId);
|
||||
final Bitmap bmp = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
|
||||
|
@ -36,8 +40,10 @@ public final class Graphics
|
|||
return new BitmapDrawable(res, bmp);
|
||||
}
|
||||
|
||||
public static Drawable drawCircleAndImage(int color, int sizeResId,
|
||||
int imageResId, int sizeImgResId, Resources res)
|
||||
@NonNull
|
||||
public static Drawable drawCircleAndImage(int color, @DimenRes int sizeResId,
|
||||
@DrawableRes int imageResId, @DimenRes int sizeImgResId,
|
||||
@NonNull Resources res)
|
||||
{
|
||||
final int size = res.getDimensionPixelSize(sizeResId);
|
||||
final Bitmap bmp = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
|
||||
|
|
Loading…
Add table
Reference in a new issue