From 44d4a132c193907ee53de180ad28e697828009e3 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Thu, 22 Oct 2026 11:19:32 +0200 Subject: Fix lifecycle, focus loss, crossfade and tab race review findings - MainActivity: remove rotate callbacks in onDestroy, ignore connect results once destroyed, rotate the background only while resumed, guard the fade end action. - HomeRows: each row owns one TileAdapter over a mutable list; rebinds refill it and notifyDataSetChanged instead of setAdapter, so focus and scroll survive a sample arriving (change payload keeps the holder). - Crossfade: flip front only on onResourceReady, cancel the animation before resetting alpha. - Tab loads ignore errors from a tab that is no longer shown; Home does not fire a second /folders request while one is in flight. - Load the instance logo after login in connect(). - FolderActivity: request grid focus after layout. Co-Authored-By: Claude Opus 5.5 --- app/src/main/java/mygram/droid/HomeRows.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'app/src/main/java/mygram/droid/HomeRows.java') diff --git a/app/src/main/java/mygram/droid/HomeRows.java b/app/src/main/java/mygram/droid/HomeRows.java index ed638b6..e4abeb5 100644 --- a/app/src/main/java/mygram/droid/HomeRows.java +++ b/app/src/main/java/mygram/droid/HomeRows.java @@ -37,11 +37,14 @@ final class HomeRows extends RecyclerView.Adapter { static final class Row extends RecyclerView.ViewHolder { final TextView title; final RecyclerView tiles; + /** Backing list of the row's one adapter: rebinds refill it instead of replacing the adapter. */ + final List list = new ArrayList<>(); Row(LinearLayout v, TextView title, RecyclerView tiles) { super(v); this.title = title; this.tiles = tiles; + tiles.setAdapter(new TileAdapter(list, Ui.POST_W, Ui.POST_H)); } } @@ -80,17 +83,18 @@ final class HomeRows extends RecyclerView.Adapter { samples.put(f.slug, posts); // marks it loading, so it is fetched once Api.async(() -> Api.folderSample(f, SAMPLE), p -> { samples.put(f.slug, p); - notifyItemChanged(folders.indexOf(f)); + notifyItemChanged(folders.indexOf(f), Boolean.TRUE); // payload: keep the holder, so focus stays }, e -> { // the row keeps only its Continue tile }); } - List tiles = new ArrayList<>(); + List tiles = row.list; + tiles.clear(); for (Post p : posts) tiles.add(TileAdapter.post(p, () -> open(f, p))); tiles.add(new TileAdapter.Tile(null, "Continue", R.drawable.ic_arrow_forward, -1, () -> FolderActivity.open(activity, f))); - row.tiles.setAdapter(new TileAdapter(tiles, Ui.POST_W, Ui.POST_H)); + row.tiles.getAdapter().notifyDataSetChanged(); } @Override -- cgit v1.2.3