Bug 699155: Tabs should preserve the order in the list [r=mfinkle]
authorSriram Ramasubramanian <sriram@mozilla.com>
Wed, 02 Nov 2011 23:42:11 -0700
changeset 81721 388c49fba3fd0235071d72d33c8364b7adc677b4
parent 81720 c1881e7e046c05bf0ee3b282678bc7b1183bcdaf
child 81722 d479ad39237782010f144d4f6254d06e96bef7d3
push id21573
push userblassey@mozilla.com
push dateTue, 06 Dec 2011 18:57:07 +0000
treeherdermozilla-central@0e397568c71e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs699155
milestone10.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 699155: Tabs should preserve the order in the list [r=mfinkle]
embedding/android/Tabs.java
embedding/android/TabsTray.java
--- a/embedding/android/Tabs.java
+++ b/embedding/android/Tabs.java
@@ -129,16 +129,23 @@ public class Tabs implements GeckoEventL
     }
 
     public HashMap<Integer, Tab> getTabs() {
         if (getCount() == 0)
             return null;
 
         return tabs;
     }
+    
+    public ArrayList<Tab> getTabsInOrder() {
+        if (getCount() == 0)
+            return null;
+
+        return order;
+    }
 
     public void setContentResolver(ContentResolver resolver) {
         this.resolver = resolver;
     }
 
     public ContentResolver getContentResolver() {
         return resolver;
     }
--- a/embedding/android/TabsTray.java
+++ b/embedding/android/TabsTray.java
@@ -33,17 +33,16 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 package org.mozilla.gecko;
 
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.Iterator;
 
 import android.app.Activity;
 import android.content.Intent;
 import android.content.Context;
 import android.graphics.drawable.Drawable;
 import android.graphics.drawable.BitmapDrawable;
 import android.graphics.Typeface;
@@ -106,36 +105,29 @@ public class TabsTray extends Activity i
         super.onDestroy();
         GeckoApp.unregisterOnTabsChangedListener(this);
     } 
    
     public void onTabsChanged() {
         if (Tabs.getInstance().getCount() == 1)
             finish();
 
-        HashMap<Integer, Tab> tabs = Tabs.getInstance().getTabs();
-        mTabsAdapter = new TabsAdapter(this, tabs);
+        mTabsAdapter = new TabsAdapter(this, Tabs.getInstance().getTabsInOrder());
         mList.setAdapter(mTabsAdapter);
     }
 
     // Adapter to bind tabs into a list 
     private class TabsAdapter extends BaseAdapter {
-	public TabsAdapter(Context context, HashMap<Integer, Tab> tabs) {
+	public TabsAdapter(Context context, ArrayList<Tab> tabs) {
             mContext = context;
             mTabs = new ArrayList<Tab>();
-            
-            if (tabs != null) {
-                Iterator keys = tabs.keySet().iterator();
-                Tab tab;
-                while (keys.hasNext()) {
-                    tab = tabs.get(keys.next());
-                    mTabs.add(tab);
-                }
+            for (int i = 0; i < tabs.size(); i++) {
+                mTabs.add(tabs.get(i));
             }
-           
+
             mInflater = LayoutInflater.from(mContext);
         }
 
         @Override    
         public int getCount() {
             return mTabs.size();
         }