Fix conversation refresh

This commit is contained in:
stom79 2018-11-23 19:34:44 +01:00
parent 0b7491c40a
commit 6bd495ea10
1 changed files with 8 additions and 7 deletions

View File

@ -227,12 +227,14 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override @Override
public void onRefresh() { public void onRefresh() {
if( statuses.size() > 0) {
if( type == RetrieveFeedsAsyncTask.Type.HOME) if( type == RetrieveFeedsAsyncTask.Type.HOME)
MainActivity.countNewStatus = 0; MainActivity.countNewStatus = 0;
isSwipped = true; isSwipped = true;
if( type != RetrieveFeedsAsyncTask.Type.CONVERSATION)
retrieveMissingToots(null); retrieveMissingToots(null);
} else if( statuses.size() > 0)
retrieveMissingToots(statuses.get(0).getId());
} }
}); });
else else
@ -721,6 +723,7 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
int insertedConversation = 0; int insertedConversation = 0;
if(type == RetrieveFeedsAsyncTask.Type.CONVERSATION){ //Remove conversation already displayed if new messages if(type == RetrieveFeedsAsyncTask.Type.CONVERSATION){ //Remove conversation already displayed if new messages
int position = 0; int position = 0;
insertedConversation = statuses.size();
if( this.statuses != null) { if( this.statuses != null) {
long initialConversationId = -1; long initialConversationId = -1;
if( this.statuses.size() > 0 ) if( this.statuses.size() > 0 )
@ -728,8 +731,6 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
for (Iterator<Status> it = this.statuses.iterator(); it.hasNext(); ) { for (Iterator<Status> it = this.statuses.iterator(); it.hasNext(); ) {
Status status = it.next(); Status status = it.next();
for (Status status1 : statuses) { for (Status status1 : statuses) {
if(initialConversationId > 0 && Long.parseLong(status1.getConversationId()) > initialConversationId)
insertedConversation++;
if (status.getConversationId() != null && status.getConversationId().equals(status1.getConversationId())) { if (status.getConversationId() != null && status.getConversationId().equals(status1.getConversationId())) {
statusListAdapter.notifyItemRemoved(position); statusListAdapter.notifyItemRemoved(position);
it.remove(); it.remove();