diff options
author | tom79 <tschneider.ac@gmail.com> | 2019-05-05 16:53:35 +0200 |
---|---|---|
committer | tom79 <tschneider.ac@gmail.com> | 2019-05-05 16:53:35 +0200 |
commit | c3847398dfc72af81a635e9fe1b4e99a17b80d5e (patch) | |
tree | 542fdf49e04f57181d3091ee8434694127826866 /app | |
parent | f5dbfe2517a7ec53c23e788d9bd92ff1c1a02b33 (diff) |
Fix issue #919 - Long press on the fetch more button to retrieve all missing toots
Diffstat (limited to 'app')
-rw-r--r-- | app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java | 28 | ||||
-rw-r--r-- | app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayStatusFragment.java | 11 |
2 files changed, 36 insertions, 3 deletions
diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java index 91c6390eb..044cb0657 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java @@ -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); diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayStatusFragment.java b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayStatusFragment.java index 81327af0a..f6f70b448 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayStatusFragment.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/DisplayStatusFragment.java @@ -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); |