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();
|
displayItems.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void prependItems(List<T> items){
|
protected void prependItems(List<T> items, boolean notify){
|
||||||
data.addAll(0, items);
|
data.addAll(0, items);
|
||||||
int offset=0;
|
int offset=0;
|
||||||
for(T s:items){
|
for(T s:items){
|
||||||
|
@ -110,7 +110,8 @@ public abstract class BaseStatusListFragment<T extends DisplayItemsParent> exten
|
||||||
displayItems.addAll(offset, toAdd);
|
displayItems.addAll(offset, toAdd);
|
||||||
offset+=toAdd.size();
|
offset+=toAdd.size();
|
||||||
}
|
}
|
||||||
adapter.notifyItemRangeInserted(0, offset);
|
if(notify)
|
||||||
|
adapter.notifyItemRangeInserted(0, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getMaxID(){
|
protected String getMaxID(){
|
||||||
|
|
|
@ -90,7 +90,7 @@ public class HomeTimelineFragment extends StatusListFragment{
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusCreated(StatusCreatedEvent ev){
|
public void onStatusCreated(StatusCreatedEvent ev){
|
||||||
prependItems(Collections.singletonList(ev.status));
|
prependItems(Collections.singletonList(ev.status), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onFabClick(View v){
|
private void onFabClick(View v){
|
||||||
|
|
|
@ -47,12 +47,17 @@ public class ThreadFragment extends StatusListFragment{
|
||||||
}
|
}
|
||||||
footerProgress.setVisibility(View.GONE);
|
footerProgress.setVisibility(View.GONE);
|
||||||
data.addAll(result.descendants);
|
data.addAll(result.descendants);
|
||||||
|
int prevCount=displayItems.size();
|
||||||
onAppendItems(result.descendants);
|
onAppendItems(result.descendants);
|
||||||
int count=displayItems.size();
|
int count=displayItems.size();
|
||||||
prependItems(result.ancestors);
|
if(!refreshing)
|
||||||
|
adapter.notifyItemRangeInserted(prevCount, count-prevCount);
|
||||||
|
prependItems(result.ancestors, !refreshing);
|
||||||
dataLoaded();
|
dataLoaded();
|
||||||
if(refreshing)
|
if(refreshing){
|
||||||
refreshDone();
|
refreshDone();
|
||||||
|
adapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
list.scrollToPosition(displayItems.size()-count);
|
list.scrollToPosition(displayItems.size()-count);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue