diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java index f95ba5fa..5e3a12b4 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/BaseStatusListFragment.java @@ -99,7 +99,7 @@ public abstract class BaseStatusListFragment exten displayItems.clear(); } - protected void prependItems(List items){ + protected void prependItems(List items, boolean notify){ data.addAll(0, items); int offset=0; for(T s:items){ @@ -110,7 +110,8 @@ public abstract class BaseStatusListFragment exten displayItems.addAll(offset, toAdd); offset+=toAdd.size(); } - adapter.notifyItemRangeInserted(0, offset); + if(notify) + adapter.notifyItemRangeInserted(0, offset); } protected String getMaxID(){ diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeTimelineFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeTimelineFragment.java index 8ae782e2..76c87ce1 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeTimelineFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeTimelineFragment.java @@ -90,7 +90,7 @@ public class HomeTimelineFragment extends StatusListFragment{ @Subscribe public void onStatusCreated(StatusCreatedEvent ev){ - prependItems(Collections.singletonList(ev.status)); + prependItems(Collections.singletonList(ev.status), true); } private void onFabClick(View v){ diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/ThreadFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/ThreadFragment.java index 8dc5ef0f..2e575e88 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ThreadFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ThreadFragment.java @@ -47,12 +47,17 @@ public class ThreadFragment extends StatusListFragment{ } footerProgress.setVisibility(View.GONE); data.addAll(result.descendants); + int prevCount=displayItems.size(); onAppendItems(result.descendants); int count=displayItems.size(); - prependItems(result.ancestors); + if(!refreshing) + adapter.notifyItemRangeInserted(prevCount, count-prevCount); + prependItems(result.ancestors, !refreshing); dataLoaded(); - if(refreshing) + if(refreshing){ refreshDone(); + adapter.notifyDataSetChanged(); + } list.scrollToPosition(displayItems.size()-count); } })