Merge "Code cleanup"

This commit is contained in:
Romain Guy
2012-03-20 13:52:35 -07:00
committed by Android (Google) Code Review
3 changed files with 25 additions and 58 deletions

View File

@@ -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();
}

View File

@@ -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;
}

View File

@@ -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;
}
/**
* <p>
* 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.
* </p>
*
* @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);
}
/**
* <p>
* 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 ---------------|