Backed out changeset ea2d05f0a053 (bug 856767) for robocop bustage on a CLOSED TREE.
authorRyan VanderMeulen <ryanvm@gmail.com>
Tue, 02 Apr 2013 17:17:02 -0400
changeset 126982 97cfc16ba5dcd6644f13989ff994cbd395cb7dec
parent 126981 581b88b27b2dea740cbbfe02f16157b9fd1077a8
child 126985 686d76b44d9f034b2a76ea063ffba7f288666b7c
child 126986 a2c84336476f847ed390734793ef387eb2fe69f4
push id24499
push userryanvm@gmail.com
push dateWed, 03 Apr 2013 02:25:10 +0000
treeherdermozilla-central@97cfc16ba5dc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs856767
milestone23.0a1
backs outea2d05f0a053fad7f9eab676850d38c80951ddfc
first release with
nightly linux32
97cfc16ba5dc / 23.0a1 / 20130403030841 / files
nightly linux64
97cfc16ba5dc / 23.0a1 / 20130403030841 / files
nightly mac
97cfc16ba5dc / 23.0a1 / 20130403030841 / files
nightly win32
97cfc16ba5dc / 23.0a1 / 20130403030841 / files
nightly win64
97cfc16ba5dc / 23.0a1 / 20130403030841 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset ea2d05f0a053 (bug 856767) for robocop bustage on a CLOSED TREE.
mobile/android/base/widget/AboutHomeContent.java
mobile/android/base/widget/TopSitesView.java
--- a/mobile/android/base/widget/AboutHomeContent.java
+++ b/mobile/android/base/widget/AboutHomeContent.java
@@ -187,22 +187,21 @@ public class AboutHomeContent extends Sc
     public void onActivityContentChanged() {
         update(EnumSet.of(UpdateFlags.TOP_SITES));
     }
 
     /**
      * Reinflates and updates all components of this view.
      */
     public void refresh() {
-        mTopSites.onDestroy();
-
         // We must remove the currently inflated view to allow for reinflation.
         removeAllViews();
 
         inflate();
+        mTopSites.refresh();
 
         // Refresh all elements.
         update(AboutHomeContent.UpdateFlags.ALL);
     }
 
     public void setLastTabsVisibility(boolean visible) {
         if (visible)
             mLastTabs.show();
--- a/mobile/android/base/widget/TopSitesView.java
+++ b/mobile/android/base/widget/TopSitesView.java
@@ -136,25 +136,19 @@ public class TopSitesView extends GridVi
             }
         });
 
         setTopSitesConstants();
     }
 
     public void onDestroy() {
         if (mTopSitesAdapter != null) {
-            final Cursor cursor = mTopSitesAdapter.getCursor();
-
-            ThreadUtils.postToBackgroundThread(new Runnable() {
-                @Override
-                public void run() {
-                    if (cursor != null && !cursor.isClosed())
-                        cursor.close();
-                }
-            });
+            Cursor cursor = mTopSitesAdapter.getCursor();
+            if (cursor != null && !cursor.isClosed())
+                cursor.close();
         }
     }
 
     @Override
     public int getColumnWidth() {
         return getColumnWidth(getWidth());
     }
 
@@ -187,19 +181,22 @@ public class TopSitesView extends GridVi
         ThumbnailHelper.getInstance().setThumbnailWidth(w);
         heightMeasureSpec = MeasureSpec.makeMeasureSpec((int)(w*ThumbnailHelper.THUMBNAIL_ASPECT_RATIO*numRows) + getPaddingTop() + getPaddingBottom(),
                                                              MeasureSpec.EXACTLY);
         super.onMeasure(widthMeasureSpec, heightMeasureSpec);
     }
 
     public void loadTopSites() {
         final ContentResolver resolver = mContext.getContentResolver();
-
+        Cursor old = null;
+        if (mTopSitesAdapter != null) {
+            old = mTopSitesAdapter.getCursor();
+        }
         // Swap in the new cursor.
-        final Cursor oldCursor = (mTopSitesAdapter != null) ? mTopSitesAdapter.getCursor() : null;
+        final Cursor oldCursor = old;
         final Cursor newCursor = BrowserDB.getTopSites(resolver, mNumberOfTopSites);
 
         post(new Runnable() {
             @Override
             public void run() {
                 if (mTopSitesAdapter == null) {
                     mTopSitesAdapter = new TopSitesCursorAdapter(mContext,
                                                                  R.layout.abouthome_topsite_item,
@@ -338,16 +335,23 @@ public class TopSitesView extends GridVi
     public void setUriLoadCallback(AboutHomeContent.UriLoadCallback uriLoadCallback) {
         mUriLoadCallback = uriLoadCallback;
     }
 
     public void setLoadCompleteCallback(AboutHomeContent.VoidCallback callback) {
         mLoadCompleteCallback = callback;
     }
 
+    public void refresh() {
+        if (mTopSitesAdapter != null)
+            mTopSitesAdapter.notifyDataSetChanged();
+
+        setAdapter(mTopSitesAdapter);
+    }
+
     private class TopSitesViewHolder {
         public TextView titleView = null;
         public ImageView thumbnailView = null;
         public ImageView pinnedView = null;
         private String mTitle = null;
         private String mUrl = null;
         private boolean mIsPinned = false;