fix polls not updating when behind spoiler
closes sk22#892
This commit is contained in:
parent
3cf23474e3
commit
3e28eb2ccf
|
@ -468,10 +468,14 @@ public abstract class BaseStatusListFragment<T extends DisplayItemsParent> exten
|
||||||
protected void updatePoll(String itemID, Status status, Poll poll){
|
protected void updatePoll(String itemID, Status status, Poll poll){
|
||||||
status.poll=poll;
|
status.poll=poll;
|
||||||
int firstOptionIndex=-1, footerIndex=-1;
|
int firstOptionIndex=-1, footerIndex=-1;
|
||||||
|
int spoilerFirstOptionIndex=-1, spoilerFooterIndex=-1;
|
||||||
|
SpoilerStatusDisplayItem spoilerItem=null;
|
||||||
int i=0;
|
int i=0;
|
||||||
for(StatusDisplayItem item:displayItems){
|
for(StatusDisplayItem item:displayItems){
|
||||||
if(item.parentID.equals(itemID)){
|
if(item.parentID.equals(itemID)){
|
||||||
if(item instanceof PollOptionStatusDisplayItem && firstOptionIndex==-1){
|
if(item instanceof SpoilerStatusDisplayItem){
|
||||||
|
spoilerItem=(SpoilerStatusDisplayItem) item;
|
||||||
|
}else if(item instanceof PollOptionStatusDisplayItem && firstOptionIndex==-1){
|
||||||
firstOptionIndex=i;
|
firstOptionIndex=i;
|
||||||
}else if(item instanceof PollFooterStatusDisplayItem){
|
}else if(item instanceof PollFooterStatusDisplayItem){
|
||||||
footerIndex=i;
|
footerIndex=i;
|
||||||
|
@ -484,8 +488,16 @@ public abstract class BaseStatusListFragment<T extends DisplayItemsParent> exten
|
||||||
throw new IllegalStateException("Can't find all poll items in displayItems");
|
throw new IllegalStateException("Can't find all poll items in displayItems");
|
||||||
List<StatusDisplayItem> pollItems=displayItems.subList(firstOptionIndex, footerIndex+1);
|
List<StatusDisplayItem> pollItems=displayItems.subList(firstOptionIndex, footerIndex+1);
|
||||||
int prevSize=pollItems.size();
|
int prevSize=pollItems.size();
|
||||||
|
if(spoilerItem!=null){
|
||||||
|
spoilerFirstOptionIndex=spoilerItem.contentItems.indexOf(pollItems.get(0));
|
||||||
|
spoilerFooterIndex=spoilerItem.contentItems.indexOf(pollItems.get(pollItems.size()-1));
|
||||||
|
}
|
||||||
pollItems.clear();
|
pollItems.clear();
|
||||||
StatusDisplayItem.buildPollItems(itemID, this, poll, pollItems);
|
StatusDisplayItem.buildPollItems(itemID, this, poll, pollItems);
|
||||||
|
if(spoilerItem!=null){
|
||||||
|
spoilerItem.contentItems.subList(spoilerFirstOptionIndex, spoilerFooterIndex+1).clear();
|
||||||
|
spoilerItem.contentItems.addAll(spoilerFirstOptionIndex, pollItems);
|
||||||
|
}
|
||||||
if(prevSize!=pollItems.size()){
|
if(prevSize!=pollItems.size()){
|
||||||
adapter.notifyItemRangeRemoved(firstOptionIndex, prevSize);
|
adapter.notifyItemRangeRemoved(firstOptionIndex, prevSize);
|
||||||
adapter.notifyItemRangeInserted(firstOptionIndex, pollItems.size());
|
adapter.notifyItemRangeInserted(firstOptionIndex, pollItems.size());
|
||||||
|
|
Loading…
Reference in New Issue