X-Git-Url: https://git.ktnx.net/?p=mobile-ledger.git;a=blobdiff_plain;f=app%2Fsrc%2Fmain%2Fjava%2Fnet%2Fktnx%2Fmobileledger%2Fui%2Ftransaction_list%2FTransactionListFragment.java;h=6652120c040ebef49bf72743c38cc62315e1636f;hp=f748ff1dd21344e67405b41e39582588af0484ff;hb=998dd32a089d199a2569069415755eb3169b35b0;hpb=bde37d0aa472d31606b53491240c79af3374f09b diff --git a/app/src/main/java/net/ktnx/mobileledger/ui/transaction_list/TransactionListFragment.java b/app/src/main/java/net/ktnx/mobileledger/ui/transaction_list/TransactionListFragment.java index f748ff1d..6652120c 100644 --- a/app/src/main/java/net/ktnx/mobileledger/ui/transaction_list/TransactionListFragment.java +++ b/app/src/main/java/net/ktnx/mobileledger/ui/transaction_list/TransactionListFragment.java @@ -1,23 +1,22 @@ /* * Copyright © 2019 Damyan Ivanov. - * This file is part of Mobile-Ledger. - * Mobile-Ledger is free software: you can distribute it and/or modify it + * 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 * the Free Software Foundation, either version 3 of the License, or * (at your opinion), any later version. * - * Mobile-Ledger is distributed in the hope that it will be useful, + * MoLe is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License terms for details. * * You should have received a copy of the GNU General Public License - * along with Mobile-Ledger. If not, see . + * along with MoLe. If not, see . */ package net.ktnx.mobileledger.ui.transaction_list; -import android.arch.lifecycle.ViewModelProviders; import android.content.Context; import android.database.MatrixCursor; import android.os.Bundle; @@ -35,6 +34,7 @@ import android.view.View; import android.view.ViewGroup; import android.view.inputmethod.InputMethodManager; import android.widget.AutoCompleteTextView; +import android.widget.Toast; import net.ktnx.mobileledger.R; import net.ktnx.mobileledger.model.Data; @@ -116,6 +116,21 @@ public class TransactionListFragment extends MobileLedgerListFragment { return inflater.inflate(R.layout.transaction_list_fragment, container, false); } @Override + public void onResume() { + super.onResume(); + Log.d("flow", "TransactionListFragment.onResume()"); + } + @Override + public void onStop() { + super.onStop(); + Log.d("flow", "TransactionListFragment.onStop()"); + } + @Override + public void onPause() { + super.onPause(); + Log.d("flow", "TransactionListFragment.onPause()"); + } + @Override public void onActivityCreated(@Nullable Bundle savedInstanceState) { Log.d("flow", "TransactionListFragment.onActivityCreated called"); super.onActivityCreated(savedInstanceState); @@ -125,7 +140,6 @@ public class TransactionListFragment extends MobileLedgerListFragment { root = mActivity.findViewById(R.id.transaction_root); if (root == null) throw new RuntimeException("Can't get hold on the transaction value view"); - model = ViewModelProviders.of(this).get(TransactionListViewModel.class); modelAdapter = new TransactionListAdapter(); modelAdapter.setBoldAccountName(mShowOnlyAccountName); @@ -133,11 +147,11 @@ public class TransactionListFragment extends MobileLedgerListFragment { FloatingActionButton fab = mActivity.findViewById(R.id.btn_add_transaction); - fab.show(); + mActivity.fabShouldShow(); root.addOnScrollListener(new RecyclerView.OnScrollListener() { @Override public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) { - if (dy < 0) fab.show(); + if (dy < 0) mActivity.fabShouldShow(); if (dy > 0) fab.hide(); } }); @@ -183,7 +197,16 @@ public class TransactionListFragment extends MobileLedgerListFragment { TransactionListViewModel.scheduleTransactionListReload(); TransactionListViewModel.updating.addObserver( (o, arg) -> swiper.setRefreshing(TransactionListViewModel.updating.get())); + TransactionListViewModel.updateError.addObserver(new Observer() { + @Override + public void update(Observable o, Object arg) { + String err = TransactionListViewModel.updateError.get(); + if (err == null) return; + Toast.makeText(mActivity, err, Toast.LENGTH_SHORT).show(); + TransactionListViewModel.updateError.set(null); + } + }); Data.transactions.addObserver( (o, arg) -> mActivity.runOnUiThread(() -> modelAdapter.notifyDataSetChanged()));