Bug 960359: (2/4) Control HomeBanner visibility from home_pager_container. r=margaret

This commit is contained in:
Josh Dover 2014-02-13 15:43:48 -08:00
Родитель 7ef9b14f04
Коммит 2c1e3e5ab9
5 изменённых файлов: 25 добавлений и 17 удалений

Просмотреть файл

@ -1422,7 +1422,8 @@ abstract public class BrowserApp extends GeckoApp
}
private boolean isHomePagerVisible() {
return (mHomePager != null && mHomePager.isVisible());
return (mHomePager != null && mHomePager.isLoaded()
&& mHomePagerContainer != null && mHomePagerContainer.getVisibility() == View.VISIBLE);
}
/* Favicon stuff. */
@ -1679,7 +1680,8 @@ abstract public class BrowserApp extends GeckoApp
mHomePager = (HomePager) homePagerStub.inflate();
}
mHomePager.show(getSupportLoaderManager(),
mHomePagerContainer.setVisibility(View.VISIBLE);
mHomePager.load(getSupportLoaderManager(),
getSupportFragmentManager(),
pageId, animator);
@ -1739,9 +1741,10 @@ abstract public class BrowserApp extends GeckoApp
// Display the previously hidden web content (which prevented screen reader access).
mLayerView.setVisibility(View.VISIBLE);
mHomePagerContainer.setVisibility(View.GONE);
if (mHomePager != null) {
mHomePager.hide();
mHomePager.unload();
}
mBrowserToolbar.setNextFocusDownId(R.id.layer_view);

Просмотреть файл

@ -167,7 +167,7 @@ public class HomePager extends ViewPager {
*
* @param fm FragmentManager for the adapter
*/
public void show(LoaderManager lm, FragmentManager fm, String panelId, PropertyAnimator animator) {
public void load(LoaderManager lm, FragmentManager fm, String panelId, PropertyAnimator animator) {
mLoaded = true;
mInitialPanelId = panelId;
@ -179,8 +179,6 @@ public class HomePager extends ViewPager {
adapter.setCanLoadHint(!shouldAnimate);
setAdapter(adapter);
setVisibility(VISIBLE);
// Don't show the tabs strip until we have the
// list of panels in place.
mTabStrip.setVisibility(View.INVISIBLE);
@ -211,23 +209,22 @@ public class HomePager extends ViewPager {
}
/**
* Hides the pager and removes all child fragments.
* Removes all child fragments to free memory.
*/
public void hide() {
public void unload() {
mLoaded = false;
setVisibility(GONE);
setAdapter(null);
}
/**
* Determines whether the pager is visible.
* Determines whether the pager is loaded.
*
* Unlike getVisibility(), this method does not need to be called on the UI
* thread.
*
* @return Whether the pager and its fragments are being displayed
* @return Whether the pager and its fragments are loaded
*/
public boolean isVisible() {
public boolean isLoaded() {
return mLoaded;
}
@ -296,7 +293,7 @@ public class HomePager extends ViewPager {
setAdapter(adapter);
// Use the default panel as defined in the HomePager's configuration
// if the initial panel wasn't explicitly set by the show() caller,
// if the initial panel wasn't explicitly set by the load() caller,
// or if the initial panel is not found in the adapter.
final int itemPosition = (mInitialPanelId == null) ? -1 : adapter.getItemPosition(mInitialPanelId);
if (itemPosition > -1) {

Просмотреть файл

@ -11,8 +11,7 @@
android:id="@+id/home_pager"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/white"
android:visibility="gone">
android:background="@android:color/white">
<org.mozilla.gecko.home.TabMenuStrip android:layout_width="fill_parent"
android:layout_height="32dip"

Просмотреть файл

@ -35,6 +35,16 @@
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"/>
</FrameLayout>

Просмотреть файл

@ -11,8 +11,7 @@
android:id="@+id/home_pager"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/white"
android:visibility="gone">
android:background="@android:color/white">
<org.mozilla.gecko.home.HomePagerTabStrip android:layout_width="fill_parent"
android:layout_height="32dip"