From e979e62ac7313b7cffe9b131bb8a99c356068b45 Mon Sep 17 00:00:00 2001 From: Romain Guy Date: Tue, 20 Mar 2012 13:50:27 -0700 Subject: [PATCH] Code cleanup Change-Id: I390e92b4a778bd9dcde6535178c1a6b204b29fe4 --- core/java/android/view/HardwareRenderer.java | 9 +-- .../android/widget/HorizontalScrollView.java | 16 ++--- core/java/android/widget/ScrollView.java | 58 ++++--------------- 3 files changed, 25 insertions(+), 58 deletions(-) diff --git a/core/java/android/view/HardwareRenderer.java b/core/java/android/view/HardwareRenderer.java index d08a61f8132c2..b98257cecadd1 100644 --- a/core/java/android/view/HardwareRenderer.java +++ b/core/java/android/view/HardwareRenderer.java @@ -704,7 +704,7 @@ public abstract class HardwareRenderer { return null; } - private void printConfig(EGLConfig config) { + private static void printConfig(EGLConfig config) { int[] value = new int[1]; Log.d(LOG_TAG, "EGL configuration " + config + ":"); @@ -990,10 +990,11 @@ public abstract class HardwareRenderer { } if (invalidateNeeded) { - if (mRedrawClip.isEmpty() || view.getParent() == null) { - view.invalidate(); + if (mRedrawClip.isEmpty()) { + attachInfo.mViewRootImpl.invalidate(); } else { - view.getParent().invalidateChild(view, mRedrawClip); + attachInfo.mViewRootImpl.invalidateChildInParent( + null, mRedrawClip); } mRedrawClip.setEmpty(); } diff --git a/core/java/android/widget/HorizontalScrollView.java b/core/java/android/widget/HorizontalScrollView.java index 0db6ef25fe761..30b2a6700ed06 100644 --- a/core/java/android/widget/HorizontalScrollView.java +++ b/core/java/android/widget/HorizontalScrollView.java @@ -715,7 +715,10 @@ public class HorizontalScrollView extends FrameLayout { } else { super.scrollTo(scrollX, scrollY); } - awakenScrollBars(); + + if (!awakenScrollBars()) { + invalidate(); + } } @Override @@ -1204,10 +1207,9 @@ public class HorizontalScrollView extends FrameLayout { } } - awakenScrollBars(); - - // Keep on drawing until the animation has finished. - postInvalidate(); + if (!awakenScrollBars()) { + invalidate(); + } } } @@ -1414,7 +1416,7 @@ public class HorizontalScrollView extends FrameLayout { /** * Return true if child is a descendant of parent, (or equal to the parent). */ - private boolean isViewDescendantOf(View child, View parent) { + private static boolean isViewDescendantOf(View child, View parent) { if (child == parent) { return true; } @@ -1524,7 +1526,7 @@ public class HorizontalScrollView extends FrameLayout { } } - private int clamp(int n, int my, int child) { + private static int clamp(int n, int my, int child) { if (my >= child || n < 0) { return 0; } diff --git a/core/java/android/widget/ScrollView.java b/core/java/android/widget/ScrollView.java index 25dd438c4693a..2680e03ec3595 100644 --- a/core/java/android/widget/ScrollView.java +++ b/core/java/android/widget/ScrollView.java @@ -642,8 +642,7 @@ public class ScrollView extends FrameLayout { break; case MotionEvent.ACTION_POINTER_DOWN: { final int index = ev.getActionIndex(); - final float y = ev.getY(index); - mLastMotionY = y; + mLastMotionY = ev.getY(index); mActivePointerId = ev.getPointerId(index); break; } @@ -715,7 +714,10 @@ public class ScrollView extends FrameLayout { } else { super.scrollTo(scrollX, scrollY); } - awakenScrollBars(); + + if (!awakenScrollBars()) { + invalidate(); + } } @Override @@ -747,42 +749,6 @@ public class ScrollView extends FrameLayout { return scrollRange; } - /** - *

- * Finds the next focusable component that fits in this View's bounds - * (excluding fading edges) pretending that this View's top is located at - * the parameter top. - *

- * - * @param topFocus look for a candidate at the top of the bounds if topFocus is true, - * or at the bottom of the bounds if topFocus is false - * @param top the top offset of the bounds in which a focusable must be - * found (the fading edge is assumed to start at this position) - * @param preferredFocusable the View that has highest priority and will be - * returned if it is within my bounds (null is valid) - * @return the next focusable component in the bounds or null if none can be found - */ - private View findFocusableViewInMyBounds(final boolean topFocus, - final int top, View preferredFocusable) { - /* - * The fading edge's transparent side should be considered for focus - * since it's mostly visible, so we divide the actual fading edge length - * by 2. - */ - final int fadingEdgeLength = getVerticalFadingEdgeLength() / 2; - final int topWithoutFadingEdge = top + fadingEdgeLength; - final int bottomWithoutFadingEdge = top + getHeight() - fadingEdgeLength; - - if ((preferredFocusable != null) - && (preferredFocusable.getTop() < bottomWithoutFadingEdge) - && (preferredFocusable.getBottom() > topWithoutFadingEdge)) { - return preferredFocusable; - } - - return findFocusableViewInBounds(topFocus, topWithoutFadingEdge, - bottomWithoutFadingEdge); - } - /** *

* Finds the next focusable component that fits in the specified bounds. @@ -1208,10 +1174,10 @@ public class ScrollView extends FrameLayout { } } - awakenScrollBars(); - - // Keep on drawing until the animation has finished. - postInvalidate(); + if (!awakenScrollBars()) { + // Keep on drawing until the animation has finished. + invalidate(); + } } else { if (mFlingStrictSpan != null) { mFlingStrictSpan.finish(); @@ -1438,7 +1404,7 @@ public class ScrollView extends FrameLayout { /** * Return true if child is a descendant of parent, (or equal to the parent). */ - private boolean isViewDescendantOf(View child, View parent) { + private static boolean isViewDescendantOf(View child, View parent) { if (child == parent) { return true; } @@ -1462,8 +1428,6 @@ public class ScrollView extends FrameLayout { mScroller.fling(mScrollX, mScrollY, 0, velocityY, 0, 0, 0, Math.max(0, bottom - height), 0, height/2); - final boolean movingDown = velocityY > 0; - if (mFlingStrictSpan == null) { mFlingStrictSpan = StrictMode.enterCriticalSpan("ScrollView-fling"); } @@ -1554,7 +1518,7 @@ public class ScrollView extends FrameLayout { } } - private int clamp(int n, int my, int child) { + private static int clamp(int n, int my, int child) { if (my >= child || n < 0) { /* my >= child is this case: * |--------------- me ---------------|