]> git.ktnx.net Git - mobile-ledger.git/commitdiff
some lambdas
authorDamyan Ivanov <dam+mobileledger@ktnx.net>
Sat, 5 Jan 2019 13:06:16 +0000 (13:06 +0000)
committerDamyan Ivanov <dam+mobileledger@ktnx.net>
Sat, 5 Jan 2019 13:06:16 +0000 (13:06 +0000)
app/src/main/java/net/ktnx/mobileledger/ui/account_summary/AccountSummaryFragment.java
app/src/main/java/net/ktnx/mobileledger/ui/activity/MainActivity.java
app/src/main/java/net/ktnx/mobileledger/ui/transaction_list/TransactionListFragment.java

index 19c88f2fd5e7f753c395ab6d6273465d2edad66f..82709138207aaf553b51f29b4f893a8d1c409895 100644 (file)
@@ -79,13 +79,10 @@ public class AccountSummaryFragment extends MobileLedgerListFragment {
                 public void update(Observable o, Object arg) {
                     if (mActivity == null) return;
                     if (swiper == null) return;
-                    mActivity.runOnUiThread(new Runnable() {
-                        @Override
-                        public void run() {
-                            int cnt = Data.backgroundTaskCount.get();
-                            Log.d("acc", String.format("background task count changed to %d", cnt));
-                            swiper.setRefreshing(cnt > 0);
-                        }
+                    mActivity.runOnUiThread(() -> {
+                        int cnt = Data.backgroundTaskCount.get();
+                        Log.d("acc", String.format("background task count changed to %d", cnt));
+                        swiper.setRefreshing(cnt > 0);
                     });
                 }
             });
@@ -174,12 +171,7 @@ public class AccountSummaryFragment extends MobileLedgerListFragment {
         Data.accounts.addObserver(new Observer() {
             @Override
             public void update(Observable o, Object arg) {
-                mActivity.runOnUiThread(new Runnable() {
-                    @Override
-                    public void run() {
-                        modelAdapter.notifyDataSetChanged();
-                    }
-                });
+                mActivity.runOnUiThread(() -> modelAdapter.notifyDataSetChanged());
             }
         });
         update_account_table();
index c2ff5c27b1b3d3bbfe55da54bcc422e3f4c6a8ec..6e17983bf0b43b4f3dad5b516e1d76ad6ce470ec 100644 (file)
@@ -109,21 +109,18 @@ public class MainActivity extends AppCompatActivity {
             @Override
             public void update(Observable o, Object arg) {
                 Log.d("main", "lastUpdateDate changed");
-                runOnUiThread(new Runnable() {
-                    @Override
-                    public void run() {
-                        Date date = Data.lastUpdateDate.get();
-                        if (date == null) {
-                            tvLastUpdate.setText(R.string.transaction_last_update_never);
+                runOnUiThread(() -> {
+                    Date date = Data.lastUpdateDate.get();
+                    if (date == null) {
+                        tvLastUpdate.setText(R.string.transaction_last_update_never);
+                    }
+                    else {
+                        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+                            tvLastUpdate.setText(date.toInstant().atZone(ZoneId.systemDefault())
+                                    .format(DateTimeFormatter.ISO_LOCAL_DATE_TIME));
                         }
                         else {
-                            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
-                                tvLastUpdate.setText(date.toInstant().atZone(ZoneId.systemDefault())
-                                        .format(DateTimeFormatter.ISO_LOCAL_DATE_TIME));
-                            }
-                            else {
-                                tvLastUpdate.setText(date.toLocaleString());
-                            }
+                            tvLastUpdate.setText(date.toLocaleString());
                         }
                     }
                 });
index e3496a086f6035c28e540cd54bdc667d14bc8625..a15650ae912df4975ffe0d7dadd1651d5c8c3792 100644 (file)
@@ -94,13 +94,10 @@ public class TransactionListFragment extends MobileLedgerListFragment {
             Data.backgroundTaskCount.addObserver(backgroundTaskCountObserver = new Observer() {
                 @Override
                 public void update(Observable o, Object arg) {
-                    mActivity.runOnUiThread(new Runnable() {
-                        @Override
-                        public void run() {
-                            int cnt = Data.backgroundTaskCount.get();
-                            Log.d("trl", String.format("background task count changed to %d", cnt));
-                            swiper.setRefreshing(cnt > 0);
-                        }
+                    mActivity.runOnUiThread(() -> {
+                        int cnt = Data.backgroundTaskCount.get();
+                        Log.d("trl", String.format("background task count changed to %d", cnt));
+                        swiper.setRefreshing(cnt > 0);
                     });
                 }
             });
@@ -197,12 +194,7 @@ public class TransactionListFragment extends MobileLedgerListFragment {
         Data.transactions.addObserver(new Observer() {
             @Override
             public void update(Observable o, Object arg) {
-                mActivity.runOnUiThread(new Runnable() {
-                    @Override
-                    public void run() {
-                        modelAdapter.notifyDataSetChanged();
-                    }
-                });
+                mActivity.runOnUiThread(() -> modelAdapter.notifyDataSetChanged());
             }
         });