Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArsentiy Milchakov <milcars@mapswithme.com>2018-04-20 11:40:58 +0300
committerAleksandr Zatsepin <alexzatsepin@users.noreply.github.com>2018-04-25 15:38:50 +0300
commit0945fe8f98d11fd159dad399ef64ad2e8ec77815 (patch)
tree720e23b78136423738483cbd9a071e150821b6ca /android/src
parent1cd0bd76fbd59c7be5a5d1d952da435fdf4cf31c (diff)
[android] show/hide delete bookmark menu item
Diffstat (limited to 'android/src')
-rw-r--r--android/src/com/mapswithme/maps/bookmarks/BookmarkCategoriesFragment.java15
-rw-r--r--android/src/com/mapswithme/util/BottomSheetHelper.java23
2 files changed, 33 insertions, 5 deletions
diff --git a/android/src/com/mapswithme/maps/bookmarks/BookmarkCategoriesFragment.java b/android/src/com/mapswithme/maps/bookmarks/BookmarkCategoriesFragment.java
index 9639127e71..40b5ace3dd 100644
--- a/android/src/com/mapswithme/maps/bookmarks/BookmarkCategoriesFragment.java
+++ b/android/src/com/mapswithme/maps/bookmarks/BookmarkCategoriesFragment.java
@@ -232,12 +232,17 @@ public class BookmarkCategoriesFragment extends BaseMwmRecyclerFragment
BottomSheetHelper.Builder bs = BottomSheetHelper.create(getActivity(), name)
.sheet(R.menu.menu_bookmark_categories)
.listener(this);
- MenuItem show = bs.getMenu().getItem(0);
+
final boolean isVisible = bmManager.isVisible(mSelectedCatId);
- show.setIcon(isVisible ? R.drawable.ic_hide
- : R.drawable.ic_show);
- show.setTitle(isVisible ? R.string.hide
- : R.string.show);
+ bs.getItemByIndex(0)
+ .setIcon(isVisible ? R.drawable.ic_hide : R.drawable.ic_show)
+ .setTitle(isVisible ? R.string.hide : R.string.show);
+
+ final boolean deleteIsPossible = bmManager.getCategoriesCount() > 1;
+ bs.getItemById(R.id.set_delete)
+ .setVisible(deleteIsPossible)
+ .setEnabled(deleteIsPossible);
+
bs.tint().show();
}
diff --git a/android/src/com/mapswithme/util/BottomSheetHelper.java b/android/src/com/mapswithme/util/BottomSheetHelper.java
index 16b938080b..e77ca22afd 100644
--- a/android/src/com/mapswithme/util/BottomSheetHelper.java
+++ b/android/src/com/mapswithme/util/BottomSheetHelper.java
@@ -6,6 +6,7 @@ import android.content.ContextWrapper;
import android.content.DialogInterface;
import android.graphics.drawable.Drawable;
import android.support.annotation.DrawableRes;
+import android.support.annotation.IdRes;
import android.support.annotation.MenuRes;
import android.support.annotation.NonNull;
import android.support.annotation.StringRes;
@@ -157,6 +158,28 @@ public final class BottomSheetHelper
return this;
}
+
+ @NonNull
+ public MenuItem getItemByIndex(int index)
+ {
+ MenuItem item = getMenu().getItem(index);
+
+ if (item == null)
+ throw new AssertionError("Can not find bottom sheet item with index: " + index);
+
+ return item;
+ }
+
+ @NonNull
+ public MenuItem getItemById(@IdRes int id)
+ {
+ MenuItem item = getMenu().findItem(id);
+
+ if (item == null)
+ throw new AssertionError("Can not find bottom sheet item with id: " + id);
+
+ return item;
+ }
}