diff options
Diffstat (limited to 'app/src/main/java/mygram/droid/ViewerActivity.java')
| -rw-r--r-- | app/src/main/java/mygram/droid/ViewerActivity.java | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/app/src/main/java/mygram/droid/ViewerActivity.java b/app/src/main/java/mygram/droid/ViewerActivity.java index 59e6948..4845cbd 100644 --- a/app/src/main/java/mygram/droid/ViewerActivity.java +++ b/app/src/main/java/mygram/droid/ViewerActivity.java @@ -131,7 +131,7 @@ public final class ViewerActivity extends Activity { if (!Playlist.posts.isEmpty()) { show(Playlist.start); - } else if (Playlist.reelsSeed != 0) { + } else if (Playlist.more != null) { message.setText("Loading…"); maybeLoadMore(); } else { @@ -330,35 +330,33 @@ public final class ViewerActivity extends Activity { }); } - /** Reels only: fetches the next page when three posts remain. */ + /** Fetches the next page when three posts remain. */ private void maybeLoadMore() { - if (Playlist.reelsSeed == 0 || loadingMore || index < Playlist.posts.size() - 3) + if (Playlist.more == null || loadingMore || index < Playlist.posts.size() - 3) return; loadingMore = true; - int page = Playlist.reelsPage + 1; List<Post> list = Playlist.posts; - Api.async(() -> Api.reels(Playlist.reelsSeed, page), o -> { + Api.async(Playlist.more, page -> { if (isDestroyed() || Playlist.posts != list) return; loadingMore = false; - Playlist.reelsPage = page; boolean first = list.isEmpty(); int old = list.size(); - list.addAll(Post.list(o, Prefs.server())); - if (!o.optBoolean("hasMore")) - Playlist.reelsSeed = 0; + if (page.isEmpty()) + Playlist.more = null; + Playlist.append(page); if (first && !list.isEmpty()) show(0); else if (parkedAtEnd && index == old - 1 && list.size() > old) show(index + 1); - else if (list.isEmpty() && Playlist.reelsSeed == 0) - message.setText("No reels"); + else if (list.isEmpty() && Playlist.more == null) + message.setText("Nothing to show"); }, e -> { if (isDestroyed()) return; loadingMore = false; if (Playlist.posts.isEmpty()) - message.setText("Cannot load reels. Press Down to retry."); + message.setText("Cannot load posts. Press Down to retry."); else Toast.makeText(this, "Cannot load more: " + e.getMessage(), Toast.LENGTH_SHORT).show(); }); |
