]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionActivity.java
asynchronous profile initialisation
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / ui / new_transaction / NewTransactionActivity.java
index ce97d985d9dc8eb5593b29a5eaa46993e4bd6ed5..11d014d369bd983144220d76a6267846a92e6d9e 100644 (file)
@@ -72,6 +72,7 @@ public class NewTransactionActivity extends ProfileThemedActivity
         implements TaskCallback, NewTransactionFragment.OnNewTransactionFragmentInteractionListener,
         QR.QRScanTrigger, QR.QRScanResultReceiver, DescriptionSelectedCallback,
         FabManager.FabHandler {
+    final String TAG = "new-t-a";
     private NavController navController;
     private NewTransactionModel model;
     private ActivityResultLauncher<Void> qrScanLauncher;
@@ -115,16 +116,23 @@ public class NewTransactionActivity extends ProfileThemedActivity
     }
     @Override
     protected void initProfile() {
-        String profileUUID = getIntent().getStringExtra("profile_uuid");
+        long profileId = getIntent().getLongExtra(PARAM_PROFILE_ID, 0);
+        int profileHue = getIntent().getIntExtra(PARAM_THEME, -1);
 
-        if (profileUUID != null) {
-            mProfile = Data.getProfile(profileUUID);
-            if (mProfile == null)
-                finish();
-            Data.setCurrentProfile(mProfile);
+        if (profileHue < 0) {
+            Logger.debug(TAG, "Started with invalid/missing theme; quitting");
+            finish();
+            return;
         }
-        else
-            super.initProfile();
+
+        if (profileId <= 0) {
+            Logger.debug(TAG, "Started with invalid/missing profile_id; quitting");
+            finish();
+            return;
+        }
+
+        setupProfileColors(profileHue);
+        initProfile(profileId);
     }
     @Override
     public void finish() {
@@ -378,9 +386,9 @@ public class NewTransactionActivity extends ProfileThemedActivity
             }
             @Override
             public boolean onRow(@NonNull Cursor cursor) {
-                final String profileUUID = cursor.getString(0);
+                final long profileId = cursor.getLong(0);
                 final int transactionId = cursor.getInt(1);
-                runOnUiThread(() -> model.loadTransactionIntoModel(profileUUID, transactionId));
+                runOnUiThread(() -> model.loadTransactionIntoModel(profileId, transactionId));
                 return false; // limit 1, by the way
             }
             @Override
@@ -409,9 +417,9 @@ public class NewTransactionActivity extends ProfileThemedActivity
                             }
                             @Override
                             public boolean onRow(@NonNull Cursor cursor) {
-                                final String profileUUID = cursor.getString(0);
+                                final long profileId = cursor.getLong(0);
                                 final int transactionId = cursor.getInt(1);
-                                runOnUiThread(() -> model.loadTransactionIntoModel(profileUUID,
+                                runOnUiThread(() -> model.loadTransactionIntoModel(profileId,
                                         transactionId));
                                 return false;
                             }