X-Git-Url: https://git.ktnx.net/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fui%2Factivity%2FProfileThemedActivity.java;h=05c534676c98c4f0d93d48be3f66c5e989c6e643;hb=26d468af81df6e4a9cee7a2fb256603c45344cac;hp=4aa60241dd3bab3fda24b661d901f793f7b9763a;hpb=fac0809065787fb473646db5770f4f2fae0d1e8f;p=mobile-ledger.git diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/activity/ProfileThemedActivity.java b/app/src/main/java/net/ktnx/mobileledger/ui/activity/ProfileThemedActivity.java index 4aa60241..05c53467 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/activity/ProfileThemedActivity.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/activity/ProfileThemedActivity.java @@ -18,17 +18,16 @@ package net.ktnx.mobileledger.ui.activity; import android.annotation.SuppressLint; -import android.os.AsyncTask; import android.os.Bundle; import androidx.annotation.Nullable; import net.ktnx.mobileledger.App; +import net.ktnx.mobileledger.dao.BaseDAO; import net.ktnx.mobileledger.dao.ProfileDAO; import net.ktnx.mobileledger.db.DB; import net.ktnx.mobileledger.db.Profile; import net.ktnx.mobileledger.model.Data; -import net.ktnx.mobileledger.model.MobileLedgerProfile; import net.ktnx.mobileledger.utils.Colors; import net.ktnx.mobileledger.utils.Logger; @@ -39,7 +38,7 @@ public class ProfileThemedActivity extends CrashReportingActivity { public static final String TAG = "prf-thm-act"; protected static final String PARAM_PROFILE_ID = "profile-id"; protected static final String PARAM_THEME = "theme"; - protected MobileLedgerProfile mProfile; + protected Profile mProfile; private boolean themeSetUp = false; private boolean mIgnoreProfileChange; private int mThemeHue; @@ -76,12 +75,11 @@ public class ProfileThemedActivity extends CrashReportingActivity { Data.observeProfile(this, profile -> { if (profile == null) { Logger.debug(TAG, "No current profile, leaving"); - finish(); return; } mProfile = profile; - int hue = profile.getThemeHue(); + int hue = profile.getTheme(); if (hue != mThemeHue) { storeProfilePref(profile); @@ -91,8 +89,8 @@ public class ProfileThemedActivity extends CrashReportingActivity { super.onCreate(savedInstanceState); } - public void storeProfilePref(MobileLedgerProfile profile) { - App.storeStartupProfileAndTheme(profile.getId(), profile.getThemeHue()); + public void storeProfilePref(Profile profile) { + App.storeStartupProfileAndTheme(profile.getId(), profile.getTheme()); } protected void initProfile() { long profileId = App.getStartupProfile(); @@ -105,9 +103,9 @@ public class ProfileThemedActivity extends CrashReportingActivity { initProfile(profileId); } protected void initProfile(long profileId) { - AsyncTask.execute(() -> initProfileAsync(profileId)); + BaseDAO.runAsync(() -> initProfileSync(profileId)); } - private void initProfileAsync(long profileId) { + private void initProfileSync(long profileId) { ProfileDAO dao = DB.get() .getProfileDAO(); Profile profile = dao.getByIdSync(profileId); @@ -119,6 +117,10 @@ public class ProfileThemedActivity extends CrashReportingActivity { profile = dao.getAnySync(); } - Data.postCurrentProfile(MobileLedgerProfile.fromDBO(profile)); + if (profile == null) + Logger.debug(TAG, "No profile could be loaded"); + else + Logger.debug(TAG, String.format(Locale.ROOT, "Profile %d loaded. posting", profileId)); + Data.postCurrentProfile(profile); } }