Fix issue #525 - scroll to bottom after fetching new toots

This commit is contained in:
stom79 2018-10-25 14:58:29 +02:00
parent 8e8394709c
commit 6f602b89dd
1 changed files with 11 additions and 3 deletions

View File

@ -94,7 +94,7 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
private List<String> mutedAccount; private List<String> mutedAccount;
private String instanceType; private String instanceType;
private String search_peertube, remote_channel_name; private String search_peertube, remote_channel_name;
private boolean isFetchingMore;
public DisplayStatusFragment(){ public DisplayStatusFragment(){
} }
@ -112,6 +112,7 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
firstTootsLoaded = true; firstTootsLoaded = true;
showPinned = false; showPinned = false;
showReply = false; showReply = false;
isFetchingMore = false;
if (bundle != null) { if (bundle != null) {
type = (RetrieveFeedsAsyncTask.Type) bundle.get("type"); type = (RetrieveFeedsAsyncTask.Type) bundle.get("type");
targetedId = bundle.getString("targetedId", null); targetedId = bundle.getString("targetedId", null);
@ -444,8 +445,13 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
statusListAdapter.notifyItemRangeInserted(position, tmpStatuses.size()); statusListAdapter.notifyItemRangeInserted(position, tmpStatuses.size());
if( tmpStatuses.size() < 3) //If new toots are only two if( tmpStatuses.size() < 3) //If new toots are only two
lv_status.scrollToPosition(0); lv_status.scrollToPosition(0);
else else {
lv_status.scrollToPosition(position+tmpStatuses.size()); if(isFetchingMore)
lv_status.scrollToPosition(position);
else
lv_status.scrollToPosition(position + tmpStatuses.size());
isFetchingMore = false;
}
} }
}else { }else {
@ -468,6 +474,7 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
} }
swipeRefreshLayout.setRefreshing(false); swipeRefreshLayout.setRefreshing(false);
firstLoad = false; firstLoad = false;
isFetchingMore = false;
} }
} }
@ -705,6 +712,7 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
} }
public void fetchMore(String max_id){ public void fetchMore(String max_id){
isFetchingMore = true;
asyncTask = new RetrieveFeedsAsyncTask(context, type, max_id, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); asyncTask = new RetrieveFeedsAsyncTask(context, type, max_id, DisplayStatusFragment.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} }