- update_account_table();
- }
- private void update_account_table() {
- if (this.getContext() == null) return;
-
- model.scheduleAccountListReload(this.getContext());
- }
- public void onShowOnlyStarredClicked(MenuItem mi) {
- SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(mActivity);
- boolean flag = pref.getBoolean(PREF_KEY_SHOW_ONLY_STARRED_ACCOUNTS, false);
-
- SharedPreferences.Editor editor = pref.edit();
- editor.putBoolean(PREF_KEY_SHOW_ONLY_STARRED_ACCOUNTS, !flag);
- Log.d("pref", "Setting show only starred accounts pref to " + (flag ? "false" : "true"));
- editor.apply();
-
- update_account_table();
- }
-
- void stopSelection() {
- modelAdapter.stopSelection();
- if (optMenu != null) {
- optMenu.findItem(R.id.menu_acc_summary_cancel_selection).setVisible(false);
- optMenu.findItem(R.id.menu_acc_summary_confirm_selection).setVisible(false);
- optMenu.findItem(R.id.menu_acc_summary_only_starred).setVisible(true);
- }
- {
- if (fab != null) fab.show();
- }
- }
- public void onCancelAccSelection(MenuItem item) {
- stopSelection();
- }
- public void onConfirmAccSelection(MenuItem item) {
- AccountSummaryViewModel.commitSelections(mActivity);
- stopSelection();
- }
- @Override
- public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
- // Inflate the menu; this adds items to the action bar if it is present.
- inflater.inflate(R.menu.account_summary, menu);
- optMenu = menu;
-
- mShowHiddenAccounts = menu.findItem(R.id.menu_acc_summary_only_starred);
- if (mShowHiddenAccounts == null) throw new AssertionError();
-
- sBindPreferenceSummaryToValueListener = (preference, value) -> mShowHiddenAccounts
- .setChecked(preference.getBoolean(PREF_KEY_SHOW_ONLY_STARRED_ACCOUNTS, false));
- SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(mActivity);
- pref.registerOnSharedPreferenceChangeListener(sBindPreferenceSummaryToValueListener);
-
- mShowHiddenAccounts.setChecked(pref.getBoolean(PREF_KEY_SHOW_ONLY_STARRED_ACCOUNTS, false));