Fix issue with setting the current page immediately after a page is added
Change-Id: Ia9ddc42896b47b10bb98ed6bd6cece1b033207c1
This commit is contained in:
1 parent
efe354b877
commit
e61a9a2cd4
2 files changed
+11
-9
No files matched your search
@@ -89,6 +89,8 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
|
||||
protected boolean mFirstLayout = true;
|
||||
|
||||
protected int mCurrentPage;
|
||||
protected int mChildCountOnLastMeasure;
|
||||
|
||||
protected int mNextPage = INVALID_PAGE;
|
||||
protected int mMaxScrollX;
|
||||
protected Scroller mScroller;
|
||||
@@ -347,7 +349,7 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
mForceScreenScrolled = true;
|
||||
mCurrentPage = Math.max(0, Math.min(currentPage, getPageCount() - 1));
|
||||
updateCurrentPageScroll();
|
||||
updateScrollingIndicator();
|
||||
@@ -564,6 +566,11 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
|
||||
// ensure that the cache is filled with good values.
|
||||
invalidateCachedOffsets();
|
||||
|
||||
if (mChildCountOnLastMeasure != getChildCount()) {
|
||||
setCurrentPage(mCurrentPage);
|
||||
}
|
||||
mChildCountOnLastMeasure = getChildCount();
|
||||
|
||||
if (childCount > 0) {
|
||||
if (DEBUG) Log.d(TAG, "getRelativeChildOffset(): " + getMeasuredWidth() + ", "
|
||||
+ getChildWidth(0));
|
||||
|
||||
Reference in new issue
Block a user