Merge "Remove unnecessary framework allocations" into jb-dev

This commit is contained in:
Romain Guy
2012-05-06 13:27:29 -07:00
committed by Android (Google) Code Review
2 changed files with 28 additions and 15 deletions

View File

@ -9187,7 +9187,7 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
}
public final boolean getLocalVisibleRect(Rect r) {
Point offset = new Point();
final Point offset = mAttachInfo != null ? mAttachInfo.mPoint : new Point();
if (getGlobalVisibleRect(r, offset)) {
r.offset(-offset.x, -offset.y); // make r local
return true;
@ -17023,6 +17023,11 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
*/
final boolean mDebugLayout = SystemProperties.getBoolean(DEBUG_LAYOUT_PROPERTY, false);
/**
* Point used to compute visible regions.
*/
final Point mPoint = new Point();
/**
* Creates a new set of attachment information with the specified
* events handler and thread.

View File

@ -211,6 +211,7 @@ public class ProgressBar extends View {
private boolean mOnlyIndeterminate;
private Transformation mTransformation;
private AlphaAnimation mAnimation;
private boolean mHasAnimation;
private Drawable mIndeterminateDrawable;
private Drawable mProgressDrawable;
private Drawable mCurrentDrawable;
@ -670,18 +671,14 @@ public class ProgressBar extends View {
if (mUiThreadId == Thread.currentThread().getId()) {
doRefreshProgress(id, progress, fromUser, true);
} else {
RefreshProgressRunnable r;
if (mRefreshProgressRunnable != null) {
// Use cached RefreshProgressRunnable if available
r = mRefreshProgressRunnable;
} else {
// Make a new one
r = new RefreshProgressRunnable();
if (mRefreshProgressRunnable == null) {
mRefreshProgressRunnable = new RefreshProgressRunnable();
}
final RefreshData rd = RefreshData.obtain(id, progress, fromUser);
mRefreshData.add(rd);
if (mAttached && !mRefreshIsPosted) {
post(r);
post(mRefreshProgressRunnable);
mRefreshIsPosted = true;
}
}
@ -860,14 +857,26 @@ public class ProgressBar extends View {
if (mIndeterminateDrawable instanceof Animatable) {
mShouldStartAnimationDrawable = true;
mAnimation = null;
mHasAnimation = false;
} else {
mHasAnimation = true;
if (mInterpolator == null) {
mInterpolator = new LinearInterpolator();
}
mTransformation = new Transformation();
mAnimation = new AlphaAnimation(0.0f, 1.0f);
if (mTransformation == null) {
mTransformation = new Transformation();
} else {
mTransformation.clear();
}
if (mAnimation == null) {
mAnimation = new AlphaAnimation(0.0f, 1.0f);
} else {
mAnimation.reset();
}
mAnimation.setRepeatMode(mBehavior);
mAnimation.setRepeatCount(Animation.INFINITE);
mAnimation.setDuration(mDuration);
@ -881,8 +890,7 @@ public class ProgressBar extends View {
* <p>Stop the indeterminate progress animation.</p>
*/
void stopAnimation() {
mAnimation = null;
mTransformation = null;
mHasAnimation = false;
if (mIndeterminateDrawable instanceof Animatable) {
((Animatable) mIndeterminateDrawable).stop();
mShouldStartAnimationDrawable = false;
@ -1030,7 +1038,7 @@ public class ProgressBar extends View {
canvas.save();
canvas.translate(mPaddingLeft, mPaddingTop);
long time = getDrawingTime();
if (mAnimation != null) {
if (mHasAnimation) {
mAnimation.getTransformation(time, mTransformation);
float scale = mTransformation.getAlpha();
try {