From 67086d606cfa261e3f18d4da023396134d3335b3 Mon Sep 17 00:00:00 2001 From: velichkomarija Date: Tue, 6 Oct 2020 09:37:24 +0300 Subject: [PATCH] [android] Moved SectionPosition to a separate class. --- .../bookmarks/BookmarkCollectionAdapter.java | 42 +++---------------- .../maps/bookmarks/BookmarkListAdapter.java | 34 --------------- .../mapswithme/maps/bookmarks/Holders.java | 13 ++---- .../maps/bookmarks/SectionPosition.java | 35 ++++++++++++++++ 4 files changed, 44 insertions(+), 80 deletions(-) create mode 100644 android/src/com/mapswithme/maps/bookmarks/SectionPosition.java diff --git a/android/src/com/mapswithme/maps/bookmarks/BookmarkCollectionAdapter.java b/android/src/com/mapswithme/maps/bookmarks/BookmarkCollectionAdapter.java index 3738a93ee5..5c34d40627 100644 --- a/android/src/com/mapswithme/maps/bookmarks/BookmarkCollectionAdapter.java +++ b/android/src/com/mapswithme/maps/bookmarks/BookmarkCollectionAdapter.java @@ -38,44 +38,12 @@ public class BookmarkCollectionAdapter extends RecyclerView.Adapter mClickListener; - static class SectionPosition - { - static final int INVALID_POSITION = -1; - - private final int mSectionIndex; - private final int mItemIndex; - - SectionPosition(int sectionInd, int itemInd) - { - mSectionIndex = sectionInd; - mItemIndex = itemInd; - } - - int getSectionIndex() - { - return mSectionIndex; - } - - int getItemIndex() - { - return mItemIndex; - } - - boolean isTitlePosition() - { - return mSectionIndex != INVALID_POSITION && mItemIndex == INVALID_POSITION; - } - - boolean isItemPosition() - { - return mSectionIndex != INVALID_POSITION && mItemIndex != INVALID_POSITION; - } - } - BookmarkCollectionAdapter(@NonNull List itemsCategories, @NonNull List itemsCollection) { + //noinspection AssignmentOrReturnOfFieldWithMutableType mItemsCategory = itemsCategories; + //noinspection AssignmentOrReturnOfFieldWithMutableType mItemsCollection = itemsCollection; mSectionCount = 0; @@ -126,8 +94,8 @@ public class BookmarkCollectionAdapter extends RecyclerView.Adapter categories = getItemsListByType(type); - int itemIndex = sp.mItemIndex; - if (sp.mItemIndex > categories.size() - 1) + int itemIndex = sp.getItemIndex(); + if (sp.getItemIndex() > categories.size() - 1) throw new ArrayIndexOutOfBoundsException(itemIndex); return categories.get(itemIndex); } @@ -185,7 +153,7 @@ public class BookmarkCollectionAdapter extends RecyclerView.Adapter