Bug 968640 - Lazy init HomeBanner using ViewStub. r=lucasr

--HG--
rename : mobile/android/base/resources/layout/home_banner.xml => mobile/android/base/resources/layout/home_banner_content.xml
This commit is contained in:
Margaret Leibovic 2014-03-14 11:41:46 -07:00
parent 3edebe70f4
commit e5887739d2
5 changed files with 55 additions and 44 deletions

View File

@ -1656,7 +1656,8 @@ abstract public class BrowserApp extends GeckoApp
// Don't show the banner in guest mode.
if (!getProfile().inGuestMode()) {
final HomeBanner homeBanner = (HomeBanner) findViewById(R.id.home_banner);
final ViewStub homeBannerStub = (ViewStub) findViewById(R.id.home_banner_stub);
final HomeBanner homeBanner = (HomeBanner) homeBannerStub.inflate();
mHomePager.setBanner(homeBanner);
// Remove the banner from the view hierarchy if it is dismissed.

View File

@ -70,7 +70,7 @@ public class HomeBanner extends LinearLayout
public HomeBanner(Context context, AttributeSet attrs) {
super(context, attrs);
LayoutInflater.from(context).inflate(R.layout.home_banner, this);
LayoutInflater.from(context).inflate(R.layout.home_banner_content, this);
mTextView = (TextView) findViewById(R.id.text);
mIconView = (ImageView) findViewById(R.id.icon);

View File

@ -36,17 +36,12 @@
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
<org.mozilla.gecko.home.HomeBanner android:id="@+id/home_banner"
style="@style/Widget.HomeBanner"
android:layout_width="fill_parent"
android:layout_height="@dimen/home_banner_height"
android:background="@drawable/home_banner"
android:layout_gravity="bottom"
android:gravity="center_vertical"
android:visibility="gone"
android:clickable="true"
android:focusable="true"
android:translationY="@dimen/home_banner_height"/>
<ViewStub android:id="@+id/home_banner_stub"
android:layout="@layout/home_banner"
android:layout_width="fill_parent"
android:layout_height="@dimen/home_banner_height"
android:layout_gravity="bottom"
android:translationY="@dimen/home_banner_height"/>
</FrameLayout>

View File

@ -3,34 +3,13 @@
- 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/. -->
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView android:id="@+id/icon"
android:layout_width="48dip"
android:layout_height="48dip"
android:layout_marginLeft="10dp"
android:scaleType="centerInside"/>
<TextView android:id="@+id/text"
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:layout_marginLeft="10dp"
android:paddingTop="7dp"
android:paddingBottom="7dp"
android:textAppearance="@style/TextAppearance.Widget.HomeBanner"
android:layout_gravity="bottom"
android:singleLine="false"
android:maxLines="3"
android:ellipsize="end"
android:gravity="center_vertical"/>
<ImageButton android:id="@+id/close"
android:layout_width="34dip"
android:layout_height="fill_parent"
android:background="@drawable/home_banner"
android:scaleType="center"
android:contentDescription="@string/close_tab"
android:src="@drawable/tab_close"/>
</merge>
<org.mozilla.gecko.home.HomeBanner xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/home_banner"
style="@style/Widget.HomeBanner"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/home_banner"
android:gravity="center_vertical"
android:visibility="gone"
android:clickable="true"
android:focusable="true"/>

View File

@ -0,0 +1,36 @@
<?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/. -->
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView android:id="@+id/icon"
android:layout_width="48dip"
android:layout_height="48dip"
android:layout_marginLeft="10dp"
android:scaleType="centerInside"/>
<TextView android:id="@+id/text"
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_weight="1"
android:layout_marginLeft="10dp"
android:paddingTop="7dp"
android:paddingBottom="7dp"
android:textAppearance="@style/TextAppearance.Widget.HomeBanner"
android:layout_gravity="bottom"
android:singleLine="false"
android:maxLines="3"
android:ellipsize="end"
android:gravity="center_vertical"/>
<ImageButton android:id="@+id/close"
android:layout_width="34dip"
android:layout_height="fill_parent"
android:background="@drawable/home_banner"
android:scaleType="center"
android:contentDescription="@string/close_tab"
android:src="@drawable/tab_close"/>
</merge>