summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRomain Guy <romainguy@android.com>2009-05-11 18:25:05 -0700
committerRomain Guy <romainguy@android.com>2009-05-11 18:25:05 -0700
commit6dfed24158b8fc9150abee23992db621cd82aa43 (patch)
tree7a6be7663a12f33cd9baf483743863604e5611f7
parent08f3b5261fc31813e35cf04225ed8260f8a3bbe0 (diff)
downloadframeworks_base-6dfed24158b8fc9150abee23992db621cd82aa43.zip
frameworks_base-6dfed24158b8fc9150abee23992db621cd82aa43.tar.gz
frameworks_base-6dfed24158b8fc9150abee23992db621cd82aa43.tar.bz2
Fixes 1844680. Interrupted scrolling could lead to rendering artifacts. The ListView was invalidating itself in opaque mode but before the drawing could happen, it was getting rid of its scrolling cache, thus becoming translucent again.
-rw-r--r--core/java/android/widget/AbsListView.java40
1 files changed, 24 insertions, 16 deletions
diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java
index ffb6785..4f503b4 100644
--- a/core/java/android/widget/AbsListView.java
+++ b/core/java/android/widget/AbsListView.java
@@ -433,7 +433,9 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
private InputConnection mDefInputConnection;
private InputConnectionWrapper mPublicInputConnection;
-
+
+ private Runnable mClearScrollingCache;
+
/**
* Interface definition for a callback to be invoked when the list or grid
* has been scrolled.
@@ -1947,7 +1949,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
if (y != mLastY) {
deltaY -= mMotionCorrection;
int incrementalDeltaY = mLastY != Integer.MIN_VALUE ? y - mLastY : deltaY;
- trackMotionScroll(deltaY, incrementalDeltaY, true);
+ trackMotionScroll(deltaY, incrementalDeltaY);
// Check to see if we have bumped into the scroll limit
View motionView = this.getChildAt(mMotionPosition - mFirstPosition);
@@ -2286,7 +2288,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
delta = Math.max(-(getHeight() - mPaddingBottom - mPaddingTop - 1), delta);
}
- trackMotionScroll(delta, delta, false);
+ trackMotionScroll(delta, delta);
// Check to see if we have bumped into the scroll limit
View motionView = getChildAt(mMotionPosition - mFirstPosition);
@@ -2323,16 +2325,23 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
}
private void clearScrollingCache() {
- if (mCachingStarted) {
- mCachingStarted = false;
- setChildrenDrawnWithCacheEnabled(false);
- if ((mPersistentDrawingCache & PERSISTENT_SCROLLING_CACHE) == 0) {
- setChildrenDrawingCacheEnabled(false);
- }
- if (!isAlwaysDrawnWithCacheEnabled()) {
- invalidate();
- }
+ if (mClearScrollingCache == null) {
+ mClearScrollingCache = new Runnable() {
+ public void run() {
+ if (mCachingStarted) {
+ mCachingStarted = false;
+ setChildrenDrawnWithCacheEnabled(false);
+ if ((mPersistentDrawingCache & PERSISTENT_SCROLLING_CACHE) == 0) {
+ setChildrenDrawingCacheEnabled(false);
+ }
+ if (!isAlwaysDrawnWithCacheEnabled()) {
+ invalidate();
+ }
+ }
+ }
+ };
}
+ post(mClearScrollingCache);
}
/**
@@ -2341,9 +2350,8 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
* @param deltaY Amount to offset mMotionView. This is the accumulated delta since the motion
* began. Positive numbers mean the user's finger is moving down the screen.
* @param incrementalDeltaY Change in deltaY from the previous event.
- * @param invalidate True to make this method call invalidate(), false otherwise.
*/
- void trackMotionScroll(int deltaY, int incrementalDeltaY, boolean invalidate) {
+ void trackMotionScroll(int deltaY, int incrementalDeltaY) {
final int childCount = getChildCount();
if (childCount == 0) {
return;
@@ -2377,7 +2385,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
if (spaceAbove >= absIncrementalDeltaY && spaceBelow >= absIncrementalDeltaY) {
hideSelector();
offsetChildrenTopAndBottom(incrementalDeltaY);
- if (invalidate) invalidate();
+ invalidate();
mMotionViewNewTop = mMotionViewOriginalTop + deltaY;
} else {
final int firstPosition = mFirstPosition;
@@ -2455,7 +2463,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
mFirstPosition += count;
}
- if (invalidate) invalidate();
+ invalidate();
fillGap(down);
mBlockLayoutRequests = false;