From dc9b31b4ebe2540c5c0111bf730dd1653100bf92 Mon Sep 17 00:00:00 2001 From: Thomas Date: Fri, 3 Mar 2023 12:25:09 +0100 Subject: [PATCH] some changes --- .../java/app/fedilab/android/BaseMainActivity.java | 11 ++--------- .../mastodon/viewmodel/mastodon/TimelinesVM.java | 6 ++++-- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/app/fedilab/android/BaseMainActivity.java b/app/src/main/java/app/fedilab/android/BaseMainActivity.java index d13378fd..daa98015 100644 --- a/app/src/main/java/app/fedilab/android/BaseMainActivity.java +++ b/app/src/main/java/app/fedilab/android/BaseMainActivity.java @@ -243,9 +243,6 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt if (b != null) { if (b.getBoolean(Helper.RECEIVE_REDRAW_TOPBAR, false)) { List mastodonLists = (List) b.getSerializable(Helper.RECEIVE_MASTODON_LIST); - if (mastodonLists != null && mastodonLists.size() == 0) { - mastodonLists = null; - } redrawPinned(mastodonLists); } if (b.getBoolean(Helper.RECEIVE_REDRAW_BOTTOM, false)) { @@ -1227,12 +1224,8 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt PinnedTimelineHelper.redrawTopBarPinned(BaseMainActivity.this, binding, pinned, bottomMenu, null); //Fetch remote lists for the authenticated account and update them new ViewModelProvider(BaseMainActivity.this).get(TimelinesVM.class).getLists(currentInstance, currentToken) - .observe(this, mastodonLists -> { - if (mastodonLists != null && mastodonLists.size() == 0) { - mastodonLists = null; - } - PinnedTimelineHelper.redrawTopBarPinned(BaseMainActivity.this, binding, pinned, bottomMenu, mastodonLists); - } + .observe(this, mastodonLists -> + PinnedTimelineHelper.redrawTopBarPinned(BaseMainActivity.this, binding, pinned, bottomMenu, mastodonLists) ); }); diff --git a/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/TimelinesVM.java b/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/TimelinesVM.java index 3d4b9a58..e33dd530 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/TimelinesVM.java +++ b/app/src/main/java/app/fedilab/android/mastodon/viewmodel/mastodon/TimelinesVM.java @@ -679,13 +679,14 @@ public class TimelinesVM extends AndroidViewModel { public LiveData> getLists(@NonNull String instance, String token) { mastodonListListMutableLiveData = new MutableLiveData<>(); MastodonTimelinesService mastodonTimelinesService = init(instance); - List mastodonListList = new ArrayList<>(); new Thread(() -> { + List mastodonListList = null; Call> getListsCall = mastodonTimelinesService.getLists(token); if (getListsCall != null) { try { Response> getListsResponse = getListsCall.execute(); if (getListsResponse.isSuccessful()) { + mastodonListList = new ArrayList<>(); List mastodonLists = getListsResponse.body(); if (mastodonLists != null) { mastodonListList.addAll(mastodonLists); @@ -696,7 +697,8 @@ public class TimelinesVM extends AndroidViewModel { } } Handler mainHandler = new Handler(Looper.getMainLooper()); - Runnable myRunnable = () -> mastodonListListMutableLiveData.setValue(mastodonListList); + List finalMastodonListList = mastodonListList; + Runnable myRunnable = () -> mastodonListListMutableLiveData.setValue(finalMastodonListList); mainHandler.post(myRunnable); }).start(); return mastodonListListMutableLiveData;