use of android.view.animation.Animation.AnimationListener in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class Utils method setViewShown.
private static void setViewShown(final View view, boolean shown, boolean animate) {
if (animate) {
Animation animation = AnimationUtils.loadAnimation(view.getContext(), shown ? android.R.anim.fade_in : android.R.anim.fade_out);
if (shown) {
view.setVisibility(View.VISIBLE);
} else {
animation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
view.setVisibility(View.INVISIBLE);
}
});
}
view.startAnimation(animation);
} else {
view.clearAnimation();
view.setVisibility(shown ? View.VISIBLE : View.INVISIBLE);
}
}
use of android.view.animation.Animation.AnimationListener in project smartmodule by carozhu.
the class ElasticScrollView method animation.
// 开启动画移动
public void animation() {
// 开启移动动画
TranslateAnimation ta = new TranslateAnimation(0, 0, 0, normal.top - inner.getTop());
ta.setDuration(200);
ta.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
animationFinish = false;
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
inner.clearAnimation();
// 设置回到正常的布局位置
inner.layout(normal.left, normal.top, normal.right, normal.bottom);
normal.setEmpty();
animationFinish = true;
}
});
inner.startAnimation(ta);
}
use of android.view.animation.Animation.AnimationListener in project JustAndroid by chinaltz.
the class AbAnimationUtil method playLandAnimation.
/**
* 跳动-落下动画.
*
* @param view the view
* @param offsetY the offset y
*/
private void playLandAnimation(final View view, final float offsetY) {
float originalY = -offsetY;
float finalY = 0;
AnimationSet animationSet = new AnimationSet(true);
animationSet.addAnimation(new TranslateAnimation(0, 0, originalY, finalY));
animationSet.setDuration(200);
animationSet.setInterpolator(new AccelerateInterpolator());
animationSet.setFillAfter(true);
animationSet.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
//两秒后再调
view.postDelayed(new Runnable() {
@Override
public void run() {
playJumpAnimation(view, offsetY);
}
}, 2000);
}
});
view.startAnimation(animationSet);
}
use of android.view.animation.Animation.AnimationListener in project JustAndroid by chinaltz.
the class AbAnimationUtil method playJumpAnimation.
/**
* 跳动-跳起动画.
*
* @param view the view
* @param offsetY the offset y
*/
private void playJumpAnimation(final View view, final float offsetY) {
float originalY = 0;
float finalY = -offsetY;
AnimationSet animationSet = new AnimationSet(true);
animationSet.addAnimation(new TranslateAnimation(0, 0, originalY, finalY));
animationSet.setDuration(300);
animationSet.setInterpolator(new AccelerateDecelerateInterpolator());
animationSet.setFillAfter(true);
animationSet.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
playLandAnimation(view, offsetY);
}
});
view.startAnimation(animationSet);
}
use of android.view.animation.Animation.AnimationListener in project android_frameworks_base by crdroidandroid.
the class SlidingTab method startAnimating.
void startAnimating(final boolean holdAfter) {
mAnimating = true;
final Animation trans1;
final Animation trans2;
final Slider slider = mCurrentSlider;
final Slider other = mOtherSlider;
final int dx;
final int dy;
if (isHorizontal()) {
int right = slider.tab.getRight();
int width = slider.tab.getWidth();
int left = slider.tab.getLeft();
int viewWidth = getWidth();
// how much of tab to show at the end of anim
int holdOffset = holdAfter ? 0 : width;
dx = slider == mRightSlider ? -(right + viewWidth - holdOffset) : (viewWidth - left) + viewWidth - holdOffset;
dy = 0;
} else {
int top = slider.tab.getTop();
int bottom = slider.tab.getBottom();
int height = slider.tab.getHeight();
int viewHeight = getHeight();
// how much of tab to show at end of anim
int holdOffset = holdAfter ? 0 : height;
dx = 0;
dy = slider == mRightSlider ? (top + viewHeight - holdOffset) : -((viewHeight - bottom) + viewHeight - holdOffset);
}
trans1 = new TranslateAnimation(0, dx, 0, dy);
trans1.setDuration(ANIM_DURATION);
trans1.setInterpolator(new LinearInterpolator());
trans1.setFillAfter(true);
trans2 = new TranslateAnimation(0, dx, 0, dy);
trans2.setDuration(ANIM_DURATION);
trans2.setInterpolator(new LinearInterpolator());
trans2.setFillAfter(true);
trans1.setAnimationListener(new AnimationListener() {
public void onAnimationEnd(Animation animation) {
Animation anim;
if (holdAfter) {
anim = new TranslateAnimation(dx, dx, dy, dy);
// plenty of time for transitions
anim.setDuration(1000);
mAnimating = false;
} else {
anim = new AlphaAnimation(0.5f, 1.0f);
anim.setDuration(ANIM_DURATION);
resetView();
}
anim.setAnimationListener(mAnimationDoneListener);
/* Animation can be the same for these since the animation just holds */
mLeftSlider.startAnimation(anim, anim);
mRightSlider.startAnimation(anim, anim);
}
public void onAnimationRepeat(Animation animation) {
}
public void onAnimationStart(Animation animation) {
}
});
slider.hideTarget();
slider.startAnimation(trans1, trans2);
}
Aggregations