From: Damyan Ivanov Date: Tue, 16 Apr 2019 18:03:51 +0000 (+0300) Subject: lambdas X-Git-Tag: v0.10.0~103 X-Git-Url: https://git.ktnx.net/?a=commitdiff_plain;h=138706a5444b5b9b3b4038b69b27338793dbeb6b;p=mobile-ledger.git lambdas --- 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 5fd3400a..088fd0bd 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 @@ -43,7 +43,6 @@ import net.ktnx.mobileledger.utils.MLDB; import org.jetbrains.annotations.NotNull; -import java.util.Observable; import java.util.Observer; import androidx.annotation.NonNull; @@ -72,16 +71,12 @@ public class TransactionListFragment extends MobileLedgerListFragment { setHasOptionsMenu(true); if (backgroundTaskCountObserver == null) { Log.d("rtl", "creating background task count observer"); - Data.backgroundTaskCount.addObserver(backgroundTaskCountObserver = new Observer() { - @Override - public void update(Observable o, Object arg) { - mActivity.runOnUiThread(() -> { + Data.backgroundTaskCount.addObserver( + backgroundTaskCountObserver = (o, arg) -> mActivity.runOnUiThread(() -> { int cnt = Data.backgroundTaskCount.get(); Log.d("trl", String.format("background task count changed to %d", cnt)); swiper.setRefreshing(cnt > 0); - }); - } - }); + })); } } @Override @@ -162,15 +157,12 @@ public class TransactionListFragment extends MobileLedgerListFragment { 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; + TransactionListViewModel.updateError.addObserver((o, arg) -> { + String err = TransactionListViewModel.updateError.get(); + if (err == null) return; - Toast.makeText(mActivity, err, Toast.LENGTH_SHORT).show(); - TransactionListViewModel.updateError.set(null); - } + Toast.makeText(mActivity, err, Toast.LENGTH_SHORT).show(); + TransactionListViewModel.updateError.set(null); }); Data.transactions.addObserver( (o, arg) -> mActivity.runOnUiThread(() -> modelAdapter.notifyDataSetChanged()));