NewTransAct: set global profile in initProfile() when called via app shortcut
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Sun, 10 Nov 2019 11:20:37 +0000 (13:20 +0200)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Sun, 10 Nov 2019 11:20:37 +0000 (13:20 +0200)
same is done in super.initProfile() during normal startup

the global profile setting is needed in the item holder when setting up
lookups

app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionActivity.java
app/src/main/java/net/ktnx/mobileledger/ui/activity/NewTransactionItemHolder.java

index cef9910..950bce3 100644 (file)
@@ -141,6 +141,7 @@ public class NewTransactionActivity extends ProfileThemedActivity implements Tas
         if (profileUUID != null) {
             mProfile = Data.getProfile(profileUUID);
             if (mProfile == null) finish();
+            Data.setCurrentProfile(mProfile);
         }
         else super.initProfile();
     }
index 2e4c0e6..031453c 100644 (file)
@@ -35,6 +35,7 @@ import androidx.recyclerview.widget.RecyclerView;
 
 import net.ktnx.mobileledger.R;
 import net.ktnx.mobileledger.async.DescriptionSelectedCallback;
+import net.ktnx.mobileledger.model.Data;
 import net.ktnx.mobileledger.model.LedgerTransactionAccount;
 import net.ktnx.mobileledger.model.MobileLedgerProfile;
 import net.ktnx.mobileledger.ui.DatePickerFragment;
@@ -84,6 +85,9 @@ class NewTransactionItemHolder extends RecyclerView.ViewHolder
         });
         tvDate.setOnClickListener(v -> pickTransactionDate());
 
+        mProfile = Data.profile.getValue();
+        if (mProfile == null) throw new AssertionError();
+
         MLDB.hookAutocompletionAdapter(tvDescription.getContext(), tvDescription,
                 MLDB.DESCRIPTION_HISTORY_TABLE, "description", false, adapter, mProfile);
         MLDB.hookAutocompletionAdapter(tvAccount.getContext(), tvAccount, MLDB.ACCOUNTS_TABLE,