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,6 +110,7 @@ public abstract class BaseStatusListFragment<T extends DisplayItemsParent> exten
|
|||
displayItems.addAll(offset, toAdd);
|
||||
offset+=toAdd.size();
|
||||
}
|
||||
if(notify)
|
||||
adapter.notifyItemRangeInserted(0, offset);
|
||||
}
|
||||
|
||||
|
|
|
@ -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