Loading app/src/main/java/foundation/e/blisslauncher/core/customviews/HorizontalPager.java +15 −31 Original line number Original line Diff line number Diff line Loading @@ -39,7 +39,6 @@ public class HorizontalPager extends ViewGroup { private boolean firstLayout = true; private boolean firstLayout = true; private int currentPage; private int currentPage; private int nextPage = INVALID_SCREEN; private Scroller mScroller; private Scroller mScroller; private VelocityTracker mVelocityTracker; private VelocityTracker mVelocityTracker; Loading Loading @@ -131,12 +130,17 @@ public class HorizontalPager extends ViewGroup { @Override @Override public void computeScroll() { public void computeScroll() { if (mScroller.computeScrollOffset()) { if (!mScroller.isFinished() && mScroller.computeScrollOffset()) { scrollTo(mScroller.getCurrX(), mScroller.getCurrY()); int oldX = getScrollX(); postInvalidate(); int oldY = getScrollY(); } else if (nextPage != INVALID_SCREEN) { int x = mScroller.getCurrX(); currentPage = nextPage; int y = mScroller.getCurrY(); nextPage = INVALID_SCREEN; if (oldX != x || oldY != y) { scrollTo(x, y); } postInvalidateOnAnimation(); return; } } } } Loading Loading @@ -209,11 +213,7 @@ public class HorizontalPager extends ViewGroup { return false; return false; } } int focusableScreen; int focusableScreen; if (nextPage != INVALID_SCREEN) { focusableScreen = nextPage; } else { focusableScreen = currentPage; focusableScreen = currentPage; } getChildAt(focusableScreen).requestFocus(direction, previouslyFocusedRect); getChildAt(focusableScreen).requestFocus(direction, previouslyFocusedRect); return false; return false; } } Loading Loading @@ -454,7 +454,6 @@ public class HorizontalPager extends ViewGroup { } else if (getScrollX() > startX + getWidth() / 8) { } else if (getScrollX() > startX + getWidth() / 8) { whichPage = Math.min(getChildCount() - 1, whichPage + 1); whichPage = Math.min(getChildCount() - 1, whichPage + 1); } } snapToPage(whichPage); snapToPage(whichPage); } } Loading @@ -462,8 +461,7 @@ public class HorizontalPager extends ViewGroup { enableChildrenCache(); enableChildrenCache(); boolean changingPages = whichPage != currentPage; boolean changingPages = whichPage != currentPage; currentPage = whichPage; nextPage = whichPage; View focusedChild = getFocusedChild(); View focusedChild = getFocusedChild(); if (focusedChild != null && changingPages && focusedChild == getChildAt(currentPage)) { if (focusedChild != null && changingPages && focusedChild == getChildAt(currentPage)) { Loading @@ -472,7 +470,6 @@ public class HorizontalPager extends ViewGroup { final int newX = getScrollXForPage(whichPage); final int newX = getScrollXForPage(whichPage); final int delta = newX - getScrollX(); final int delta = newX - getScrollX(); //mScroller.startScroll(getScrollX(), 0, delta, 0, Math.abs(delta) * 2); mScroller.startScroll(getScrollX(), 0, delta, 0, duration); mScroller.startScroll(getScrollX(), 0, delta, 0, duration); invalidate(); invalidate(); } } Loading @@ -497,27 +494,14 @@ public class HorizontalPager extends ViewGroup { } } } } public void scrollLeft() { if (nextPage == INVALID_SCREEN && currentPage > 0 && mScroller.isFinished()) { snapToPage(currentPage - 1); } } public void scrollLeft(int duration) { public void scrollLeft(int duration) { if (nextPage == INVALID_SCREEN && currentPage > 0 && mScroller.isFinished()) { if (currentPage > 0 && mScroller.isFinished()) { snapToPage(currentPage - 1, duration); snapToPage(currentPage - 1, duration); } } } } public void scrollRight() { if (nextPage == INVALID_SCREEN && currentPage < getChildCount() - 1 && mScroller.isFinished()) { snapToPage(currentPage + 1); } } public void scrollRight(int duration) { public void scrollRight(int duration) { if (nextPage == INVALID_SCREEN && currentPage < getChildCount() - 1 if (currentPage < getChildCount() - 1 && mScroller.isFinished()) { && mScroller.isFinished()) { snapToPage(currentPage + 1, duration); snapToPage(currentPage + 1, duration); } } Loading Loading
app/src/main/java/foundation/e/blisslauncher/core/customviews/HorizontalPager.java +15 −31 Original line number Original line Diff line number Diff line Loading @@ -39,7 +39,6 @@ public class HorizontalPager extends ViewGroup { private boolean firstLayout = true; private boolean firstLayout = true; private int currentPage; private int currentPage; private int nextPage = INVALID_SCREEN; private Scroller mScroller; private Scroller mScroller; private VelocityTracker mVelocityTracker; private VelocityTracker mVelocityTracker; Loading Loading @@ -131,12 +130,17 @@ public class HorizontalPager extends ViewGroup { @Override @Override public void computeScroll() { public void computeScroll() { if (mScroller.computeScrollOffset()) { if (!mScroller.isFinished() && mScroller.computeScrollOffset()) { scrollTo(mScroller.getCurrX(), mScroller.getCurrY()); int oldX = getScrollX(); postInvalidate(); int oldY = getScrollY(); } else if (nextPage != INVALID_SCREEN) { int x = mScroller.getCurrX(); currentPage = nextPage; int y = mScroller.getCurrY(); nextPage = INVALID_SCREEN; if (oldX != x || oldY != y) { scrollTo(x, y); } postInvalidateOnAnimation(); return; } } } } Loading Loading @@ -209,11 +213,7 @@ public class HorizontalPager extends ViewGroup { return false; return false; } } int focusableScreen; int focusableScreen; if (nextPage != INVALID_SCREEN) { focusableScreen = nextPage; } else { focusableScreen = currentPage; focusableScreen = currentPage; } getChildAt(focusableScreen).requestFocus(direction, previouslyFocusedRect); getChildAt(focusableScreen).requestFocus(direction, previouslyFocusedRect); return false; return false; } } Loading Loading @@ -454,7 +454,6 @@ public class HorizontalPager extends ViewGroup { } else if (getScrollX() > startX + getWidth() / 8) { } else if (getScrollX() > startX + getWidth() / 8) { whichPage = Math.min(getChildCount() - 1, whichPage + 1); whichPage = Math.min(getChildCount() - 1, whichPage + 1); } } snapToPage(whichPage); snapToPage(whichPage); } } Loading @@ -462,8 +461,7 @@ public class HorizontalPager extends ViewGroup { enableChildrenCache(); enableChildrenCache(); boolean changingPages = whichPage != currentPage; boolean changingPages = whichPage != currentPage; currentPage = whichPage; nextPage = whichPage; View focusedChild = getFocusedChild(); View focusedChild = getFocusedChild(); if (focusedChild != null && changingPages && focusedChild == getChildAt(currentPage)) { if (focusedChild != null && changingPages && focusedChild == getChildAt(currentPage)) { Loading @@ -472,7 +470,6 @@ public class HorizontalPager extends ViewGroup { final int newX = getScrollXForPage(whichPage); final int newX = getScrollXForPage(whichPage); final int delta = newX - getScrollX(); final int delta = newX - getScrollX(); //mScroller.startScroll(getScrollX(), 0, delta, 0, Math.abs(delta) * 2); mScroller.startScroll(getScrollX(), 0, delta, 0, duration); mScroller.startScroll(getScrollX(), 0, delta, 0, duration); invalidate(); invalidate(); } } Loading @@ -497,27 +494,14 @@ public class HorizontalPager extends ViewGroup { } } } } public void scrollLeft() { if (nextPage == INVALID_SCREEN && currentPage > 0 && mScroller.isFinished()) { snapToPage(currentPage - 1); } } public void scrollLeft(int duration) { public void scrollLeft(int duration) { if (nextPage == INVALID_SCREEN && currentPage > 0 && mScroller.isFinished()) { if (currentPage > 0 && mScroller.isFinished()) { snapToPage(currentPage - 1, duration); snapToPage(currentPage - 1, duration); } } } } public void scrollRight() { if (nextPage == INVALID_SCREEN && currentPage < getChildCount() - 1 && mScroller.isFinished()) { snapToPage(currentPage + 1); } } public void scrollRight(int duration) { public void scrollRight(int duration) { if (nextPage == INVALID_SCREEN && currentPage < getChildCount() - 1 if (currentPage < getChildCount() - 1 && mScroller.isFinished()) { && mScroller.isFinished()) { snapToPage(currentPage + 1, duration); snapToPage(currentPage + 1, duration); } } Loading