Commit dc9b31b4 authored by Thomas's avatar Thomas
Browse files

some changes

parent c89cabdc
Loading
Loading
Loading
Loading
+2 −9
Original line number Diff line number Diff line
@@ -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)
                                    );
                        });

+4 −2
Original line number Diff line number Diff line
@@ -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;