From a6d580568320ecff5b28321abfc95a20527f1be2 Mon Sep 17 00:00:00 2001 From: Floens Date: Fri, 19 Jan 2018 16:56:29 +0100 Subject: [PATCH] state: fix restoring when the loadables werent actually deserialized --- .../floens/chan/ui/activity/StartActivity.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Clover/app/src/main/java/org/floens/chan/ui/activity/StartActivity.java b/Clover/app/src/main/java/org/floens/chan/ui/activity/StartActivity.java index ab5c8353..cf0fe6df 100644 --- a/Clover/app/src/main/java/org/floens/chan/ui/activity/StartActivity.java +++ b/Clover/app/src/main/java/org/floens/chan/ui/activity/StartActivity.java @@ -232,10 +232,19 @@ public class StartActivity extends AppCompatActivity implements NfcAdapter.Creat state.thread.site = site; state.thread.board = board; - Loadable boardLoadable = loadableManager.get(state.board); - Loadable threadLoadable = loadableManager.get(state.thread); + // When restarting the parcelable isn't actually deserialized, but the same object + // instance is reused. This means that the loadables we gave to the state are + // the same instance, and also have the id set etc. We don't need to query + // these from the loadablemanager. + Loadable threadLoadable; + if (state.thread.id == 0) { + threadLoadable = loadableManager.get(state.thread); + } else { + threadLoadable = state.thread; + } - return new Pair<>(boardLoadable, threadLoadable.mode == Loadable.Mode.THREAD ? threadLoadable : null); + return new Pair<>(state.board, + threadLoadable.mode == Loadable.Mode.THREAD ? threadLoadable : null); } }