From 6ce3053bcebf809bcc56c3846777e607df4b7593 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=80=20?= =?UTF-8?q?=D0=97=D0=B0=D1=86=D0=B5=D0=BF=D0=B8=D0=BD?= Date: Thu, 22 Mar 2018 14:45:01 +0300 Subject: [PATCH] [android] Implemented hide/show all logic in bookmark category list --- ...ml => item_bookmark_group_list_header.xml} | 2 +- .../bookmarks/BookmarkCategoriesAdapter.java | 44 ++++++++++++++----- .../mapswithme/maps/bookmarks/Holders.java | 41 +++++++++++++++++ .../maps/bookmarks/data/BookmarkManager.java | 33 +++++++++++--- 4 files changed, 102 insertions(+), 18 deletions(-) rename android/res/layout/{item_bookmark_hide_all.xml => item_bookmark_group_list_header.xml} (97%) diff --git a/android/res/layout/item_bookmark_hide_all.xml b/android/res/layout/item_bookmark_group_list_header.xml similarity index 97% rename from android/res/layout/item_bookmark_hide_all.xml rename to android/res/layout/item_bookmark_group_list_header.xml index 5fd0f26f4c..8e75bd23dd 100644 --- a/android/res/layout/item_bookmark_hide_all.xml +++ b/android/res/layout/item_bookmark_group_list_header.xml @@ -17,7 +17,7 @@ android:fontFamily="@string/robotoMedium" tools:targetApi="jelly_bean"/> { private final static int TYPE_CATEGORY_ITEM = 0; private final static int TYPE_ACTION_CREATE_GROUP = 1; - private final static int TYPE_ACTION_HIDE_ALL = 2; + private final static int TYPE_ACTION_HEADER = 2; + private final static int HEADER_POSITION = 0; @Nullable private RecyclerLongClickListener mLongClickListener; @Nullable @@ -52,15 +53,10 @@ public class BookmarkCategoriesAdapter extends BaseBookmarkCategoryAdapter - { - Toast.makeText(getContext(), "Coming soon", Toast.LENGTH_SHORT).show(); - }); - return new Holders.GeneralViewHolder(hideAllView); + View header = inflater.inflate(R.layout.item_bookmark_group_list_header, parent, false); + return new Holders.HeaderViewHolder(header); } if (viewType == TYPE_ACTION_CREATE_GROUP) @@ -99,9 +95,32 @@ public class BookmarkCategoriesAdapter extends BaseBookmarkCategoryAdapter { if (mCategoryListInterface != null) @@ -124,7 +144,7 @@ public class BookmarkCategoriesAdapter extends BaseBookmarkCategoryAdapter + { + if (action == null) + return; + + Resources res = mButton.getResources(); + if (mButton.getText().equals(res.getString(R.string.bookmarks_groups_show_all))) + action.onShowAll(); + else + action.onHideAll(); + }); + } + + public interface HeaderAction + { + void onHideAll(); + void onShowAll(); + } + } + static class CategoryViewHolder extends RecyclerView.ViewHolder { @NonNull diff --git a/android/src/com/mapswithme/maps/bookmarks/data/BookmarkManager.java b/android/src/com/mapswithme/maps/bookmarks/data/BookmarkManager.java index 9e3e02b870..e5ce751188 100644 --- a/android/src/com/mapswithme/maps/bookmarks/data/BookmarkManager.java +++ b/android/src/com/mapswithme/maps/bookmarks/data/BookmarkManager.java @@ -240,6 +240,26 @@ public enum BookmarkManager return nativeIsAsyncBookmarksLoadingInProgress(); } + public boolean isUsedCategoryName(@NonNull String name) + { + return nativeIsUsedCategoryName(name); + } + + public boolean areAllCategoriesVisible() + { + return nativeAreAllCategoriesVisible(); + } + + public boolean areAllCategoriesInvisible() + { + return nativeAreAllCategoriesInvisible(); + } + + public void setAllCategoriesVisibility(boolean visible) + { + nativeSetAllCategoriesVisibility(visible); + } + private native int nativeGetCategoriesCount(); private native int nativeGetCategoryPositionById(long catId); @@ -311,15 +331,18 @@ public enum BookmarkManager private static native boolean nativeIsAsyncBookmarksLoadingInProgress(); + private static native boolean nativeIsUsedCategoryName(@NonNull String name); + + private static native boolean nativeAreAllCategoriesVisible(); + + private static native boolean nativeAreAllCategoriesInvisible(); + + private static native void nativeSetAllCategoriesVisibility(boolean visible); + public interface BookmarksLoadingListener { void onBookmarksLoadingStarted(); void onBookmarksLoadingFinished(); void onBookmarksFileLoaded(boolean success); } - - private static native boolean nativeIsUsedCategoryName(@NonNull String name); - private static native boolean nativeAreAllCategoriesVisible(); - private static native boolean nativeAreAllCategoriesInvisible(); - private static native void nativeSetAllCategoriesVisibility(boolean visible); }