Improve rendering
This commit is contained in:
parent
0e212539e9
commit
9ffeecc584
@ -9,6 +9,7 @@ import android.util.AttributeSet;
|
|||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.animation.Animation;
|
import android.view.animation.Animation;
|
||||||
|
import android.view.animation.Animation.AnimationListener;
|
||||||
import android.view.animation.DecelerateInterpolator;
|
import android.view.animation.DecelerateInterpolator;
|
||||||
import android.view.animation.Transformation;
|
import android.view.animation.Transformation;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
@ -97,11 +98,7 @@ public class AnimatedProgressBar extends LinearLayout {
|
|||||||
mProgressView.getLayoutParams().width = width;
|
mProgressView.getLayoutParams().width = width;
|
||||||
mProgressView.requestLayout();
|
mProgressView.requestLayout();
|
||||||
}
|
}
|
||||||
if ((1.0f - interpolatedTime) < 0.0005) {
|
mProgressView.invalidate();
|
||||||
if (mProgress >= 100) {
|
|
||||||
fadeOut();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -109,7 +106,25 @@ public class AnimatedProgressBar extends LinearLayout {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
mAnimation.setAnimationListener(new AnimationListener(){
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAnimationStart(Animation animation) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAnimationEnd(Animation animation) {
|
||||||
|
if (mProgress >= 100) {
|
||||||
|
fadeOut();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAnimationRepeat(Animation animation) {
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
mAnimation.setDuration(300);
|
mAnimation.setDuration(300);
|
||||||
mAnimation.setInterpolator(new DecelerateInterpolator());
|
mAnimation.setInterpolator(new DecelerateInterpolator());
|
||||||
}
|
}
|
||||||
@ -155,9 +170,7 @@ public class AnimatedProgressBar extends LinearLayout {
|
|||||||
initialWidth = 0;
|
initialWidth = 0;
|
||||||
|
|
||||||
} else if (progress == mProgress) { // we don't need to go any farther if the progress is unchanged
|
} else if (progress == mProgress) { // we don't need to go any farther if the progress is unchanged
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mProgress = progress; // save the progress
|
mProgress = progress; // save the progress
|
||||||
@ -178,6 +191,7 @@ public class AnimatedProgressBar extends LinearLayout {
|
|||||||
mInitialWidth = initialWidth;
|
mInitialWidth = initialWidth;
|
||||||
mMaxWidth = maxWidth;
|
mMaxWidth = maxWidth;
|
||||||
mDeltaWidth = deltaWidth;
|
mDeltaWidth = deltaWidth;
|
||||||
|
mAnimation.reset();
|
||||||
mProgressView.startAnimation(mAnimation);
|
mProgressView.startAnimation(mAnimation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user