From b38eb3bb093ac2290009ab6482f2000e8fd296c1 Mon Sep 17 00:00:00 2001 From: Thomas Date: Sun, 20 Nov 2022 16:30:13 +0100 Subject: [PATCH] Fix some color issues --- .../activities/StatusInfoActivity.java | 25 +++++++++++++++++++ .../android/ui/drawer/AccountAdapter.java | 11 ++++---- .../timeline/FragmentMastodonTimeline.java | 2 ++ 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/app/fedilab/android/activities/StatusInfoActivity.java b/app/src/main/java/app/fedilab/android/activities/StatusInfoActivity.java index 45003cde..29f3b2dc 100644 --- a/app/src/main/java/app/fedilab/android/activities/StatusInfoActivity.java +++ b/app/src/main/java/app/fedilab/android/activities/StatusInfoActivity.java @@ -33,11 +33,13 @@ import app.fedilab.android.BaseMainActivity; import app.fedilab.android.R; import app.fedilab.android.client.entities.api.Account; import app.fedilab.android.client.entities.api.Accounts; +import app.fedilab.android.client.entities.api.RelationShip; import app.fedilab.android.client.entities.api.Status; import app.fedilab.android.databinding.ActivityStatusInfoBinding; import app.fedilab.android.helper.Helper; import app.fedilab.android.helper.ThemeHelper; import app.fedilab.android.ui.drawer.AccountAdapter; +import app.fedilab.android.viewmodel.mastodon.AccountsVM; import app.fedilab.android.viewmodel.mastodon.StatusesVM; @@ -115,6 +117,8 @@ public class StatusInfoActivity extends BaseActivity { private void manageView(Accounts accounts) { binding.loadingNextAccounts.setVisibility(View.GONE); if (accountList != null && accounts != null && accounts.accounts != null) { + int position = this.accountList.size(); + fetchRelationShip(accounts.accounts, position); int startId = 0; //There are some statuses present in the timeline if (accountList.size() > 0) { @@ -127,6 +131,27 @@ public class StatusInfoActivity extends BaseActivity { } } + private void fetchRelationShip(List accounts, int position) { + List ids = new ArrayList<>(); + for (Account account : accounts) { + ids.add(account.id); + } + AccountsVM accountsVM = new ViewModelProvider(StatusInfoActivity.this).get(AccountsVM.class); + accountsVM.getRelationships(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, ids) + .observe(StatusInfoActivity.this, relationShips -> { + if (relationShips != null) { + for (RelationShip relationShip : relationShips) { + for (Account account : accounts) { + if (account.id.compareToIgnoreCase(relationShip.id) == 0) { + account.relationShip = relationShip; + } + } + } + accountAdapter.notifyItemRangeChanged(position, accounts.size()); + } + }); + } + @Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == android.R.id.home) { diff --git a/app/src/main/java/app/fedilab/android/ui/drawer/AccountAdapter.java b/app/src/main/java/app/fedilab/android/ui/drawer/AccountAdapter.java index 4cab5fa8..a7cdcf67 100644 --- a/app/src/main/java/app/fedilab/android/ui/drawer/AccountAdapter.java +++ b/app/src/main/java/app/fedilab/android/ui/drawer/AccountAdapter.java @@ -79,7 +79,12 @@ public class AccountAdapter extends RecyclerView.Adapter 0) { route(DIRECTION.FETCH_NEW, true);