some changes

This commit is contained in:
Thomas 2023-03-03 12:25:09 +01:00
parent c89cabdcb4
commit dc9b31b4eb
2 changed files with 6 additions and 11 deletions

View file

@ -243,9 +243,6 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
if (b != null) {
if (b.getBoolean(Helper.RECEIVE_REDRAW_TOPBAR, false)) {
List<MastodonList> mastodonLists = (List<MastodonList>) 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)
);
});

View file

@ -679,13 +679,14 @@ public class TimelinesVM extends AndroidViewModel {
public LiveData<List<MastodonList>> getLists(@NonNull String instance, String token) {
mastodonListListMutableLiveData = new MutableLiveData<>();
MastodonTimelinesService mastodonTimelinesService = init(instance);
List<MastodonList> mastodonListList = new ArrayList<>();
new Thread(() -> {
List<MastodonList> mastodonListList = null;
Call<List<MastodonList>> getListsCall = mastodonTimelinesService.getLists(token);
if (getListsCall != null) {
try {
Response<List<MastodonList>> getListsResponse = getListsCall.execute();
if (getListsResponse.isSuccessful()) {
mastodonListList = new ArrayList<>();
List<MastodonList> 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<MastodonList> finalMastodonListList = mastodonListList;
Runnable myRunnable = () -> mastodonListListMutableLiveData.setValue(finalMastodonListList);
mainHandler.post(myRunnable);
}).start();
return mastodonListListMutableLiveData;