X-Git-Url: https://git.ktnx.net/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fui%2Factivity%2FMainActivity.java;h=bbc8fa79428b42c9d29d2fbe3c1255d57eacf09a;hb=a26e0d3df1c20585c47a1513b1b11af3e4b79fcf;hp=199347a40eca617b80551e14c51030ddc22d21bc;hpb=d45f5704a4eb4acceb85d46a2ed23bd62623e10b;p=mobile-ledger-staging.git 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 199347a4..bbc8fa79 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 @@ -342,6 +342,14 @@ public class MainActivity extends ProfileThemedActivity { sm.setDynamicShortcuts(shortcuts); } private void onProfileListChanged(List newList) { + if (newList == null) { + // profiles not yet loaded from DB + findViewById(R.id.loading_layout).setVisibility(View.VISIBLE); + findViewById(R.id.no_profiles_layout).setVisibility(View.GONE); + findViewById(R.id.pager_layout).setVisibility(View.GONE); + return; + } + if (newList.isEmpty()) { findViewById(R.id.no_profiles_layout).setVisibility(View.VISIBLE); findViewById(R.id.pager_layout).setVisibility(View.GONE); @@ -361,7 +369,9 @@ public class MainActivity extends ProfileThemedActivity { createShortcuts(newList); } - /** called when the current profile has changed */ + /** + * called when the current profile has changed + */ private void onProfileChanged(MobileLedgerProfile profile) { boolean haveProfile = profile != null; findViewById(R.id.no_profiles_layout).setVisibility(haveProfile ? View.GONE : View.VISIBLE); @@ -464,7 +474,7 @@ public class MainActivity extends ProfileThemedActivity { startActivity(intent, args); } private void setupProfile() { - MLDB.getOption(MLDB.OPT_PROFILE_UUID, null, new GetOptCallback(){ + MLDB.getOption(MLDB.OPT_PROFILE_UUID, null, new GetOptCallback() { @Override protected void onResult(String profileUUID) { MobileLedgerProfile startupProfile; @@ -542,7 +552,9 @@ public class MainActivity extends ProfileThemedActivity { } } public void updateLastUpdateTextFromDB() { - long last_update = (profile != null) ? profile.getLongOption(MLDB.OPT_LAST_SCRAPE, 0L) : 0; + if (profile == null) return; + + long last_update = profile.getLongOption(MLDB.OPT_LAST_SCRAPE, 0L); debug("transactions", String.format(Locale.ENGLISH, "Last update = %d", last_update)); if (last_update == 0) {