Bug 903160 - Follow-up: Use ViewStub in home_list_with_title.xml for lazy inflation. r=sriram

This commit is contained in:
Chenxia Liu 2013-08-09 17:56:53 -07:00
parent 2096b42101
commit 5885e2d2e5
5 changed files with 37 additions and 24 deletions

View File

@ -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 \

View File

@ -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);

View File

@ -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);

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/home_empty_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:gravity="center"
android:paddingLeft="50dp"
android:paddingRight="50dp">
<ImageView android:id="@+id/home_empty_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="15dp"/>
<TextView android:id="@+id/home_empty_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textAppearance="@style/TextAppearance.EmptyMessage"/>
</LinearLayout>

View File

@ -5,28 +5,10 @@
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout android:id="@+id/home_empty_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:gravity="center"
android:paddingLeft="50dp"
android:paddingRight="50dp"
android:visibility="gone">
<ImageView android:id="@+id/home_empty_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="15dp"
android:scaleType="fitXY"/>
<TextView android:id="@+id/home_empty_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textAppearance="@style/TextAppearance.EmptyMessage"/>
</LinearLayout>
<ViewStub android:id="@+id/home_empty_view_stub"
android:layout="@layout/home_empty_page"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
<TextView android:id="@+id/title"
style="@style/Widget.Home.PageTitle"