From 5885e2d2e56ccf20f00a24d22abcf95846c8d704 Mon Sep 17 00:00:00 2001 From: Chenxia Liu Date: Fri, 9 Aug 2013 17:56:53 -0700 Subject: [PATCH] Bug 903160 - Follow-up: Use ViewStub in home_list_with_title.xml for lazy inflation. r=sriram --- mobile/android/base/Makefile.in | 1 + mobile/android/base/home/LastTabsPage.java | 4 ++- mobile/android/base/home/MostRecentPage.java | 4 ++- .../base/resources/layout/home_empty_page.xml | 26 +++++++++++++++++++ .../resources/layout/home_list_with_title.xml | 26 +++---------------- 5 files changed, 37 insertions(+), 24 deletions(-) create mode 100644 mobile/android/base/resources/layout/home_empty_page.xml diff --git a/mobile/android/base/Makefile.in b/mobile/android/base/Makefile.in index 3dcd78b9f79..4a2984c67ad 100644 --- a/mobile/android/base/Makefile.in +++ b/mobile/android/base/Makefile.in @@ -467,6 +467,7 @@ RES_LAYOUT = \ res/layout/font_size_preference.xml \ res/layout/gecko_app.xml \ res/layout/home_bookmarks_page.xml \ + res/layout/home_empty_page.xml \ res/layout/home_item_row.xml \ res/layout/home_header_row.xml \ res/layout/home_history_page.xml \ diff --git a/mobile/android/base/home/LastTabsPage.java b/mobile/android/base/home/LastTabsPage.java index b105b614462..edba58cec73 100644 --- a/mobile/android/base/home/LastTabsPage.java +++ b/mobile/android/base/home/LastTabsPage.java @@ -24,6 +24,7 @@ import android.support.v4.content.Loader; import android.support.v4.widget.CursorAdapter; import android.view.LayoutInflater; import android.view.View; +import android.view.ViewStub; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.ImageView; @@ -159,7 +160,8 @@ public class LastTabsPage extends HomeFragment { 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); + ViewStub emptyViewStub = (ViewStub) getActivity().findViewById(R.id.home_empty_view_stub); + mEmptyView = emptyViewStub.inflate(); final ImageView emptyIcon = (ImageView) mEmptyView.findViewById(R.id.home_empty_image); emptyIcon.setImageResource(R.drawable.icon_last_tabs_empty); diff --git a/mobile/android/base/home/MostRecentPage.java b/mobile/android/base/home/MostRecentPage.java index 73ef89974d0..942b7f15270 100644 --- a/mobile/android/base/home/MostRecentPage.java +++ b/mobile/android/base/home/MostRecentPage.java @@ -21,6 +21,7 @@ import android.support.v4.content.Loader; import android.util.SparseArray; import android.view.LayoutInflater; import android.view.View; +import android.view.ViewStub; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.ImageView; @@ -158,7 +159,8 @@ public class MostRecentPage extends HomeFragment { 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); + ViewStub emptyViewStub = (ViewStub) getActivity().findViewById(R.id.home_empty_view_stub); + mEmptyView = emptyViewStub.inflate(); final ImageView emptyIcon = (ImageView) mEmptyView.findViewById(R.id.home_empty_image); emptyIcon.setImageResource(R.drawable.icon_most_recent_empty); diff --git a/mobile/android/base/resources/layout/home_empty_page.xml b/mobile/android/base/resources/layout/home_empty_page.xml new file mode 100644 index 00000000000..438e84c45d1 --- /dev/null +++ b/mobile/android/base/resources/layout/home_empty_page.xml @@ -0,0 +1,26 @@ + + + + + + + + + + diff --git a/mobile/android/base/resources/layout/home_list_with_title.xml b/mobile/android/base/resources/layout/home_list_with_title.xml index f8e818879e9..3bc8daab40b 100644 --- a/mobile/android/base/resources/layout/home_list_with_title.xml +++ b/mobile/android/base/resources/layout/home_list_with_title.xml @@ -5,28 +5,10 @@ - - - - - - - +