浏览代码

harden notification empty screenshot test

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Andy Scherzinger 4 年之前
父节点
当前提交
c8696d9f64
共有 1 个文件被更改,包括 21 次插入13 次删除
  1. 21 13
      src/main/java/com/owncloud/android/ui/activity/NotificationsActivity.java

+ 21 - 13
src/main/java/com/owncloud/android/ui/activity/NotificationsActivity.java

@@ -202,6 +202,7 @@ public class NotificationsActivity extends DrawerActivity implements Notificatio
 
 
     @VisibleForTesting
     @VisibleForTesting
     public void populateList(List<Notification> notifications) {
     public void populateList(List<Notification> notifications) {
+        initializeAdapter();
         adapter.setNotificationItems(notifications);
         adapter.setNotificationItems(notifications);
         binding.loadingContent.setVisibility(View.GONE);
         binding.loadingContent.setVisibility(View.GONE);
 
 
@@ -220,19 +221,7 @@ public class NotificationsActivity extends DrawerActivity implements Notificatio
 
 
     private void fetchAndSetData() {
     private void fetchAndSetData() {
         Thread t = new Thread(() -> {
         Thread t = new Thread(() -> {
-            if (client == null && optionalUser.isPresent()) {
-                try {
-                    User user = optionalUser.get();
-                    client = clientFactory.create(user);
-                } catch (ClientFactory.CreationException e) {
-                    Log_OC.e(TAG, "Error initializing client", e);
-                }
-            }
-
-            if (adapter == null) {
-                adapter = new NotificationListAdapter(client, this);
-                binding.list.setAdapter(adapter);
-            }
+            initializeAdapter();
 
 
             RemoteOperation getRemoteNotificationOperation = new GetNotificationsRemoteOperation();
             RemoteOperation getRemoteNotificationOperation = new GetNotificationsRemoteOperation();
             final RemoteOperationResult result = getRemoteNotificationOperation.execute(client);
             final RemoteOperationResult result = getRemoteNotificationOperation.execute(client);
@@ -253,6 +242,25 @@ public class NotificationsActivity extends DrawerActivity implements Notificatio
         t.start();
         t.start();
     }
     }
 
 
+    private void initializeClient() {
+        if (client == null && optionalUser.isPresent()) {
+            try {
+                User user = optionalUser.get();
+                client = clientFactory.create(user);
+            } catch (ClientFactory.CreationException e) {
+                Log_OC.e(TAG, "Error initializing client", e);
+            }
+        }
+    }
+
+    private void initializeAdapter() {
+        initializeClient();
+        if (adapter == null) {
+            adapter = new NotificationListAdapter(client, this);
+            binding.list.setAdapter(adapter);
+        }
+    }
+
     private void hideRefreshLayoutLoader() {
     private void hideRefreshLayoutLoader() {
         runOnUiThread(() -> {
         runOnUiThread(() -> {
             binding.swipeContainingList.setRefreshing(false);
             binding.swipeContainingList.setRefreshing(false);