Bug 1251362 - Part 10 - Only enable swipe to refresh when viewing synced tabs draft
authorJan Henning <jh+bugzilla@buttercookie.de>
Sat, 14 May 2016 23:38:29 +0200
changeset 369304 7feb7321ca5c0bb851322dd5111d80c874ec308d
parent 369303 778cf9812bcc43468ddfaa4ef5abef081daf12bf
child 369305 29fc733565579bd322648002e710dd79c870c2f3
push id18831
push usermozilla@buttercookie.de
push dateSat, 21 May 2016 18:52:21 +0000
bugs1251362
milestone49.0a1
Bug 1251362 - Part 10 - Only enable swipe to refresh when viewing synced tabs MozReview-Commit-ID: YwekSwQr2q
mobile/android/base/java/org/mozilla/gecko/home/ClientsAdapter.java
mobile/android/base/java/org/mozilla/gecko/home/CombinedHistoryPanel.java
--- a/mobile/android/base/java/org/mozilla/gecko/home/ClientsAdapter.java
+++ b/mobile/android/base/java/org/mozilla/gecko/home/ClientsAdapter.java
@@ -140,16 +140,20 @@ public class ClientsAdapter extends Recy
         }
     }
 
     @Override
     public int getItemViewType(int position) {
         return CombinedHistoryItem.ItemType.itemTypeToViewType(getItemTypeForPosition(position));
     }
 
+    public int getClientsCount() {
+        return hiddenClients.size() + visibleClients.size();
+    }
+
     @UiThread
     public void setClients(List<RemoteClient> clients) {
         adapterList.clear();
         adapterList.add(null);
 
         hiddenClients.clear();
         visibleClients.clear();
 
--- a/mobile/android/base/java/org/mozilla/gecko/home/CombinedHistoryPanel.java
+++ b/mobile/android/base/java/org/mozilla/gecko/home/CombinedHistoryPanel.java
@@ -172,16 +172,17 @@ public class CombinedHistoryPanel extend
             }
         });
         registerForContextMenu(mRecyclerView);
     }
 
     private void setUpRefreshLayout() {
         mRefreshLayout.setColorSchemeResources(R.color.fennec_ui_orange, R.color.action_orange);
         mRefreshLayout.setOnRefreshListener(new RemoteTabsRefreshListener());
+        mRefreshLayout.setEnabled(false);
     }
 
     private void setUpEmptyViews() {
         // Set up history empty view.
         final ImageView historyIcon = (ImageView) mHistoryEmptyView.findViewById(R.id.home_empty_image);
         historyIcon.setVisibility(View.GONE);
 
         final TextView historyText = (TextView) mHistoryEmptyView.findViewById(R.id.home_empty_text);
@@ -291,17 +292,16 @@ public class CombinedHistoryPanel extend
                 case LOADER_ID_HISTORY:
                     mHistoryAdapter.setHistory(c);
                     break;
 
                 case LOADER_ID_REMOTE:
                     final List<RemoteClient> clients = mDB.getTabsAccessor().getClientsFromCursor(c);
                     mHistoryAdapter.getDeviceUpdateHandler().onDeviceCountUpdated(clients.size());
                     mClientsAdapter.setClients(clients);
-                    mRefreshLayout.setEnabled(clients.size() > 0);
                     break;
             }
 
             updateEmptyView();
             updateButtonFromLevel();
         }
 
         @Override
@@ -334,19 +334,21 @@ public class CombinedHistoryPanel extend
             if (level == mPanelLevel) {
                 return false;
             }
 
             mPanelLevel = level;
             switch (level) {
                 case PARENT:
                     mRecyclerView.swapAdapter(mHistoryAdapter, true);
+                    mRefreshLayout.setEnabled(false);
                     break;
                 case CHILD_SYNC:
                     mRecyclerView.swapAdapter(mClientsAdapter, true);
+                    mRefreshLayout.setEnabled(mClientsAdapter.getClientsCount() > 0);
                     break;
                 case CHILD_RECENT_TABS:
                     mRecyclerView.swapAdapter(mRecentTabsAdapter, true);
                     break;
             }
 
             updateEmptyView();
             updateButtonFromLevel();