/** * "pop" operation ends if destPage is found, if destPage is not found, the method call is a no-op * * @param destPage page as the destination for this pop operation * @param animated true to animate the transition */ public void popToPage( Page destPage, boolean animated, PageAnimator.AnimationDirection animationDirection) { if (mAnimating) { return; } if (destPage == null) { throw new IllegalArgumentException("cannot call popToPage() with null destPage."); } if (mPageStack.size() <= 0 || mPageStack.lastIndexOf(destPage) == -1 || mPageStack.peekLast() == destPage) { return; } Page oldPage = mPageStack.removeLast(); if (mEnableDebug) { Log.d(TAG, String.format(">>>> popPage, pagestack=%d, %s", mPageStack.size(), oldPage)); } while (mPageStack.size() > 1) { if (mPageStack.peekLast() == destPage) { break; } Page page = mPageStack.removeLast(); page.onHide(); mContainerView.removeView(page.getView()); page.onDetached(); page.onHidden(); } popPageInternal(oldPage, animated, animationDirection); }
public void popTopNPages( int n, boolean animated, PageAnimator.AnimationDirection animationDirection) { if (mAnimating) { return; } if (n <= 0 || mPageStack.size() <= 0) { return; } Page oldPage = mPageStack.removeLast(); --n; // for mPageStack.removeLast() above while (--n >= 0) { Page page = mPageStack.removeLast(); page.onHide(); mContainerView.removeView(page.getView()); page.onDetached(); page.onHidden(); if (mEnableDebug) { Log.d(TAG, String.format(">>>> popPage, pagestack=%d, %s", mPageStack.size(), page)); } } popPageInternal(oldPage, animated, animationDirection); }
private void doFinalWorkForPopPageInternal(Page removedPage, Page prevPage) { mContainerView.removeView(removedPage.getView()); removedPage.onDetached(); removedPage.onHidden(); if (prevPage != null) { if (prevPage == getTopPage()) { prevPage.getView().bringToFront(); } prevPage.onUncovered(removedPage.getReturnData()); } }
/** * "pop" operation ends when one of the classes specified by pageClasses is found, if none of the * classes is found, the method call is a no-op * * @param pageClasses classes of pages as the destination for this pop operation * @param animated true to animate the transition */ public void popToClasses( Class<? extends Page>[] pageClasses, boolean animated, PageAnimator.AnimationDirection animationDirection) { if (mAnimating) { return; } if (pageClasses == null || pageClasses.length == 0) { throw new IllegalArgumentException( "cannot call popToClasses() with null or empty pageClasses."); } if (mPageStack.size() <= 0) { return; } // do nothing if the topPage is the page we want to navigate to Class topPageClass = mPageStack.peekLast().getClass(); for (Class pageClass : pageClasses) { if (pageClass == topPageClass) { return; } } // do nothing if the page we want to navigate to does not exist boolean hasDestClass = false; Iterator<Page> it = mPageStack.descendingIterator(); LOOP1: while (it.hasNext()) { Class destPageClass = it.next().getClass(); for (Class pageClass : pageClasses) { if (destPageClass == pageClass) { hasDestClass = true; break LOOP1; } } } if (!hasDestClass) { return; } Page oldPage = mPageStack.removeLast(); LOOP2: while (mPageStack.size() > 1) { Class lastPageClass = mPageStack.peekLast().getClass(); for (Class pageClass : pageClasses) { if (lastPageClass == pageClass) { break LOOP2; } } Page page = mPageStack.removeLast(); page.onHide(); mContainerView.removeView(page.getView()); page.onDetached(); page.onHidden(); } popPageInternal(oldPage, animated, animationDirection); }