[android] Fixed collection recycler animation.

This commit is contained in:
velichkomarija 2020-10-20 15:00:01 +03:00 committed by Alexey
parent aff4aa575b
commit 3fc748d792
3 changed files with 13 additions and 2 deletions

View file

@ -24,6 +24,7 @@
android:id="@+id/collections_recycler"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:overScrollMode="never"
android:background="?cardBackground"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler"

View file

@ -62,8 +62,6 @@ public class BookmarkCollectionAdapter extends RecyclerView.Adapter<RecyclerView
BookmarkCategory category = mHolder.getEntity();
BookmarkManager.INSTANCE.toggleCategoryVisibility(category);
category.invertVisibility();
notifyItemChanged(mHolder.getAdapterPosition());
notifyItemChanged(SectionPosition.INVALID_POSITION);
int type = BookmarkManager.INSTANCE.getCompilationType(category.getId());
String compilationTypeString = type == BookmarkManager.CATEGORY ?
@ -72,6 +70,13 @@ public class BookmarkCollectionAdapter extends RecyclerView.Adapter<RecyclerView
Statistics.INSTANCE.trackGuideVisibilityChange(
category.isVisible() ? Statistics.ParamValue.SHOW : Statistics.ParamValue.HIDE,
category.getServerId(), compilationTypeString);
if (type == BookmarkManager.COLLECTION)
notifyItemChanged(0);
else if (mItemsCollection.size() > 0)
notifyItemChanged(mItemsCollection.size() + 1);
else
notifyItemChanged(0);
}
}

View file

@ -20,6 +20,7 @@ import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.SimpleItemAnimator;
import com.cocosw.bottomsheet.BottomSheet;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.mapswithme.maps.MwmActivity;
@ -271,6 +272,10 @@ public class BookmarksListFragment extends BaseMwmRecyclerFragment<BookmarkListA
manager.setSmoothScrollbarEnabled(true);
mCollectionRecyclerView.setLayoutManager(manager);
RecyclerView.ItemAnimator itemAnimator = mCollectionRecyclerView.getItemAnimator();
if (itemAnimator != null)
((SimpleItemAnimator) itemAnimator).setSupportsChangeAnimations(false);
mCollectionRecyclerView.setAdapter(mBookmarkCollectionAdapter);
configureRecyclerDividers(mCollectionRecyclerView);
}