X-Git-Url: https://git.ktnx.net/?p=mobile-ledger.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2FAccountSummary.java;h=2c9589e37cffeb6b25dad537fecd02b9ba2c7f27;hp=5ad2a57d8589c1490f7a251333a6411e1b0a17ac;hb=6c58c1072c9af6ea0d0f52baeae7f95ba7f7ee2f;hpb=f8f86b6145e025b787650f7342675622227f9b24 diff --git a/app/src/main/java/net/ktnx/mobileledger/AccountSummary.java b/app/src/main/java/net/ktnx/mobileledger/AccountSummary.java index 5ad2a57d..2c9589e3 100644 --- a/app/src/main/java/net/ktnx/mobileledger/AccountSummary.java +++ b/app/src/main/java/net/ktnx/mobileledger/AccountSummary.java @@ -43,7 +43,7 @@ import android.widget.LinearLayout; import net.ktnx.mobileledger.async.RetrieveAccountsTask; import net.ktnx.mobileledger.model.LedgerAccount; -import net.ktnx.mobileledger.utils.MobileLedgerDatabase; +import net.ktnx.mobileledger.utils.MLDB; import java.lang.ref.WeakReference; import java.util.Date; @@ -58,7 +58,6 @@ public class AccountSummary extends AppCompatActivity { private static boolean account_list_needs_update = true; MenuItem mShowHiddenAccounts; SharedPreferences.OnSharedPreferenceChangeListener sBindPreferenceSummaryToValueListener; - private MobileLedgerDatabase dbh; private AccountSummaryViewModel model; private AccountSummaryAdapter modelAdapter; private Menu optMenu; @@ -74,8 +73,6 @@ public class AccountSummary extends AppCompatActivity { Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); - dbh = new MobileLedgerDatabase(this); - drawer = findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); @@ -92,7 +89,7 @@ public class AccountSummary extends AppCompatActivity { } model = ViewModelProviders.of(this).get(AccountSummaryViewModel.class); - List accounts = model.getAccounts(); + List accounts = model.getAccounts(getApplicationContext()); modelAdapter = new AccountSummaryAdapter(accounts); RecyclerView root = findViewById(R.id.account_root); @@ -250,7 +247,7 @@ public class AccountSummary extends AppCompatActivity { } private void prepare_db() { - account_list_last_updated = dbh.get_option_value("last_refresh", (long) 0); + account_list_last_updated = MLDB.get_option_value(this, "last_refresh", (long) 0); } private void update_accounts(boolean force) { @@ -277,12 +274,12 @@ public class AccountSummary extends AppCompatActivity { Snackbar.make(drawer, err_text, Snackbar.LENGTH_LONG ).show(); } else { - dbh.set_option_value("last_refresh", new Date().getTime() ); + MLDB.set_option_value(this, "last_refresh", new Date().getTime()); update_account_table(); } } private void update_account_table() { - model.reloadAccounts(); + model.reloadAccounts(getApplicationContext()); modelAdapter.notifyDataSetChanged(); } void stopSelection() { @@ -301,7 +298,7 @@ public class AccountSummary extends AppCompatActivity { stopSelection(); } public void onConfirmAccSelection(MenuItem item) { - model.commitSelections(); + model.commitSelections(getApplicationContext()); stopSelection(); } }