summaryrefslogtreecommitdiffstats
path: root/core/java/android/widget/AdapterViewAnimator.java
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2010-08-19 16:49:52 -0700
committerAdam Cohen <adamcohen@google.com>2010-08-25 13:16:14 -0700
commit9b073948cfb84c0dd04f8a94ee1f7f263f027c83 (patch)
tree40a111e61be846c7eee74b9843f8a5f8b183a6bc /core/java/android/widget/AdapterViewAnimator.java
parent3c1fbf7ad2766a2942c326abd6692286949aee2f (diff)
downloadframeworks_base-9b073948cfb84c0dd04f8a94ee1f7f263f027c83.zip
frameworks_base-9b073948cfb84c0dd04f8a94ee1f7f263f027c83.tar.gz
frameworks_base-9b073948cfb84c0dd04f8a94ee1f7f263f027c83.tar.bz2
Cleanup and bug fixes in StackView
-> pushed functionality from AdapterViewAnimator to StackView -> only modifying clipping flags as far up the view hierarchy as needed -> still need framework level solution for drawing outside bounds ViewGroup touch dispatch temp fix -> Touch event was being modified and not reset in some code paths. Change-Id: I8135b62e2d73f239b9df407b0fa93bc434796989
Diffstat (limited to 'core/java/android/widget/AdapterViewAnimator.java')
-rw-r--r--core/java/android/widget/AdapterViewAnimator.java112
1 files changed, 6 insertions, 106 deletions
diff --git a/core/java/android/widget/AdapterViewAnimator.java b/core/java/android/widget/AdapterViewAnimator.java
index b6c8e47..e78c8b7 100644
--- a/core/java/android/widget/AdapterViewAnimator.java
+++ b/core/java/android/widget/AdapterViewAnimator.java
@@ -23,6 +23,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.res.TypedArray;
import android.graphics.Rect;
+import android.graphics.RectF;
import android.os.Handler;
import android.os.Looper;
import android.os.Parcel;
@@ -323,15 +324,13 @@ public abstract class AdapterViewAnimator extends AdapterView<Adapter>
return null;
}
- private LayoutParams createOrReuseLayoutParams(View v) {
+ LayoutParams createOrReuseLayoutParams(View v) {
final ViewGroup.LayoutParams currentLp = v.getLayoutParams();
- if (currentLp instanceof LayoutParams) {
+ if (currentLp instanceof ViewGroup.LayoutParams) {
LayoutParams lp = (LayoutParams) currentLp;
- lp.setHorizontalOffset(0);
- lp.setVerticalOffset(0);
return lp;
}
- return new LayoutParams(v);
+ return new ViewGroup.LayoutParams(0, 0);
}
void showOnly(int childIndex, boolean animate, boolean onLayout) {
@@ -472,10 +471,9 @@ public abstract class AdapterViewAnimator extends AdapterView<Adapter>
int childRight = mPaddingLeft + child.getMeasuredWidth();
int childBottom = mPaddingTop + child.getMeasuredHeight();
- LayoutParams lp = (LayoutParams) child.getLayoutParams();
- child.layout(mPaddingLeft + lp.horizontalOffset, mPaddingTop + lp.verticalOffset,
- childRight + lp.horizontalOffset, childBottom + lp.verticalOffset);
+ child.layout(mPaddingLeft, mPaddingTop,
+ childRight, childBottom);
}
mDataChanged = false;
}
@@ -738,102 +736,4 @@ public abstract class AdapterViewAnimator extends AdapterView<Adapter>
setAdapter(mRemoteViewsAdapter);
}
}
-
- private final Rect dirtyRect = new Rect();
- @Override
- public void removeViewInLayout(View view) {
- // TODO: need to investigate this block a bit more
- // and perhaps fix some other invalidations issues.
- View parent = null;
- view.setVisibility(INVISIBLE);
- if (view.getLayoutParams() instanceof LayoutParams) {
- LayoutParams lp = (LayoutParams) view.getLayoutParams();
- parent = lp.getParentAndDirtyRegion(dirtyRect);
- }
-
- super.removeViewInLayout(view);
-
- if (parent != null)
- parent.invalidate(dirtyRect.left, dirtyRect.top, dirtyRect.right, dirtyRect.bottom);
- }
-
- static class LayoutParams extends ViewGroup.LayoutParams {
- int horizontalOffset;
- int verticalOffset;
- View mView;
-
- LayoutParams(View view) {
- super(0, 0);
- horizontalOffset = 0;
- verticalOffset = 0;
- mView = view;
- }
-
- LayoutParams(Context c, AttributeSet attrs) {
- super(c, attrs);
- horizontalOffset = 0;
- verticalOffset = 0;
- }
-
- private Rect parentRect = new Rect();
- void invalidateGlobalRegion(View v, Rect r) {
- View p = v;
- boolean firstPass = true;
- parentRect.set(0, 0, 0, 0);
- while (p.getParent() != null && p.getParent() instanceof View
- && !parentRect.contains(r)) {
- if (!firstPass) r.offset(p.getLeft() - p.getScrollX(), p.getTop() - p.getScrollY());
- firstPass = false;
- p = (View) p.getParent();
- parentRect.set(p.getLeft() - p.getScrollX(), p.getTop() - p.getScrollY(),
- p.getRight() - p.getScrollX(), p.getBottom() - p.getScrollY());
- }
- p.invalidate(r.left, r.top, r.right, r.bottom);
- }
-
- public View getParentAndDirtyRegion(Rect globalRect) {
- globalRect.set(mView.getLeft(), mView.getTop(), mView.getRight(), mView.getBottom());
- View p = mView;
- boolean firstPass = true;
- parentRect.set(0, 0, 0, 0);
- while (p.getParent() != null && p.getParent() instanceof View
- && !parentRect.contains(globalRect)) {
- if (!firstPass) {
- globalRect.offset(p.getLeft() - p.getScrollX(), p.getTop() - p.getScrollY());
- }
-
- firstPass = false;
- p = (View) p.getParent();
- parentRect.set(p.getLeft() - p.getScrollX(), p.getTop() - p.getScrollY(),
- p.getRight() - p.getScrollX(), p.getBottom() - p.getScrollY());
- }
- return p;
- }
-
- private Rect invalidateRect = new Rect();
- // This is public so that PropertyAnimator can access it
- public void setVerticalOffset(int newVerticalOffset) {
- int offsetDelta = newVerticalOffset - verticalOffset;
- verticalOffset = newVerticalOffset;
- if (mView != null) {
- mView.requestLayout();
- int top = Math.min(mView.getTop() + offsetDelta, mView.getTop());
- int bottom = Math.max(mView.getBottom() + offsetDelta, mView.getBottom());
- invalidateRect.set(mView.getLeft(), top, mView.getRight(), bottom);
- invalidateGlobalRegion(mView, invalidateRect);
- }
- }
-
- public void setHorizontalOffset(int newHorizontalOffset) {
- int offsetDelta = newHorizontalOffset - horizontalOffset;
- horizontalOffset = newHorizontalOffset;
- if (mView != null) {
- mView.requestLayout();
- int left = Math.min(mView.getLeft() + offsetDelta, mView.getLeft());
- int right = Math.max(mView.getRight() + offsetDelta, mView.getRight());
- invalidateRect.set(left, mView.getTop(), right, mView.getBottom());
- invalidateGlobalRegion(mView, invalidateRect);
- }
- }
- }
}