Bug 1037527 - Auto-expand synced tabs clients, r=nalexander
authorMark Capella <markcapella@twcny.rr.com>
Tue, 15 Jul 2014 03:43:54 -0400
changeset 216011 4f035fc0bd3bd496cf0012dd6512c207b59ff748
parent 216010 d5d67c4fe497bd6dc0a41960d1e9641ad935a4b3
child 216012 9ca47cad4083095669acb83161fa734ab22dd816
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnalexander
bugs1037527
milestone33.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1037527 - Auto-expand synced tabs clients, r=nalexander
mobile/android/base/tabspanel/RemoteTabsList.java
--- a/mobile/android/base/tabspanel/RemoteTabsList.java
+++ b/mobile/android/base/tabspanel/RemoteTabsList.java
@@ -37,17 +37,17 @@ class RemoteTabsList extends ExpandableL
 
     private final Context context;
     private TabsPanel tabsPanel;
 
     private ArrayList <HashMap <String, String>> clients;
     private ArrayList <ArrayList <HashMap <String, String>>> tabsList;
 
     // A list of the clients that are currently expanded.
-    private List<String> expandedClientList = new ArrayList<String>();
+    private List<String> expandedClientList;
 
     // The client that previously had an item selected is used to restore the scroll position.
     private String clientScrollPosition;
 
     public RemoteTabsList(Context context, AttributeSet attrs) {
         super(context, attrs);
         this.context = context;
 
@@ -138,27 +138,36 @@ class RemoteTabsList extends ExpandableL
                                                    R.layout.remote_tabs_group,
                                                    CLIENT_KEY,
                                                    CLIENT_RESOURCE,
                                                    tabsList,
                                                    R.layout.remote_tabs_child,
                                                    TAB_KEY,
                                                    TAB_RESOURCE));
 
-        // Expand the client groups, and restore the previous scroll position.
+        // Either set the initial UI state, or restore it.
         List<String> newExpandedClientList = new ArrayList<String>();
         for (int i = 0; i < clients.size(); i++) {
             final String clientGuid = clients.get(i).get("guid");
-            if (expandedClientList.contains(clientGuid)) {
+
+            if (expandedClientList == null) {
+                // On initial entry we expand all clients by default.
                 newExpandedClientList.add(clientGuid);
                 expandGroup(i);
-            }
+            } else {
+                // On subsequent entries, we expand clients based on their previous UI state.
+                if (expandedClientList.contains(clientGuid)) {
+                    newExpandedClientList.add(clientGuid);
+                    expandGroup(i);
+                }
 
-            if (clientGuid.equals(clientScrollPosition)) {
-                setSelectedGroup(i);
+                // Additionally we reset the UI scroll position.
+                if (clientGuid.equals(clientScrollPosition)) {
+                    setSelectedGroup(i);
+                }
             }
         }
         expandedClientList = newExpandedClientList;
     }
 
     /**
      * Return a relative "Last synced" time span for the given tab record.
      *