From b5398ea34027c2f8bde5463de1ef42711f9104e3 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 2 Jun 2017 00:02:58 +0300 Subject: [PATCH] swipe to dismiss: animate item undo --- .../src/main/java/org/fox/ttrss/HeadlinesFragment.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java index ba8d068b..72c154be 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java @@ -368,7 +368,8 @@ public class HeadlinesFragment extends Fragment { @Override public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) { - final int position = viewHolder.getAdapterPosition() - m_adapter.getHeaderCount(); + final int adapterPosition = viewHolder.getAdapterPosition(); + final int position = adapterPosition - m_adapter.getHeaderCount(); try { final Article article = getArticleAtPosition(position); @@ -398,7 +399,8 @@ public class HeadlinesFragment extends Fragment { } m_articles.add(position, article); - m_adapter.notifyDataSetChanged(); + m_adapter.notifyItemInserted(adapterPosition); + m_adapter.notifyItemRangeChanged(adapterPosition, 1); } }).show();