From ac3b5b52cfdf268b05578acab1c098647543245b Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Thu, 6 Dec 2018 21:28:45 +0000 Subject: [PATCH] Account summary: menu item for manually refreshing the data --- .../java/net/ktnx/mobileledger/AccountSummary.java | 11 ++++++++++- app/src/main/res/drawable/ic_refresh_white_24dp.xml | 5 +++++ app/src/main/res/menu/account_summary.xml | 11 +++++++++++ app/src/main/res/values/strings.xml | 1 + 4 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 app/src/main/res/drawable/ic_refresh_white_24dp.xml create mode 100644 app/src/main/res/menu/account_summary.xml diff --git a/app/src/main/java/net/ktnx/mobileledger/AccountSummary.java b/app/src/main/java/net/ktnx/mobileledger/AccountSummary.java index e8cf0398..bd73cd07 100644 --- a/app/src/main/java/net/ktnx/mobileledger/AccountSummary.java +++ b/app/src/main/java/net/ktnx/mobileledger/AccountSummary.java @@ -33,6 +33,7 @@ public class AccountSummary extends AppCompatActivity { public static void preferences_changed() { account_list_needs_update = true; } + MenuItem mRefresh; @Override protected void onCreate(Bundle savedInstanceState) { @@ -88,7 +89,9 @@ public class AccountSummary extends AppCompatActivity { @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. - //getMenuInflater().inflate(R.menu.latest_transactions, menu); + getMenuInflater().inflate(R.menu.account_summary, menu); + mRefresh = (MenuItem) menu.findItem(R.id.menu_acc_summary_refresh); + assert mRefresh != null; return true; } @@ -107,6 +110,10 @@ public class AccountSummary extends AppCompatActivity { return super.onOptionsItemSelected(item); } + public void onRefreshAccountSummaryClicked(MenuItem mi) { + update_accounts(true); + } + private void prepare_db() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { MobileLedgerDB.setDb_filename(this.getApplicationInfo().deviceProtectedDataDir + "/" + MobileLedgerDB.DATABASE_NAME); @@ -129,6 +136,7 @@ public class AccountSummary extends AppCompatActivity { } private void update_accounts() { + mRefresh.setVisible(false); Resources rm = getResources(); ProgressBar pb = findViewById(R.id.progressBar); @@ -150,6 +158,7 @@ public class AccountSummary extends AppCompatActivity { protected void onPostExecute(Void result) { pb.setVisibility(GONE); pt.setVisibility(GONE); + mRefresh.setVisible(true); if (this.error != 0) Snackbar.make(drawer, rm.getString(this.error), Snackbar.LENGTH_LONG ); else diff --git a/app/src/main/res/drawable/ic_refresh_white_24dp.xml b/app/src/main/res/drawable/ic_refresh_white_24dp.xml new file mode 100644 index 00000000..0d6368fc --- /dev/null +++ b/app/src/main/res/drawable/ic_refresh_white_24dp.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/menu/account_summary.xml b/app/src/main/res/menu/account_summary.xml new file mode 100644 index 00000000..f416b53d --- /dev/null +++ b/app/src/main/res/menu/account_summary.xml @@ -0,0 +1,11 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 75e444d4..813ccf05 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -69,4 +69,5 @@ Description Save Account Summary + Refresh -- 2.39.5