本文整理汇总了Java中android.animation.ObjectAnimator.addListener方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectAnimator.addListener方法的具体用法?Java ObjectAnimator.addListener怎么用?Java ObjectAnimator.addListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.animation.ObjectAnimator
的用法示例。
在下文中一共展示了ObjectAnimator.addListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showContent
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
@Override public void showContent() {
if (adapter.getItemCount() == 0) {
if (isRestoringViewState()) {
emptyView.setVisibility(View.VISIBLE);
} else {
ObjectAnimator anim = ObjectAnimator.ofFloat(emptyView, "alpha", 0f, 1f).setDuration(300);
anim.setStartDelay(250);
anim.addListener(new AnimatorListenerAdapter() {
@Override public void onAnimationStart(Animator animation) {
emptyView.setVisibility(View.VISIBLE);
}
});
anim.start();
}
} else {
emptyView.setVisibility(View.GONE);
}
super.showContent();
}
示例2: startSecondAnimation
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
public void startSecondAnimation(View view) {
ObjectAnimator rotationXAnimation = ObjectAnimator.ofFloat(mView1, "rotationX", 0f, 25f);
ObjectAnimator alphaAnimation = ObjectAnimator.ofFloat(mView1, "alpha", 0.5f, 1f);
ObjectAnimator scaleXAnimation = ObjectAnimator.ofFloat(mView1, "scaleX", 0.8f, 1f);
ObjectAnimator scaleYAnimation = ObjectAnimator.ofFloat(mView1, "scaleY", 0.8f, 1f);
ObjectAnimator translationYAnimation = ObjectAnimator.ofFloat(mView1, "translationY", -0.1f * mView1.getHeight(), 0f);
ObjectAnimator rerotationXAnimation = ObjectAnimator.ofFloat(mView1, "rotationX", 25f, 0f);
rerotationXAnimation.setStartDelay(200);
ObjectAnimator translationYAnimation2 = ObjectAnimator.ofFloat(mView2, "translationY", 0, mView2.getHeight());
translationYAnimation2.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
mView2.setVisibility(View.INVISIBLE);
}
});
AnimatorSet as = new AnimatorSet();
as.playTogether(rotationXAnimation, alphaAnimation, scaleXAnimation, scaleYAnimation,
translationYAnimation,
rerotationXAnimation, translationYAnimation2);
as.setDuration(200);
as.start();
}
示例3: startSaturationAnimation
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
private void startSaturationAnimation(Context context, final AppCompatImageView target) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
target.setHasTransientState(true);
final AnimUtils.ObservableColorMatrix matrix = new AnimUtils.ObservableColorMatrix();
final ObjectAnimator saturation = ObjectAnimator.ofFloat(
matrix, AnimUtils.ObservableColorMatrix.SATURATION, 0f, 1f);
saturation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
target.setColorFilter(new ColorMatrixColorFilter(matrix));
}
});
saturation.setDuration(2000);
saturation.setInterpolator(AnimUtils.getFastOutSlowInInterpolator(context));
saturation.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
target.clearColorFilter();
target.setHasTransientState(false);
}
});
saturation.start();
}
}
示例4: animateLayoutChange
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
private void animateLayoutChange(@Nullable final View previousView) {
if (previousView == null) {
getView(mViewState).setVisibility(View.VISIBLE);
return;
}
previousView.setVisibility(View.VISIBLE);
ObjectAnimator anim = ObjectAnimator.ofFloat(previousView, "alpha", 1.0f, 0.0f).setDuration(250L);
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
previousView.setVisibility(View.GONE);
getView(mViewState).setVisibility(View.VISIBLE);
ObjectAnimator.ofFloat(getView(mViewState), "alpha", 0.0f, 1.0f).setDuration(250L).start();
}
});
anim.start();
}
示例5: hideFromWindow
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
private void hideFromWindow(boolean animate) {
try {
if (baseView != null && baseView.getWindowToken() != null) {
if (animate) {
int h = baseView.getHeight();
ObjectAnimator oa = ObjectAnimator.ofFloat(baseView, "translationY", 0.0f, (float) (-h));
oa.setDuration(250);
oa.addListener(new ShowHideAnimation());
oa.start();
return;
}
((Activity) this.context).getWindowManager().removeViewImmediate(baseView);
baseView = null;
}
} catch (Exception ignored) {
}
}
示例6: addRow
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
public void addRow(View view) {
mButton.setEnabled(false);
mItemNum++;
ListItemObject obj = mValues[mItemNum % mValues.length];
final ListItemObject newObj = new ListItemObject(obj.getTitle(), obj.getImgResource(),
mCellHeight);
boolean shouldAnimateInNewImage = mListView.shouldAnimateInNewImage();
if (!shouldAnimateInNewImage) {
mListView.addRow(newObj);
return;
}
mListView.setEnabled(false);
ObjectAnimator animator = mRoundView.getScalingAnimator();
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationRepeat(Animator animation) {
mListView.addRow(newObj);
}
});
animator.start();
}
示例7: waterLoggingAlpha
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
public static void waterLoggingAlpha(final View view, final Animator.AnimatorListener listener) {
ObjectAnimator anim = ObjectAnimator.ofFloat(view, "alpha", 0.1f, 1f);
anim.setDuration(1200);// 动画持续时间
if(listener!=null) {
anim.addListener(listener);
}
anim.start();
}
示例8: fadeAndRemoveEmptyScreen
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
private void fadeAndRemoveEmptyScreen(int delay, int duration, final Runnable onComplete,
final boolean stripEmptyScreens) {
// XXX: Do we need to update LM workspace screens below?
PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 0f);
PropertyValuesHolder bgAlpha = PropertyValuesHolder.ofFloat("backgroundAlpha", 0f);
final CellLayout cl = mWorkspaceScreens.get(EXTRA_EMPTY_SCREEN_ID);
mRemoveEmptyScreenRunnable = new Runnable() {
@Override
public void run() {
if (hasExtraEmptyScreen()) {
mWorkspaceScreens.remove(EXTRA_EMPTY_SCREEN_ID);
mScreenOrder.remove(EXTRA_EMPTY_SCREEN_ID);
removeView(cl);
if (stripEmptyScreens) {
stripEmptyScreens();
}
// Update the page indicator to reflect the removed page.
showPageIndicatorAtCurrentScroll();
}
}
};
ObjectAnimator oa = ObjectAnimator.ofPropertyValuesHolder(cl, alpha, bgAlpha);
oa.setDuration(duration);
oa.setStartDelay(delay);
oa.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (mRemoveEmptyScreenRunnable != null) {
mRemoveEmptyScreenRunnable.run();
}
if (onComplete != null) {
onComplete.run();
}
}
});
oa.start();
}
示例9: hideBottomBar
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
@Override
public void hideBottomBar() {
// 下移动画
ObjectAnimator animator = ObjectAnimator.ofFloat(mRlBottomBar, "translationY", SizeUtils.dp2px(56));
animator.setDuration(300);
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mRlBottomBar.setVisibility(View.GONE);
}
});
animator.start();
}
示例10: shrinkAndFadeIn
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
public void shrinkAndFadeIn(boolean animate) {
final CellLayout cl = (CellLayout) getParent().getParent();
((CellLayout.LayoutParams) getLayoutParams()).canReorder = true;
// We remove and re-draw the FolderIcon in-case it has changed
final PreviewImageView previewImage = PreviewImageView.get(getContext());
previewImage.removeFromParent();
copyToPreview(previewImage);
if (cl != null) {
cl.clearFolderLeaveBehind();
}
ObjectAnimator oa = LauncherAnimUtils.ofViewAlphaAndScale(previewImage, 1, 1, 1);
oa.setDuration(getResources().getInteger(R.integer.config_folderExpandDuration));
oa.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (cl != null) {
// Remove the ImageView copy of the FolderIcon and make the original visible.
previewImage.removeFromParent();
setVisibility(View.VISIBLE);
}
}
});
oa.start();
if (!animate) {
oa.end();
}
}
示例11: startFadeInAnimator
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
public static void startFadeInAnimator(final View view) {
ObjectAnimator fadeAnimator = ObjectAnimator.ofFloat(view, View.ALPHA, 0, 1);
fadeAnimator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
super.onAnimationStart(animation);
view.setVisibility(View.VISIBLE);
}
});
fadeAnimator.setDuration(150);
fadeAnimator.start();
}
示例12: enterSoftware
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
private void enterSoftware() {
cancelAnimations();
mGlowAlpha = mGlowAlphaMax;
ObjectAnimator scaleAnimator = ObjectAnimator.ofFloat(this, "glowScale",
0f, GLOW_MAX_SCALE_FACTOR);
scaleAnimator.setInterpolator(mInterpolator);
scaleAnimator.setDuration(ANIMATION_DURATION_SCALE);
scaleAnimator.addListener(mAnimatorListener);
scaleAnimator.start();
mRunningAnimations.add(scaleAnimator);
}
示例13: exitSoftware
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
private void exitSoftware() {
ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(this, "glowAlpha", mGlowAlpha, 0f);
alphaAnimator.setInterpolator(mAlphaExitInterpolator);
alphaAnimator.setDuration(ANIMATION_DURATION_FADE);
alphaAnimator.addListener(mAnimatorListener);
alphaAnimator.start();
mRunningAnimations.add(alphaAnimator);
}
示例14: introAnimate
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
static ObjectAnimator introAnimate(final DepthLayout target, final float moveY, final float customElevation, long delay, int subtractDelay)
{
target.setPivotY(getDistanceToCenter(target));
target.setPivotX(getDistanceToCenterX(target));
target.setCameraDistance(10000 * target.getResources().getDisplayMetrics().density);
ObjectAnimator translationY2 = ObjectAnimator.ofFloat(target, View.TRANSLATION_Y, target.getResources().getDisplayMetrics().heightPixels, -moveY * target.getResources().getDisplayMetrics().density).setDuration(800);
translationY2.setInterpolator(new ExpoOut());
translationY2.setStartDelay(700 + subtractDelay);
translationY2.start();
target.setTranslationY(target.getResources().getDisplayMetrics().heightPixels);
ObjectAnimator translationX2 = ObjectAnimator.ofFloat(target, View.TRANSLATION_X, -target.getResources().getDisplayMetrics().widthPixels, 0).setDuration(800);
translationX2.setInterpolator(new ExpoOut());
translationX2.setStartDelay(700 + subtractDelay);
translationX2.start();
target.setTranslationX(-target.getResources().getDisplayMetrics().widthPixels);
ObjectAnimator translationY = ObjectAnimator.ofFloat(target, View.TRANSLATION_Y, 0).setDuration(700);
translationY.setInterpolator(new BackOut());
translationY.setStartDelay(700 + 800);
translationY.start();
ObjectAnimator rotationX = ObjectAnimator.ofFloat(target, View.ROTATION_X, TARGET_ROTATION_X, 0).setDuration(1000);
rotationX.setInterpolator(new QuintInOut());
rotationX.setStartDelay(700 + FISRTDELAY + subtractDelay);
rotationX.start();
target.setRotationX(TARGET_ROTATION_X);
ObjectAnimator elevation = ObjectAnimator.ofFloat(target, "CustomShadowElevation", customElevation * target.getResources().getDisplayMetrics().density, target.getCustomShadowElevation()).setDuration(1000);
elevation.setInterpolator(new QuintInOut());
elevation.setStartDelay(700 + FISRTDELAY + subtractDelay * 2);
elevation.start();
target.setCustomShadowElevation(customElevation * target.getResources().getDisplayMetrics().density);
ObjectAnimator scaleX = ObjectAnimator.ofFloat(target, View.SCALE_X, TARGET_SCALE, target.getScaleX()).setDuration(1000);
scaleX.setInterpolator(new CircInOut());
scaleX.setStartDelay(700 + FISRTDELAY + subtractDelay);
scaleX.start();
target.setScaleX(TARGET_SCALE);
ObjectAnimator scaleY = ObjectAnimator.ofFloat(target, View.SCALE_Y, TARGET_SCALE, target.getScaleY()).setDuration(1000);
scaleY.setInterpolator(new CircInOut());
scaleY.setStartDelay(700 + FISRTDELAY + subtractDelay);
scaleY.start();
target.setScaleY(TARGET_SCALE);
ObjectAnimator rotation = ObjectAnimator.ofFloat(target, View.ROTATION, TARGET_ROTATION, 0).setDuration(1400);
rotation.setInterpolator(new QuadInOut());
rotation.setStartDelay(FISRTDELAY + subtractDelay);
rotation.start();
target.setRotation(TARGET_ROTATION);
rotation.addListener(getShowStatusBarListener(target));
return scaleY;
}
示例15: revertFromMenu
import android.animation.ObjectAnimator; //导入方法依赖的package包/类
static ObjectAnimator revertFromMenu(final DepthLayout target, final float customElevation, int subtractDelay, float targetElevation)
{
target.setPivotY(getDistanceToCenter(target));
target.setPivotX(getDistanceToCenterX(target));
target.setCameraDistance(10000 * target.getResources().getDisplayMetrics().density);
ObjectAnimator translationY = ObjectAnimator.ofFloat(target, View.TRANSLATION_Y, 0).setDuration(700);
translationY.setInterpolator(new BackOut());
translationY.setStartDelay(250 + FISRTDELAY + subtractDelay);
translationY.start();
ObjectAnimator rotationX = ObjectAnimator.ofFloat(target, View.ROTATION_X, target.getRotationX(), 0).setDuration(1000);
rotationX.setInterpolator(new QuintInOut());
rotationX.setStartDelay(FISRTDELAY + subtractDelay);
rotationX.start();
target.setRotationX(TARGET_ROTATION_X);
ObjectAnimator elevation = ObjectAnimator.ofFloat(target, "CustomShadowElevation", target.getCustomShadowElevation(), targetElevation * target.getResources().getDisplayMetrics().density).setDuration(1000);
elevation.setInterpolator(new QuintInOut());
elevation.setStartDelay(FISRTDELAY + subtractDelay * 2);
elevation.start();
target.setCustomShadowElevation(customElevation * target.getResources().getDisplayMetrics().density);
ObjectAnimator scaleX = ObjectAnimator.ofFloat(target, View.SCALE_X, target.getScaleX(), 1f).setDuration(1000);
scaleX.setInterpolator(new CircInOut());
scaleX.setStartDelay(FISRTDELAY + subtractDelay);
scaleX.start();
target.setScaleX(TARGET_SCALE);
ObjectAnimator scaleY = ObjectAnimator.ofFloat(target, View.SCALE_Y, target.getScaleY(), 1f).setDuration(1000);
scaleY.setInterpolator(new CircInOut());
scaleY.setStartDelay(FISRTDELAY + subtractDelay);
scaleY.start();
target.setScaleY(TARGET_SCALE);
ObjectAnimator rotation = ObjectAnimator.ofFloat(target, View.ROTATION, target.getRotation(), 0).setDuration(1100);
rotation.setInterpolator(new QuintInOut());
rotation.setStartDelay(subtractDelay);
rotation.start();
rotation.addListener(getShowStatusBarListener(target));
return scaleY;
}