Bug 966047 - Hide banner when there are no panels enabled. r=mleibovic

This commit is contained in:
Josh Dover 2014-02-24 17:05:52 -08:00
parent d1cdd98f85
commit 7393d9ce58

View File

@ -40,6 +40,7 @@ public class HomePager extends ViewPager {
private HomeBanner mHomeBanner;
private int mDefaultPageIndex = -1;
private final ViewPager.OnPageChangeListener mPageChangeListener;
private final OnAddPanelListener mAddPanelListener;
private final HomeConfig mConfig;
@ -123,7 +124,8 @@ public class HomePager extends ViewPager {
setFocusableInTouchMode(true);
mOriginalBackground = getBackground();
setOnPageChangeListener(new PageChangeListener());
mPageChangeListener = new PageChangeListener();
setOnPageChangeListener(mPageChangeListener);
}
@Override
@ -216,8 +218,9 @@ public class HomePager extends ViewPager {
public void setCurrentItem(int item, boolean smoothScroll) {
super.setCurrentItem(item, smoothScroll);
if (mDecor != null) {
mDecor.onPageSelected(item);
// Android doesn't call this when there is only one item
if (getAdapter().getCount() == 1 && mPageChangeListener != null) {
mPageChangeListener.onPageSelected(0);
}
}
@ -261,6 +264,10 @@ public class HomePager extends ViewPager {
mDecor.removeAllPagerViews();
}
if (mHomeBanner != null) {
mHomeBanner.setEnabled(false);
}
final HomeAdapter adapter = (HomeAdapter) getAdapter();
// Destroy any existing panels currently loaded