]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/ui/profiles/ProfilesRecyclerViewAdapter.java
asynchronous profile initialisation
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / ui / profiles / ProfilesRecyclerViewAdapter.java
index 34b9064a8f4a34023f4810c24dde2fc5a48519d4..e7346b1b0487a4d4d09fea3ee474047f43592efa 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2020 Damyan Ivanov.
+ * Copyright © 2021 Damyan Ivanov.
  * This file is part of MoLe.
  * MoLe is free software: you can distribute it and/or modify it
  * under the term of the GNU General Public License as published by
@@ -39,7 +39,7 @@ import androidx.recyclerview.widget.RecyclerView;
 import net.ktnx.mobileledger.R;
 import net.ktnx.mobileledger.model.Data;
 import net.ktnx.mobileledger.model.MobileLedgerProfile;
-import net.ktnx.mobileledger.ui.activity.ProfileDetailActivity;
+import net.ktnx.mobileledger.ui.activity.MainActivity;
 import net.ktnx.mobileledger.utils.Colors;
 
 import java.lang.ref.WeakReference;
@@ -51,13 +51,13 @@ import static net.ktnx.mobileledger.utils.Logger.debug;
 public class ProfilesRecyclerViewAdapter
         extends RecyclerView.Adapter<ProfilesRecyclerViewAdapter.ProfileListViewHolder> {
     private static WeakReference<ProfilesRecyclerViewAdapter> instanceRef;
+    public final MutableLiveData<Boolean> editingProfiles = new MutableLiveData<>(false);
     private final View.OnClickListener mOnClickListener = view -> {
         MobileLedgerProfile profile = (MobileLedgerProfile) ((View) view.getParent()).getTag();
         editProfile(view, profile);
     };
-    public final MutableLiveData<Boolean> editingProfiles = new MutableLiveData<>(false);
+    private final ItemTouchHelper rearrangeHelper;
     private RecyclerView recyclerView;
-    private ItemTouchHelper rearrangeHelper;
     private boolean animationsEnabled = true;
     public ProfilesRecyclerViewAdapter() {
         instanceRef = new WeakReference<>(this);
@@ -149,8 +149,10 @@ public class ProfilesRecyclerViewAdapter
         if (profile == null)
             throw new IllegalStateException("Profile row without associated profile");
         debug("profiles", "Setting profile to " + profile.getName());
-        if (Data.getProfile() != profile)
+        if (Data.getProfile() != profile) {
             Data.drawerOpen.setValue(false);
+            ((MainActivity) v.getContext()).storeProfilePref(profile);
+        }
         Data.setCurrentProfile(profile);
     }
     @NonNull