mirror of
https://github.com/mastodon/mastodon-android.git
synced 2024-12-23 07:26:46 +01:00
Crash fix
This commit is contained in:
parent
8b8dc4fbf9
commit
371faf9bb2
@ -99,7 +99,7 @@ public abstract class BaseStatusListFragment<T extends DisplayItemsParent> exten
|
||||
displayItems.clear();
|
||||
}
|
||||
|
||||
protected void prependItems(List<T> items){
|
||||
protected void prependItems(List<T> items, boolean notify){
|
||||
data.addAll(0, items);
|
||||
int offset=0;
|
||||
for(T s:items){
|
||||
@ -110,7 +110,8 @@ public abstract class BaseStatusListFragment<T extends DisplayItemsParent> exten
|
||||
displayItems.addAll(offset, toAdd);
|
||||
offset+=toAdd.size();
|
||||
}
|
||||
adapter.notifyItemRangeInserted(0, offset);
|
||||
if(notify)
|
||||
adapter.notifyItemRangeInserted(0, offset);
|
||||
}
|
||||
|
||||
protected String getMaxID(){
|
||||
|
@ -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){
|
||||
|
@ -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);
|
||||
}
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user