From d28e54c3e91f3a65e8b4571dc94fe90e953d4c7a Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Fri, 29 Mar 2019 13:45:44 +0200 Subject: [PATCH] notify profile list adapter when the currently selected profile changes this seems to work when the profiles use a different theme because in this case the activity is restarted (and adapter re-initializes) but when the changed profiles use the same theme the change was not reflected in the profile list --- .../mobileledger/ui/activity/MainActivity.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java b/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java index 86463aac..f61ebb0e 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java @@ -169,6 +169,20 @@ public class MainActivity extends ProfileThemedActivity { fab.hide(); } + int old_index = -1; + int new_index = -1; + if (arg != null) { + MobileLedgerProfile old = (MobileLedgerProfile) arg; + old_index = Data.getProfileIndex(old); + new_index = Data.getProfileIndex(profile); + } + + if ((old_index != -1) && (new_index != -1)) { + mProfileListAdapter.notifyItemChanged(old_index); + mProfileListAdapter.notifyItemChanged(new_index); + } + else mProfileListAdapter.notifyDataSetChanged(); + int newProfileTheme = profile.getThemeId(); if (newProfileTheme != Colors.profileThemeId) { Log.d("profiles", String.format("profile theme %d → %d", Colors.profileThemeId, -- 2.39.2