From: Damyan Ivanov Date: Sun, 7 Mar 2021 09:16:34 +0000 (+0200) Subject: handle menu items click hooks by code in new transaction activity X-Git-Tag: v0.17.0~16 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=b36e2e3152f57528aacf94f31985952cf80406a4;p=mobile-ledger.git handle menu items click hooks by code in new transaction activity --- diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionActivity.java b/app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionActivity.java index 5bba06e1..ce97d985 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionActivity.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/new_transaction/NewTransactionActivity.java @@ -155,9 +155,10 @@ public class NewTransactionActivity extends ProfileThemedActivity navController.navigate(R.id.newTransactionFragment, b); } } - public void simulateCrash(MenuItem item) { + public boolean onSimulateCrashMenuItemClicked(MenuItem item) { debug("crash", "Will crash intentionally"); new AsyncCrasher().execute(); + return true; } public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); @@ -170,6 +171,11 @@ public class NewTransactionActivity extends ProfileThemedActivity MenuCompat.setGroupDividerEnabled(menu, true); + menu.findItem(R.id.action_simulate_save) + .setOnMenuItemClickListener(this::onToggleSimulateSaveMenuItemClicked); + menu.findItem(R.id.action_simulate_crash) + .setOnMenuItemClickListener(this::onSimulateCrashMenuItemClicked); + model.getSimulateSave() .observe(this, state -> { menu.findItem(R.id.action_simulate_save) @@ -195,8 +201,9 @@ public class NewTransactionActivity extends ProfileThemedActivity else navController.navigate(R.id.action_newTransactionSavingFragment_Success, b); } - public void toggleSimulateSave(MenuItem item) { + public boolean onToggleSimulateSaveMenuItemClicked(MenuItem item) { model.toggleSimulateSave(); + return true; } @Override diff --git a/app/src/main/res/menu/new_transaction.xml b/app/src/main/res/menu/new_transaction.xml index 15fe57b0..f4862d8c 100644 --- a/app/src/main/res/menu/new_transaction.xml +++ b/app/src/main/res/menu/new_transaction.xml @@ -21,7 +21,6 @@