Backed out changeset c0dc627fa67f
authorChenxia Liu <liuche@mozilla.com>
Thu, 08 Aug 2013 16:13:21 -0700
changeset 143512 8689289ad25e081e966365b9a48357d2796c0fde
parent 143511 c0dc627fa67f97b4f93cf40bf718ae621a3eea71
child 143513 51eb7425cb01f6ef2475bbceacd4af03b0822c4a
push id25130
push userlrocha@mozilla.com
push dateWed, 21 Aug 2013 09:41:27 +0000
treeherdermozilla-central@b2486721572e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone25.0a1
backs outc0dc627fa67f97b4f93cf40bf718ae621a3eea71
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
Backed out changeset c0dc627fa67f
mobile/android/base/home/MostRecentPage.java
mobile/android/base/resources/layout/home_list_with_title.xml
--- a/mobile/android/base/home/MostRecentPage.java
+++ b/mobile/android/base/home/MostRecentPage.java
@@ -40,22 +40,16 @@ public class MostRecentPage extends Home
     private static final int LOADER_ID_HISTORY = 0;
 
     // Adapter for the list of search results
     private MostRecentAdapter mAdapter;
 
     // The view shown by the fragment.
     private ListView mList;
 
-    // The title for this HomeFragment page.
-    private TextView mTitle;
-
-    // Reference to the View to display when there are no results.
-    private View mEmptyView;
-
     // Callbacks used for the search and favicon cursor loaders
     private CursorLoaderCallbacks mCursorLoaderCallbacks;
 
     // On URL open listener
     private OnUrlOpenListener mUrlOpenListener;
 
     public static MostRecentPage newInstance() {
         return new MostRecentPage();
@@ -85,30 +79,36 @@ public class MostRecentPage extends Home
 
     @Override
     public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
         return inflater.inflate(R.layout.home_most_recent_page, container, false);
     }
 
     @Override
     public void onViewCreated(View view, Bundle savedInstanceState) {
-        mTitle = (TextView) view.findViewById(R.id.title);
-        mTitle.setText(R.string.home_most_recent_title);
+        final TextView title = (TextView) view.findViewById(R.id.title);
+        title.setText(R.string.home_most_recent_title);
 
         mList = (ListView) view.findViewById(R.id.list);
         mList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
             @Override
             public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                 position -= mAdapter.getMostRecentSectionsCountBefore(position);
                 final Cursor c = mAdapter.getCursor(position);
                 final String url = c.getString(c.getColumnIndexOrThrow(URLColumns.URL));
                 mUrlOpenListener.onUrlOpen(url);
             }
         });
 
+        // Set empty page view.
+        final View emptyView = view.findViewById(R.id.home_empty_view);
+        ((ImageView) emptyView.findViewById(R.id.home_empty_image)).setImageResource(R.drawable.icon_most_recent_empty);
+        ((TextView) emptyView.findViewById(R.id.home_empty_text)).setText(R.string.home_most_recent_empty);
+        mList.setEmptyView(emptyView);
+
         registerForContextMenu(mList);
     }
 
     @Override
     public void onDestroyView() {
         super.onDestroyView();
         mList = null;
     }
@@ -143,38 +143,16 @@ public class MostRecentPage extends Home
 
         @Override
         public Cursor loadCursor() {
             final ContentResolver cr = getContext().getContentResolver();
             return BrowserDB.getRecentHistory(cr, HISTORY_LIMIT);
         }
     }
 
-    private void updateUiFromCursor(Cursor c) {
-        if (c != null || c.getCount() > 0) {
-            mTitle.setVisibility(View.VISIBLE);
-            return;
-        }
-
-        // Cursor is empty, so hide the title and set the empty view if it hasn't been set already.
-        mTitle.setVisibility(View.GONE);
-        if (mEmptyView == null) {
-            // Set empty page view. We delay this so that the empty view won't flash.
-            mEmptyView = getActivity().findViewById(R.id.home_empty_view);
-
-            final ImageView emptyIcon = (ImageView) mEmptyView.findViewById(R.id.home_empty_image);
-            emptyIcon.setImageResource(R.drawable.icon_most_recent_empty);
-
-            final TextView emptyText = (TextView) mEmptyView.findViewById(R.id.home_empty_text);
-            emptyText.setText(R.string.home_most_recent_empty);
-
-            mList.setEmptyView(mEmptyView);
-        }
-    }
-
     private static class MostRecentAdapter extends MultiTypeCursorAdapter {
         private static final int ROW_HEADER = 0;
         private static final int ROW_STANDARD = 1;
 
         private static final int[] VIEW_TYPES = new int[] { ROW_STANDARD, ROW_HEADER };
         private static final int[] LAYOUT_TYPES = new int[] { R.layout.home_item_row, R.layout.home_header_row };
 
         // For the time sections in history
@@ -356,17 +334,16 @@ public class MostRecentPage extends Home
                 return super.onCreateLoader(id, args);
             }
         }
 
         @Override
         public void onLoadFinished(Loader<Cursor> loader, Cursor c) {
             if (loader.getId() == LOADER_ID_HISTORY) {
                 mAdapter.swapCursor(c);
-                updateUiFromCursor(c);
                 loadFavicons(c);
             } else {
                 super.onLoadFinished(loader, c);
             }
         }
 
         @Override
         public void onLoaderReset(Loader<Cursor> loader) {
--- a/mobile/android/base/resources/layout/home_list_with_title.xml
+++ b/mobile/android/base/resources/layout/home_list_with_title.xml
@@ -24,18 +24,17 @@
                   android:layout_width="fill_parent"
                   android:layout_height="wrap_content"
                   android:gravity="center"
                   android:textAppearance="@style/TextAppearance.EmptyMessage"/>
 
     </LinearLayout>
 
     <TextView android:id="@+id/title"
-              style="@style/Widget.Home.PageTitle"
-              android:visibility="gone"/>
+              style="@style/Widget.Home.PageTitle"/>
 
     <org.mozilla.gecko.home.HomeListView
             android:id="@+id/list"
             android:layout_width="fill_parent"
             android:layout_height="0dp"
             android:layout_weight="1"/>
 
 </merge>