Fix issue #919 - Long press on the fetch more button to retrieve all missing toots
This commit is contained in:
parent
f5dbfe2517
commit
c3847398df
|
@ -182,7 +182,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
private boolean redraft;
|
||||
private Status toot;
|
||||
private TagTimeline tagTimeline;
|
||||
|
||||
public static boolean fetch_all_more = false;
|
||||
public StatusListAdapter(Context context, RetrieveFeedsAsyncTask.Type type, String targetedId, boolean isOnWifi, List<Status> statuses){
|
||||
super();
|
||||
this.context = context;
|
||||
|
@ -220,6 +220,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
redraft = false;
|
||||
}
|
||||
|
||||
|
||||
public void updateMuted(List<String> timedMute){
|
||||
this.timedMute = timedMute;
|
||||
}
|
||||
|
@ -1340,6 +1341,31 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
|
|||
}
|
||||
}
|
||||
});
|
||||
holder.fetch_more.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
status.setFetchMore(false);
|
||||
holder.fetch_more.setEnabled(false);
|
||||
holder.fetch_more.setVisibility(View.GONE);
|
||||
if( context instanceof BaseMainActivity) {
|
||||
SQLiteDatabase db = Sqlite.getInstance(context, DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
List<ManageTimelines> timelines = new TimelinesDAO(context, db).getDisplayedTimelines();
|
||||
for(ManageTimelines tl: timelines) {
|
||||
if( tl.getType() == ManageTimelines.Type.HOME) {
|
||||
DisplayStatusFragment homeFragment = (DisplayStatusFragment) mPageReferenceMap.get(tl.getPosition());
|
||||
if (homeFragment != null) {
|
||||
fetch_all_more = true;
|
||||
homeFragment.fetchMore(status.getId());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
Toasty.error(context, context.getString(R.string.toast_error), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
holder.fetch_more.setVisibility(View.GONE);
|
||||
|
||||
|
|
|
@ -975,9 +975,16 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
|
|||
//Display the fetch more toot button
|
||||
if( tmpStatuses.size() >= tootPerPage) {
|
||||
if (initialBookMarkDate != null && !fetchMoreButtonDisplayed && tmpStatuses.size() > 0 && tmpStatuses.get(tmpStatuses.size() - 1).getCreated_at().after(initialBookMarkDate)) {
|
||||
tmpStatuses.get(tmpStatuses.size() - 1).setFetchMore(true);
|
||||
fetchMoreButtonDisplayed = true;
|
||||
if( StatusListAdapter.fetch_all_more && statuses.size() > 0){
|
||||
fetchMore(tmpStatuses.get(tmpStatuses.size() - 1).getId());
|
||||
}else{
|
||||
fetchMoreButtonDisplayed = true;
|
||||
tmpStatuses.get(tmpStatuses.size() - 1).setFetchMore(true);
|
||||
StatusListAdapter.fetch_all_more = false;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
StatusListAdapter.fetch_all_more = false;
|
||||
}
|
||||
this.statuses.addAll(position, tmpStatuses);
|
||||
boolean display_content_after_fetch_more = sharedpreferences.getBoolean(Helper.SET_DISPLAY_CONTENT_AFTER_FM, true);
|
||||
|
|
Loading…
Reference in New Issue