Example #1
0
 @Override
 protected void onDetachedFromWindow() {
   updateAdapter(mPager.getAdapter(), null);
   mPager.setInternalPageChangeListener(null);
   mPager.setOnAdapterChangeListener(null);
   mPager = null;
 }
Example #2
0
  @Override
  protected void onAttachedToWindow() {
    super.onAttachedToWindow();

    final ViewParent parent = getParent();
    if (!(parent instanceof ViewPager)) {
      throw new IllegalStateException("PagerTitleStrip must be a direct child of a ViewPager.");
    }

    final ViewPager pager = (ViewPager) parent;
    final PagerAdapter adapter = pager.getAdapter();

    pager.setInternalPageChangeListener(mPageListener);
    pager.setOnAdapterChangeListener(mPageListener);
    mPager = pager;
    updateAdapter(null, adapter);
  }