X-Git-Url: https://git.ktnx.net/?a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fui%2Faccount_summary%2FAccountSummaryFragment.java;h=8ee910b54fe33b4c33655cc771fc18cd8d0fb167;hb=accc48ea8a6f092716a99d2e21f3c6b95a7e9c37;hp=8ed6582d714508848234577b0970b199f40e47bc;hpb=21d46a2a578325c5653bf8ecdbb69f68c0097d0e;p=mobile-ledger.git diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/account_summary/AccountSummaryFragment.java b/app/src/main/java/net/ktnx/mobileledger/ui/account_summary/AccountSummaryFragment.java index 8ed6582d..8ee910b5 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/account_summary/AccountSummaryFragment.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/account_summary/AccountSummaryFragment.java @@ -1,5 +1,5 @@ /* - * Copyright © 2019 Damyan Ivanov. + * Copyright © 2020 Damyan Ivanov. * This file is part of MoLe. * MoLe is free software: you can distribute it and/or modify it * under the term of the GNU General Public License as published by @@ -46,9 +46,6 @@ public class AccountSummaryFragment extends MobileLedgerListFragment { super.onCreate(savedInstanceState); debug("flow", "AccountSummaryFragment.onCreate()"); setHasOptionsMenu(true); - - Data.backgroundTasksRunning.observe(this.getViewLifecycleOwner(), - this::onBackgroundTaskRunningChanged); } public void onAttach(@NotNull Context context) { super.onAttach(context); @@ -68,9 +65,11 @@ public class AccountSummaryFragment extends MobileLedgerListFragment { debug("flow", "AccountSummaryFragment.onActivityCreated()"); super.onActivityCreated(savedInstanceState); + Data.backgroundTasksRunning.observe(this.getViewLifecycleOwner(), + this::onBackgroundTaskRunningChanged); + modelAdapter = new AccountSummaryAdapter(); - mActivity.mAccountSummaryFragment = this; root = mActivity.findViewById(R.id.account_root); LinearLayoutManager llm = new LinearLayoutManager(mActivity); llm.setOrientation(RecyclerView.VERTICAL); @@ -94,72 +93,4 @@ public class AccountSummaryFragment extends MobileLedgerListFragment { Data.accounts.addObserver( (o, arg) -> mActivity.runOnUiThread(() -> modelAdapter.notifyDataSetChanged())); } -/* - 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(@NotNull Menu menu, @NotNull 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; - - mShowOnlyStarred = menu.findItem(R.id.menu_acc_summary_only_starred); - if (mShowOnlyStarred == null) throw new AssertionError(); - MenuItem mCancelSelection = menu.findItem(R.id.menu_acc_summary_cancel_selection); - if (mCancelSelection == null) throw new AssertionError(); - MenuItem mConfirmSelection = menu.findItem(R.id.menu_acc_summary_confirm_selection); - if (mConfirmSelection == null) throw new AssertionError(); - - Data.optShowOnlyStarred.addObserver((o, arg) -> { - boolean newValue = Data.optShowOnlyStarred.get(); - debug("pref", String.format("pref change came (%s)", newValue ? "true" : "false")); - mShowOnlyStarred.setChecked(newValue); - update_account_table(); - }); - - mShowOnlyStarred.setChecked(Data.optShowOnlyStarred.get()); - - debug("menu", "Accounts: onCreateOptionsMenu called"); - - mShowOnlyStarred.setOnMenuItemClickListener(item -> { - SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(mActivity); - SharedPreferences.Editor editor = pref.edit(); - boolean flag = item.isChecked(); - editor.putBoolean(PREF_KEY_SHOW_ONLY_STARRED_ACCOUNTS, !flag); - debug("pref", - "Setting show only starred accounts pref to " + (flag ? "false" : "true")); - editor.apply(); - - return true; - }); - - mCancelSelection.setOnMenuItemClickListener(item -> { - stopSelection(); - return true; - }); - - mConfirmSelection.setOnMenuItemClickListener(item -> { - AccountSummaryViewModel.commitSelections(mActivity); - stopSelection(); - - return true; - }); - } -*/ }