浏览代码

fix cr comments and replace anonymous listeners with lambdas

AndyScherzinger 7 年之前
父节点
当前提交
3a7a82238e
共有 1 个文件被更改,包括 21 次插入27 次删除
  1. 21 27
      src/main/java/com/owncloud/android/ui/activity/ActivitiesListActivity.java

+ 21 - 27
src/main/java/com/owncloud/android/ui/activity/ActivitiesListActivity.java

@@ -88,8 +88,10 @@ public class ActivitiesListActivity extends FileActivity implements ActivityList
     @BindView(R.id.empty_list_view)
     @BindView(R.id.empty_list_view)
     public LinearLayout emptyContentContainer;
     public LinearLayout emptyContentContainer;
 
 
+    @BindView(R.id.swipe_containing_list)
     public SwipeRefreshLayout swipeListRefreshLayout;
     public SwipeRefreshLayout swipeListRefreshLayout;
 
 
+    @BindView(R.id.swipe_containing_empty)
     public SwipeRefreshLayout swipeEmptyListRefreshLayout;
     public SwipeRefreshLayout swipeEmptyListRefreshLayout;
 
 
     @BindView(R.id.empty_list_view_text)
     @BindView(R.id.empty_list_view_text)
@@ -107,6 +109,9 @@ public class ActivitiesListActivity extends FileActivity implements ActivityList
     @BindView(android.R.id.list)
     @BindView(android.R.id.list)
     public RecyclerView recyclerView;
     public RecyclerView recyclerView;
 
 
+    @BindView(R.id.bottom_navigation_view)
+    public BottomNavigationView bottomNavigationView;
+
     @BindString(R.string.activities_no_results_headline)
     @BindString(R.string.activities_no_results_headline)
     public String noResultsHeadline;
     public String noResultsHeadline;
 
 
@@ -132,8 +137,6 @@ public class ActivitiesListActivity extends FileActivity implements ActivityList
         // setup toolbar
         // setup toolbar
         setupToolbar();
         setupToolbar();
 
 
-        swipeEmptyListRefreshLayout = findViewById(R.id.swipe_containing_empty);
-        swipeListRefreshLayout = findViewById(R.id.swipe_containing_list);
         onCreateSwipeToRefresh(swipeEmptyListRefreshLayout);
         onCreateSwipeToRefresh(swipeEmptyListRefreshLayout);
         onCreateSwipeToRefresh(swipeListRefreshLayout);
         onCreateSwipeToRefresh(swipeListRefreshLayout);
 
 
@@ -144,27 +147,23 @@ public class ActivitiesListActivity extends FileActivity implements ActivityList
             ThemeUtils.setColoredTitle(actionBar, getString(R.string.drawer_item_activities));
             ThemeUtils.setColoredTitle(actionBar, getString(R.string.drawer_item_activities));
         }
         }
 
 
-        swipeListRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
-            @Override
-            public void onRefresh() {
-                setLoadingMessage();
-                if (swipeListRefreshLayout.isRefreshing()) {
-                    swipeListRefreshLayout.setRefreshing(false);
+        swipeListRefreshLayout.setOnRefreshListener(() -> {
+                    setLoadingMessage();
+                    if (swipeListRefreshLayout != null && swipeListRefreshLayout.isRefreshing()) {
+                        swipeListRefreshLayout.setRefreshing(false);
+                    }
+                    fetchAndSetData(null);
                 }
                 }
-                fetchAndSetData(null);
-            }
-        });
+        );
 
 
-        swipeEmptyListRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
-            @Override
-            public void onRefresh() {
-                setLoadingMessage();
-                if (swipeEmptyListRefreshLayout.isRefreshing()) {
-                    swipeEmptyListRefreshLayout.setRefreshing(false);
+        swipeEmptyListRefreshLayout.setOnRefreshListener(() -> {
+                    setLoadingMessage();
+                    if (swipeEmptyListRefreshLayout != null && swipeEmptyListRefreshLayout.isRefreshing()) {
+                        swipeEmptyListRefreshLayout.setRefreshing(false);
+                    }
+                    fetchAndSetData(null);
                 }
                 }
-                fetchAndSetData(null);
-            }
-        });
+        );
     }
     }
 
 
     protected void onCreateSwipeToRefresh(SwipeRefreshLayout refreshLayout) {
     protected void onCreateSwipeToRefresh(SwipeRefreshLayout refreshLayout) {
@@ -223,8 +222,6 @@ public class ActivitiesListActivity extends FileActivity implements ActivityList
             }
             }
         });
         });
 
 
-        BottomNavigationView bottomNavigationView = (BottomNavigationView) findViewById(R.id.bottom_navigation_view);
-
         if (getResources().getBoolean(R.bool.bottom_toolbar_enabled)) {
         if (getResources().getBoolean(R.bool.bottom_toolbar_enabled)) {
             bottomNavigationView.setVisibility(View.VISIBLE);
             bottomNavigationView.setVisibility(View.VISIBLE);
             DisplayUtils.setupBottomBar(bottomNavigationView, getResources(), this, -1);
             DisplayUtils.setupBottomBar(bottomNavigationView, getResources(), this, -1);
@@ -240,9 +237,7 @@ public class ActivitiesListActivity extends FileActivity implements ActivityList
         final Account currentAccount = AccountUtils.getCurrentOwnCloudAccount(MainApp.getAppContext());
         final Account currentAccount = AccountUtils.getCurrentOwnCloudAccount(MainApp.getAppContext());
         final Context context = MainApp.getAppContext();
         final Context context = MainApp.getAppContext();
 
 
-        Thread t = new Thread(new Runnable() {
-
-            public void run() {
+        Thread t = new Thread(() -> {
                 OwnCloudAccount ocAccount;
                 OwnCloudAccount ocAccount;
                 try {
                 try {
                     ocAccount = new OwnCloudAccount(currentAccount, context);
                     ocAccount = new OwnCloudAccount(currentAccount, context);
@@ -305,7 +300,7 @@ public class ActivitiesListActivity extends FileActivity implements ActivityList
                     Log_OC.e(TAG, "Authentication Exception", e);
                     Log_OC.e(TAG, "Authentication Exception", e);
                 }
                 }
             }
             }
-        });
+        );
 
 
         t.start();
         t.start();
     }
     }
@@ -320,7 +315,6 @@ public class ActivitiesListActivity extends FileActivity implements ActivityList
     }
     }
 
 
     private void populateList(List<Object> activities, OwnCloudClient mClient) {
     private void populateList(List<Object> activities, OwnCloudClient mClient) {
-
         adapter.setActivityItems(activities, mClient);
         adapter.setActivityItems(activities, mClient);
     }
     }