]> git.ktnx.net Git - mobile-ledger.git/blobdiff - app/src/main/java/net/ktnx/mobileledger/ui/account_summary/AccountSummaryFragment.java
use a constant for the last refresh stamp option
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / ui / account_summary / AccountSummaryFragment.java
index b0b673273a8424b59491fb7267316a677aa9c9f3..99cf91fecb07e32024878114560836dbbd90a0cf 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2018 Damyan Ivanov.
+ * Copyright © 2019 Damyan Ivanov.
  * This file is part of Mobile-Ledger.
  * Mobile-Ledger is free software: you can distribute it and/or modify it
  * under the term of the GNU General Public License as published by
@@ -39,9 +39,9 @@ import android.view.View;
 import android.view.ViewGroup;
 
 import net.ktnx.mobileledger.R;
-import net.ktnx.mobileledger.ui.RecyclerItemListener;
 import net.ktnx.mobileledger.async.RetrieveAccountsTask;
 import net.ktnx.mobileledger.model.LedgerAccount;
+import net.ktnx.mobileledger.ui.RecyclerItemListener;
 import net.ktnx.mobileledger.ui.activity.MainActivity;
 import net.ktnx.mobileledger.utils.MLDB;
 
@@ -82,6 +82,8 @@ public class AccountSummaryFragment extends Fragment {
     public void onActivityCreated(@Nullable Bundle savedInstanceState) {
         super.onActivityCreated(savedInstanceState);
 
+        mActivity.markDrawerItemCurrent(R.id.nav_account_summary);
+
         model = ViewModelProviders.of(this).get(AccountSummaryViewModel.class);
         List<LedgerAccount> accounts = model.getAccounts(this.getContext());
         modelAdapter = new AccountSummaryAdapter(accounts);
@@ -103,6 +105,14 @@ public class AccountSummaryFragment extends Fragment {
                         if (modelAdapter.isSelectionActive()) {
                             modelAdapter.selectItem(position);
                         }
+                        else {
+                            List<LedgerAccount> accounts = model.getAccounts(mActivity);
+                            if (accounts != null) {
+                                LedgerAccount account = accounts.get(position);
+
+                                mActivity.showAccountTransactions(account);
+                            }
+                        }
                     }
 
                     @Override
@@ -122,6 +132,7 @@ public class AccountSummaryFragment extends Fragment {
                     }
                 }));
 
+        fab.show();
         root.addOnScrollListener(new RecyclerView.OnScrollListener() {
             @Override
             public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
@@ -143,7 +154,7 @@ public class AccountSummaryFragment extends Fragment {
 
     }
     private void prepare_db() {
-        account_list_last_updated = MLDB.get_option_value(mActivity, "last_refresh", (long) 0);
+        account_list_last_updated = MLDB.get_option_value(MLDB.OPT_LAST_REFRESH, (long) 0);
     }
 
     private void update_accounts(boolean force) {
@@ -171,7 +182,7 @@ public class AccountSummaryFragment extends Fragment {
             Snackbar.make(swiper, err_text, Snackbar.LENGTH_LONG).show();
         }
         else {
-            MLDB.set_option_value(mActivity, "last_refresh", new Date().getTime());
+            MLDB.set_option_value(MLDB.OPT_LAST_REFRESH, new Date().getTime());
             update_account_table();
         }
     }