X-Git-Url: https://git.ktnx.net/?p=mobile-ledger.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fui%2Factivity%2FMainActivity.java;h=fbb99989ebd6de9b91c3528d3388ad5a15e51497;hp=20460186e3cf90e787a20c7cb96d4f44d107e8bf;hb=e809f9bacb61890374d1b9c8c46edeaed8a838b0;hpb=bde37d0aa472d31606b53491240c79af3374f09b 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 20460186..fbb99989 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 @@ -37,6 +37,7 @@ import android.view.View; import android.widget.LinearLayout; import android.widget.ProgressBar; import android.widget.TextView; +import android.widget.Toast; import net.ktnx.mobileledger.R; import net.ktnx.mobileledger.async.RefreshDescriptionsTask; @@ -109,7 +110,7 @@ public class MainActivity extends AppCompatActivity { drawer.addDrawerListener(toggle); toggle.syncState(); - android.widget.TextView ver = drawer.findViewById(R.id.drawer_version_text); + TextView ver = drawer.findViewById(R.id.drawer_version_text); try { PackageInfo pi = @@ -169,10 +170,9 @@ public class MainActivity extends AppCompatActivity { }); } private void setupProfile() { - Data.profiles.setList(MobileLedgerProfile.loadAllFromDB()); - MobileLedgerProfile profile = null; - String profileUUID = MLDB.getOption(MLDB.OPT_PROFILE_UUID, null); + MobileLedgerProfile profile; + if (profileUUID == null) { if (Data.profiles.isEmpty()) { Data.profiles.setList(MobileLedgerProfile.createInitialProfileList()); @@ -195,9 +195,10 @@ public class MainActivity extends AppCompatActivity { editor.clear(); editor.apply(); } + else profile = Data.profiles.get(0); } else { - profile = MobileLedgerProfile.loadUUIDFromDB(profileUUID); + profile = MobileLedgerProfile.loadAllFromDB(profileUUID); } if (profile == null) profile = Data.profiles.get(0); @@ -220,12 +221,6 @@ public class MainActivity extends AppCompatActivity { startActivity(intent); overridePendingTransition(R.anim.slide_in_right, R.anim.dummy); } - - public void navExitClicked(View view) { - Log.w("app", "exiting"); - finish(); - } - public void navSettingsClicked(View view) { Intent intent = new Intent(this, SettingsActivity.class); startActivity(intent); @@ -234,10 +229,10 @@ public class MainActivity extends AppCompatActivity { public void markDrawerItemCurrent(int id) { TextView item = drawer.findViewById(id); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - item.setBackgroundColor(getResources().getColor(R.color.table_row_even_bg, getTheme())); + item.setBackgroundColor(getResources().getColor(R.color.table_row_dark_bg, getTheme())); } else { - item.setBackgroundColor(getResources().getColor(R.color.table_row_even_bg)); + item.setBackgroundColor(getResources().getColor(R.color.table_row_dark_bg)); } @ColorInt int transparent = getResources().getColor(android.R.color.transparent); @@ -311,7 +306,7 @@ public class MainActivity extends AppCompatActivity { } public void updateLastUpdateTextFromDB() { { - long last_update = Data.profile.get().get_option_value(MLDB.OPT_LAST_SCRAPE, 0L); + long last_update = Data.profile.get().getLongOption(MLDB.OPT_LAST_SCRAPE, 0L); Log.d("transactions", String.format("Last update = %d", last_update)); if (last_update == 0) { @@ -333,11 +328,15 @@ public class MainActivity extends AppCompatActivity { if (retrieveTransactionsTask != null) retrieveTransactionsTask.cancel(false); bTransactionListCancelDownload.setEnabled(false); } - public void onRetrieveDone(boolean success) { + public void onRetrieveDone(String error) { progressLayout.setVisibility(View.GONE); - updateLastUpdateTextFromDB(); - new RefreshDescriptionsTask().execute(); + if (error == null) { + updateLastUpdateTextFromDB(); + + new RefreshDescriptionsTask().execute(); + } + else Toast.makeText(this, error, Toast.LENGTH_LONG).show(); } public void onRetrieveStart() { progressBar.setIndeterminate(true);