下面列出了android.view.animation.BounceInterpolator#android.animation.AnimatorListenerAdapter 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private static void slideUpNow(final View view, final int delay) {
view.setTranslationY(view.getWidth());
view.animate()
.translationY(100)
.alpha(1.0f)
.setDuration(500)
.setStartDelay(delay)
.setInterpolator(new AccelerateDecelerateInterpolator())
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
view.setVisibility(View.VISIBLE);
view.setAlpha(1.f);
}
});
}
public void closeAiUi(boolean isShowOther, boolean isShowRightIcon) {
this.menuState = X8AiFlyMenuEnum.ALL_ITEMS;
this.aiFlyBlank.setVisibility(8);
if (this.isShow) {
this.isShow = false;
ObjectAnimator translationRight = ObjectAnimator.ofFloat(this.contentView, "translationX", new float[]{0.0f, (float) this.width});
translationRight.setDuration(300);
translationRight.start();
translationRight.addListener(new AnimatorListenerAdapter() {
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
X8MainAiFlyController.this.rlAiFly.setVisibility(4);
X8MainAiFlyController.this.svAiItems.fullScroll(33);
X8MainAiFlyController.this.onCloseConfirmUi();
}
});
}
this.listener.onCloseAiUi(isShowOther, isShowRightIcon);
}
public void closeAiUi(boolean b) {
enableGesture(true);
if (this.isShow) {
this.isShow = false;
ObjectAnimator translationRight = ObjectAnimator.ofFloat(this.contentView, "translationX", new float[]{0.0f, (float) this.width});
translationRight.setDuration(300);
translationRight.start();
translationRight.addListener(new AnimatorListenerAdapter() {
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
X8MainCameraSettingController.this.rlCameraSetting.setVisibility(8);
X8MainCameraSettingController.this.curMenu = MenuMode.normal;
if (X8MainCameraSettingController.this.evShutterISOController != null) {
X8MainCameraSettingController.this.evShutterISOController.setCurModle();
}
}
});
}
if (this.cameraMainSetListener != null) {
this.cameraMainSetListener.showTopAndBottom(b);
}
if (this.takePhotoSettingContoller != null) {
this.takePhotoSettingContoller.closeUi();
}
}
public void closeNextUi() {
this.blank.setVisibility(8);
if (this.isNextShow) {
this.isNextShow = false;
ObjectAnimator translationRight = ObjectAnimator.ofFloat(this.nextRootView, "translationX", new float[]{0.0f, (float) this.width});
translationRight.setDuration(300);
translationRight.start();
translationRight.addListener(new AnimatorListenerAdapter() {
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
X8AiAerialPhotographExcuteController.this.nextRootView.setVisibility(8);
}
});
}
this.activity.taskFullScreen(false);
if (this.mX8AiAerialPhotographNextUi.isSaveData()) {
setSensity();
}
}
private void setEmojiTooltipVisible(boolean visible){
emojiTooltipVisible=visible;
if(tooltipAnim!=null)
tooltipAnim.cancel();
hintTextView.setVisibility(View.VISIBLE);
ObjectAnimator oa=ObjectAnimator.ofFloat(hintTextView, "alpha", visible ? 1 : 0);
oa.setDuration(300);
oa.setInterpolator(CubicBezierInterpolator.DEFAULT);
oa.addListener(new AnimatorListenerAdapter(){
@Override
public void onAnimationEnd(Animator animation){
tooltipAnim=null;
}
});
tooltipAnim=oa;
oa.start();
}
public void closeNextUi(final boolean b) {
this.blank.setVisibility(8);
if (this.isNextShow) {
this.isNextShow = false;
ObjectAnimator translationRight = ObjectAnimator.ofFloat(this.nextRootView, "translationX", new float[]{0.0f, (float) this.width});
translationRight.setDuration(300);
translationRight.start();
translationRight.addListener(new AnimatorListenerAdapter() {
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
X8AiAutoPhototExcuteController.this.nextRootView.setVisibility(8);
((ViewGroup) X8AiAutoPhototExcuteController.this.nextRootView).removeAllViews();
X8AiAutoPhototExcuteController.this.imgBack.setVisibility(0);
X8AiAutoPhototExcuteController.this.flagSmall.setVisibility(0);
if (b) {
X8AiAutoPhototExcuteController.this.imgNext.setVisibility(0);
}
}
});
}
}
public void hide() {
post(new Runnable() {
@Override
public void run() {
ObjectAnimator objectAnimator = ObjectAnimator.ofInt(IntroCard.this, "height", 0);
objectAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
setVisibility(GONE);
if (mListener != null) {
mListener.onClick(IntroCard.this);
}
}
});
objectAnimator.setDuration(500);
objectAnimator.setInterpolator(new AnticipateInterpolator());
objectAnimator.setRepeatCount(0);
objectAnimator.start();
}
});
}
public void closeNextUi(final boolean b) {
this.blank.setVisibility(8);
this.imgBack.setVisibility(0);
if (this.isNextShow) {
this.isNextShow = false;
ObjectAnimator translationRight = ObjectAnimator.ofFloat(this.nextRootView, "translationX", new float[]{0.0f, (float) this.width});
translationRight.setDuration(300);
translationRight.start();
translationRight.addListener(new AnimatorListenerAdapter() {
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
X8AiLineExcuteController.this.nextRootView.setVisibility(8);
((ViewGroup) X8AiLineExcuteController.this.nextRootView).removeAllViews();
X8AiLineExcuteController.this.imgBack.setVisibility(0);
X8AiLineExcuteController.this.flagSmall.setVisibility(0);
if (b) {
X8AiLineExcuteController.this.imgNext.setVisibility(0);
}
}
});
}
}
private void createAnimators() {
alphaDownAnimator = ObjectAnimator.ofFloat(mView.get(), "alpha", config.getAlpha());
alphaUpAnimator = ObjectAnimator.ofFloat(mView.get(), "alpha", 1.0f);
scaleXDownAnimator = ObjectAnimator.ofFloat(mView.get(), "scaleX", config.getScaleDown());
scaleXUpAnimator = ObjectAnimator.ofFloat(mView.get(), "scaleX", 1.0f);
scaleYDownAnimator = ObjectAnimator.ofFloat(mView.get(), "scaleY", config.getScaleDown());
scaleYUpAnimator = ObjectAnimator.ofFloat(mView.get(), "scaleY", 1.0f);
downSet = new AnimatorSet();
downSet.setDuration(config.getDuration());
downSet.setInterpolator(new AccelerateInterpolator());
downSet.playTogether(alphaDownAnimator, scaleXDownAnimator, scaleYDownAnimator);
upSet = new AnimatorSet();
upSet.setDuration(config.getDuration());
upSet.setInterpolator(new FastOutSlowInInterpolator());
upSet.playTogether(alphaUpAnimator, scaleXUpAnimator, scaleYUpAnimator);
finalAnimationListener = new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
onClick(mView.get());
}
};
}
public void closeNextUi(final boolean b) {
this.blank.setVisibility(8);
if (this.isNextShow) {
this.isNextShow = false;
ObjectAnimator translationRight = ObjectAnimator.ofFloat(this.nextRootView, "translationX", new float[]{0.0f, (float) this.width});
translationRight.setDuration(300);
translationRight.start();
translationRight.addListener(new AnimatorListenerAdapter() {
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
X8AiScrewExcuteController.this.nextRootView.setVisibility(8);
((ViewGroup) X8AiScrewExcuteController.this.nextRootView).removeAllViews();
X8AiScrewExcuteController.this.imgBack.setVisibility(0);
X8AiScrewExcuteController.this.flagSmall.setVisibility(0);
if (b) {
X8AiScrewExcuteController.this.tvPoint.setVisibility(0);
}
}
});
}
}
public static void showIn(final View v) {
v.setVisibility(View.VISIBLE);
v.setAlpha(0f);
v.setTranslationY(v.getHeight());
v.animate()
.setDuration(200)
.translationY(0)
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
}
})
.alpha(1f)
.start();
}
/**
* Animate appearance of a view
*
* @param view View to animate
* @param toVisibility Visibility at the end of animation
* @param toAlpha Alpha at the end of animation
* @param duration Animation duration in ms
*/
public static void animateView(final View view, final int toVisibility, float toAlpha, int duration) {
boolean show = toVisibility == View.VISIBLE;
if (show) {
view.setAlpha(0);
}
view.setVisibility(View.VISIBLE);
view.animate()
.setDuration(duration)
.alpha(show ? toAlpha : 0)
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
view.setVisibility(toVisibility);
}
});
}
@Override
public void onBackPressed() {
if (isRestored) {
getFragmentManager().popBackStack();
} else {
// Perform a circular conceal, then pop this fragment off the back stack.
final FrameLayout view = ((FrameLayout) getView());
//noinspection ConstantConditions
Animator circularConceal = ViewUtils.createCircularConceal(mRevealCenter, mRevealWidth,
view, INTERPOLATOR);
circularConceal.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
view.setVisibility(View.GONE);
getFragmentManager().popBackStack();
}
});
circularConceal.start();
}
}
/**
* Animate appearance of a view
*
* @param view View to animate
* @param toVisibility Visibility at the end of animation
* @param toAlpha Alpha at the end of animation
* @param duration Animation duration in ms
*/
public static void animateView(final View view, final int toVisibility, float toAlpha, int duration) {
boolean show = toVisibility == View.VISIBLE;
if (show) {
view.setAlpha(0);
}
view.setVisibility(View.VISIBLE);
view.animate()
.setDuration(duration)
.alpha(show ? toAlpha : 0)
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
view.setVisibility(toVisibility);
}
});
}
/**
* 隐藏内容布局
*/
@SuppressLint("NewApi")
final void hideContentView() {
if (mContentView == null)
return;
mContentView.animate()
.translationY(getHeight() - mMonthView.getHeight())
.setDuration(220)
.setInterpolator(new LinearInterpolator())
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
mContentView.setVisibility(INVISIBLE);
mContentView.clearAnimation();
}
});
}
private void hideFloatingDateView(boolean animated) {
if (floatingDateView.getTag() != null && !currentFloatingDateOnScreen && (!scrollingFloatingDate || currentFloatingTopIsNotMessage)) {
floatingDateView.setTag(null);
if (animated) {
floatingDateAnimation = new AnimatorSet();
floatingDateAnimation.setDuration(150);
floatingDateAnimation.playTogether(ObjectAnimator.ofFloat(floatingDateView, "alpha", 0.0f));
floatingDateAnimation.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (animation.equals(floatingDateAnimation)) {
floatingDateAnimation = null;
}
}
});
floatingDateAnimation.setStartDelay(500);
floatingDateAnimation.start();
} else {
if (floatingDateAnimation != null) {
floatingDateAnimation.cancel();
floatingDateAnimation = null;
}
floatingDateView.setAlpha(0.0f);
}
}
}
/**
* This is a utility method used by subclasses to handle standard parts of
* setting up and running an Animator: it sets the {@link #getDuration()
* duration} and the {@link #getStartDelay() startDelay}, starts the
* animation, and, when the animator ends, calls {@link #end()}.
*
* @param animator The Animator to be run during this transition.
*
* @hide
*/
protected void animate(Animator animator) {
// TODO: maybe pass auto-end as a boolean parameter?
if (animator == null) {
end();
} else {
if (getDuration() >= 0) {
animator.setDuration(getDuration());
}
if (getStartDelay() >= 0) {
animator.setStartDelay(getStartDelay() + animator.getStartDelay());
}
if (getInterpolator() != null) {
animator.setInterpolator(getInterpolator());
}
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
end();
animation.removeListener(this);
}
});
animator.start();
}
}
@Override
public void addView(View child) {
TransitionAdapter adapter = switchView(child);
if (mHandler.hasMessages(MESSAGE_REMOVE_VIEW)) {
mHandler.removeMessages(MESSAGE_REMOVE_VIEW);
}
mValueAnimator = adapter.getAnimator();
mValueAnimator.setInterpolator(new AccelerateInterpolator());
mValueAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
sendRemoveViewMessage();
}
});
mValueAnimator.setInterpolator(new AccelerateInterpolator());
startAnimator();
}
public static void shakeView(final View view, final float x, final int num)
{
if (view == null)
{
return;
}
if (num == 6)
{
view.setTranslationX(0);
return;
}
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(ObjectAnimator.ofFloat(view, "translationX", AndroidUtilities.dp(x)));
animatorSet.setDuration(50);
animatorSet.addListener(new AnimatorListenerAdapter()
{
@Override
public void onAnimationEnd(Animator animation)
{
shakeView(view, num == 5 ? 0 : -x, num + 1);
}
});
animatorSet.start();
}
private void hideFloatingDateView(boolean animated) {
if (floatingDateView.getTag() != null && !currentFloatingDateOnScreen && (!scrollingFloatingDate || currentFloatingTopIsNotMessage)) {
floatingDateView.setTag(null);
if (animated) {
floatingDateAnimation = new AnimatorSet();
floatingDateAnimation.setDuration(150);
floatingDateAnimation.playTogether(ObjectAnimator.ofFloat(floatingDateView, "alpha", 0.0f));
floatingDateAnimation.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (animation.equals(floatingDateAnimation)) {
floatingDateAnimation = null;
}
}
});
floatingDateAnimation.setStartDelay(500);
floatingDateAnimation.start();
} else {
if (floatingDateAnimation != null) {
floatingDateAnimation.cancel();
floatingDateAnimation = null;
}
floatingDateView.setAlpha(0.0f);
}
}
}
private void initListener() {
mAnimatorListener = new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
//动画播放完毕, 移除本View
detachFromRootView();
if (mOnAnimationEndListener != null) {
mOnAnimationEndListener.onAnimationEnd();
}
isStarted = false;
}
};
mAnimatorUpdateListener = animation -> {
//更新圆的半径
mCurrentRadius = (int) (float) animation.getAnimatedValue() + mStartRadius;
postInvalidate();
};
}
@Override
public void run() {
valueTextView.setTag(null);
valueAnimation = new AnimatorSet();
valueAnimation.playTogether(
ObjectAnimator.ofFloat(valueTextView, "alpha", 0.0f),
ObjectAnimator.ofFloat(nameTextView, "alpha", 1.0f));
valueAnimation.setDuration(180);
valueAnimation.setInterpolator(new DecelerateInterpolator());
valueAnimation.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (animation.equals(valueAnimation)) {
valueAnimation = null;
}
}
});
valueAnimation.start();
}
private void scale(float ratio) {
if (scaleRatio == ratio) {
return;
}
if (scaleAnimator != null) {
scaleAnimator.cancel();
}
PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", scaleRatio, ratio);
PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", scaleRatio, ratio);
PropertyValuesHolder translationX = PropertyValuesHolder.ofFloat("translationX", 0);
PropertyValuesHolder translationY = PropertyValuesHolder.ofFloat("translationY", 0);
scaleAnimator = ObjectAnimator.ofPropertyValuesHolder(mVideoView, scaleX, scaleY, translationX, translationY);
scaleAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
animation.removeAllListeners();
scaleAnimator = null;
}
});
scaleAnimator.setDuration(150L).start();
scaleRatio = ratio;
}
private void initListener() {
mAnimatorListener = new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (mOnAnimationEndListener != null) {
mOnAnimationEndListener.onAnimationEnd();
}
isStarted = false;
//动画播放完毕, 移除本View
detachFromRootView();
}
};
mAnimatorUpdateListener = new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
//更新圆的半径
mCurrentRadius = (int) (float) animation.getAnimatedValue() + mStartRadius;
postInvalidate();
}
};
}
private void animateToCheckedState(boolean newCheckedState) {
isCheckAnimation = newCheckedState;
checkAnimator = ObjectAnimator.ofFloat(this, "progress", newCheckedState ? 1 : 0);
checkAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (animation.equals(checkAnimator)) {
checkAnimator = null;
}
if (!isChecked) {
checkedText = null;
}
}
});
checkAnimator.setDuration(300);
checkAnimator.start();
}
private void hideRecordedAudioPanel()
{
audioToSendPath = null;
audioToSend = null;
audioToSendMessageObject = null;
videoToSendMessageObject = null;
videoTimelineView.destroy();
AnimatorSet AnimatorSet = new AnimatorSet();
AnimatorSet.playTogether(
ObjectAnimator.ofFloat(recordedAudioPanel, "alpha", 0.0f)
);
AnimatorSet.setDuration(200);
AnimatorSet.addListener(new AnimatorListenerAdapter()
{
@Override
public void onAnimationEnd(Animator animation)
{
recordedAudioPanel.setVisibility(GONE);
}
});
AnimatorSet.start();
}
public void explode(Bitmap bitmap, Rect bound, long startDelay, final View view) {
if(bitmap == null || bitmap.isRecycled()){
return;
}
long currentDuration = customDuration;
final ExplosionAnimator explosion = new ExplosionAnimator(this, bitmap, bound);
explosion.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mExplosions.remove(animation);
if (view != null) {
view.setScaleX(1);
view.setScaleY(1);
view.setAlpha(1);
view.setOnClickListener(mOnClickListener);//set event
}
}
});
explosion.setStartDelay(startDelay);
explosion.setDuration(currentDuration);
mExplosions.add(explosion);
explosion.start();
}
private void setDimVisibility(final boolean visible) {
Animator animator;
if (visible) {
dimView.setVisibility(VISIBLE);
animator = ObjectAnimator.ofFloat(dimView, "alpha", 0.0f, 1.0f);
} else {
animator = ObjectAnimator.ofFloat(dimView, "alpha", 1.0f, 0.0f);
}
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (!visible) {
dimView.setVisibility(GONE);
}
}
});
animator.setDuration(200);
animator.start();
}
private void closeStickersView() {
if (stickersView == null || stickersView.getVisibility() != VISIBLE) {
return;
}
pickingSticker = false;
Animator a = ObjectAnimator.ofFloat(stickersView, "alpha", 1.0f, 0.0f);
a.setDuration(200);
a.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animator) {
stickersView.setVisibility(GONE);
}
});
a.start();
}
static void hide(final LuBottomMenu luBottomMenu, final long duration){
luBottomMenu.post(new Runnable() {
@Override
public void run() {
luBottomMenu.animate()
.setDuration(duration)
.translationY(luBottomMenu.getHeight())
.alpha(0f)
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
luBottomMenu.setVisibility(View.GONE);
}
}).start();
}
});
}