本文整理汇总了Java中com.nineoldandroids.animation.ValueAnimator.addListener方法的典型用法代码示例。如果您正苦于以下问题:Java ValueAnimator.addListener方法的具体用法?Java ValueAnimator.addListener怎么用?Java ValueAnimator.addListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.nineoldandroids.animation.ValueAnimator
的用法示例。
在下文中一共展示了ValueAnimator.addListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startAnimation
import com.nineoldandroids.animation.ValueAnimator; //导入方法依赖的package包/类
/**
* Starts the underlying Animator for a set of properties. We use a single animator that
* simply runs from 0 to 1, and then use that fractional value to set each property
* value accordingly.
*/
private void startAnimation() {
ValueAnimator animator = ValueAnimator.ofFloat(1.0f);
ArrayList<NameValuesHolder> nameValueList =
(ArrayList<NameValuesHolder>) mPendingAnimations.clone();
mPendingAnimations.clear();
int propertyMask = 0;
int propertyCount = nameValueList.size();
for (int i = 0; i < propertyCount; ++i) {
NameValuesHolder nameValuesHolder = nameValueList.get(i);
propertyMask |= nameValuesHolder.mNameConstant;
}
mAnimatorMap.put(animator, new PropertyBundle(propertyMask, nameValueList));
animator.addUpdateListener(mAnimatorEventListener);
animator.addListener(mAnimatorEventListener);
if (mStartDelaySet) {
animator.setStartDelay(mStartDelay);
}
if (mDurationSet) {
animator.setDuration(mDuration);
}
if (mInterpolatorSet) {
animator.setInterpolator(mInterpolator);
}
animator.start();
}
示例2: startAnimation
import com.nineoldandroids.animation.ValueAnimator; //导入方法依赖的package包/类
private void startAnimation() {
ValueAnimator animator = ValueAnimator.ofFloat(new float[]{1.0f});
ArrayList<NameValuesHolder> nameValueList = (ArrayList) this.mPendingAnimations.clone();
this.mPendingAnimations.clear();
int propertyMask = 0;
for (int i = 0; i < nameValueList.size(); i++) {
propertyMask |= ((NameValuesHolder) nameValueList.get(i)).mNameConstant;
}
this.mAnimatorMap.put(animator, new PropertyBundle(propertyMask, nameValueList));
animator.addUpdateListener(this.mAnimatorEventListener);
animator.addListener(this.mAnimatorEventListener);
if (this.mStartDelaySet) {
animator.setStartDelay(this.mStartDelay);
}
if (this.mDurationSet) {
animator.setDuration(this.mDuration);
}
if (this.mInterpolatorSet) {
animator.setInterpolator(this.mInterpolator);
}
animator.start();
}
示例3: animateCirlce
import com.nineoldandroids.animation.ValueAnimator; //导入方法依赖的package包/类
/**
* Internal void to start the circles animation.
* <p>
* when this void is called the circles radius would be updated by a
* {@link ValueAnimator} and then it will call the {@link View}'s
* invalidate() void witch calls the onDraw void each time so a bigger
* circle would be drawn each time till the cirlce's fill the whole screen.
* </p>
*/
private void animateCirlce() {
if (circles_fill_type == CIRLCES_FILL_HEIGHT_TYPE) {
circle_max_radius = screen_height + (screen_height / 4);
} else {
circle_max_radius = screen_width + (screen_width / 4);
}
ValueAnimator va = ValueAnimator.ofInt(0, circle_max_radius / 3);
va.setDuration(1000);
va.addListener(this);
va.setInterpolator(new AccelerateInterpolator());
va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
public void onAnimationUpdate(ValueAnimator animation) {
int value = (int) animation.getAnimatedValue();
circle_radius = value * 3;
invalidate();
}
});
va.start();
}
示例4: animateRect
import com.nineoldandroids.animation.ValueAnimator; //导入方法依赖的package包/类
/**
* Internal void to start the rectangle animation.
* <p>
* when this void is called the space at the top of the rectangle would be
* updated by a {@link ValueAnimator} and then it will call the {@link View}
* 's invalidate() void witch calls the onDraw void each time so a bigger
* rectangle would be drawn each time till the it the rectangles height is
* enough
* </p>
*/
private void animateRect() {
ValueAnimator va = ValueAnimator.ofInt(rect_space_top / 2,
screen_height / 2);
va.setDuration(500);
va.addListener(this);
va.setInterpolator(new DecelerateInterpolator());
va.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
public void onAnimationUpdate(ValueAnimator animation) {
int value = ((int) animation.getAnimatedValue()) * 2;
int rect_top = -((value - rect_space_top) - screen_height);
rect.top = rect_top;
invalidate();
}
});
va.start();
}
示例5: performRemovalIfNecessary
import com.nineoldandroids.animation.ValueAnimator; //导入方法依赖的package包/类
private void performRemovalIfNecessary() {
if (mCurrentRemovedId == -1) {
return;
}
ContextualUndoView currentRemovedView = getCurrentRemovedView(mCurrentRemovedView, mCurrentRemovedId);
if (currentRemovedView != null) {
ValueAnimator animator = ValueAnimator.ofInt(currentRemovedView.getHeight(), 1).setDuration(ANIMATION_DURATION);
RemoveViewAnimatorListenerAdapter listener = new RemoveViewAnimatorListenerAdapter(currentRemovedView, mCurrentRemovedId);
RemoveViewAnimatorUpdateListener updateListener = new RemoveViewAnimatorUpdateListener(listener);
animator.addListener(listener);
animator.addUpdateListener(updateListener);
animator.start();
} else {
// The hard way.
deleteItemGivenId(mCurrentRemovedId);
}
clearCurrentRemovedView();
}
示例6: performDismiss
import com.nineoldandroids.animation.ValueAnimator; //导入方法依赖的package包/类
protected void performDismiss(final PendingDismissData data) {
// Animate the dismissed list item to zero-height and fire the
// dismiss callback when all dismissed list item animations have
// completed.
final ViewGroup.LayoutParams lp = data.view.getLayoutParams();
final int originalHeight = data.view.getHeight();
ValueAnimator animator = ValueAnimator.ofInt(originalHeight, 1).setDuration(mAnimationTime);
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(final ValueAnimator valueAnimator) {
lp.height = (Integer) valueAnimator.getAnimatedValue();
data.view.setLayoutParams(lp);
}
});
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(final Animator animation) {
finalizeDismiss();
}
});
animator.start();
}
开发者ID:xulailing,项目名称:android-open-project-demo-master,代码行数:27,代码来源:SwipeDismissListViewTouchListener.java
示例7: performDismiss
import com.nineoldandroids.animation.ValueAnimator; //导入方法依赖的package包/类
/**
* Perform dismiss action
*
* @param dismissView View
* @param dismissPosition Position of list
*/
protected void performDismiss(final View dismissView, final int dismissPosition, boolean doPendingDismiss) {
final ViewGroup.LayoutParams lp = dismissView.getLayoutParams();
final int originalHeight = dismissView.getHeight();
ValueAnimator animator = ValueAnimator.ofInt(originalHeight, 1).setDuration(animationTime);
if (doPendingDismiss) {
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
--dismissAnimationRefCount;
if (dismissAnimationRefCount == 0) {
removePendingDismisses(originalHeight);
}
}
});
}
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
lp.height = (Integer) valueAnimator.getAnimatedValue();
dismissView.setLayoutParams(lp);
}
});
pendingDismisses.add(new PendingDismissData(dismissPosition, dismissView));
animator.start();
}
示例8: restoreStepperContent
import com.nineoldandroids.animation.ValueAnimator; //导入方法依赖的package包/类
/**
* 中间滑条恢复原位置
*/
private void restoreStepperContent() {
if (animationing) return;
animationing = true;
ValueAnimator restoreTranslateAnimation = ValueAnimator.ofFloat(tvStepperContent.getLeft(), (int) startStepperContentLeft);
restoreTranslateAnimation.setDuration(ANIMATIONDURATION);
restoreTranslateAnimation.addListener(this);
restoreTranslateAnimation.addUpdateListener(this);
restoreTranslateAnimation.setInterpolator(new AccelerateInterpolator());
restoreTranslateAnimation.start();
}
示例9: performDismiss
import com.nineoldandroids.animation.ValueAnimator; //导入方法依赖的package包/类
/**
* Animates the dismissed list item to zero-height and fires the dismiss callback when all dismissed list item animations have completed.
*
* @param view the dismissed {@link android.view.View}.
*/
protected void performDismiss(@NonNull final View view, final int position) {
mDismissedViews.add(view);
mDismissedPositions.add(position);
ValueAnimator animator = ValueAnimator.ofInt(view.getHeight(), 1).setDuration(mDismissAnimationTime);
animator.addUpdateListener(new DismissAnimatorUpdateListener(view));
animator.addListener(new DismissAnimatorListener());
animator.start();
mActiveDismissCount++;
}
示例10: animateCollapsing
import com.nineoldandroids.animation.ValueAnimator; //导入方法依赖的package包/类
public static void animateCollapsing(final View view) {
int origHeight = view.getHeight();
ValueAnimator animator = createHeightAnimator(view, origHeight, 0);
animator.addListener(
new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(final Animator animation) {
view.setVisibility(View.GONE);
}
}
);
animator.start();
}
示例11: run
import com.nineoldandroids.animation.ValueAnimator; //导入方法依赖的package包/类
@NonNull
public static Animator run(@NonNull final Runnable runnable) {
ValueAnimator animator = new ValueAnimator();
animator.setDuration(0);
animator.setIntValues(1);
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
runnable.run();
}
});
return animator;
}
示例12: performDismiss
import com.nineoldandroids.animation.ValueAnimator; //导入方法依赖的package包/类
private void performDismiss() {
// Animate the dismissed view to zero-height and then fire the dismiss callback.
// This triggers layout on each animation frame; in the future we may want to do something
// smarter and more performant.
final ViewGroup.LayoutParams lp = mView.getLayoutParams();
final int originalHeight = mView.getHeight();
ValueAnimator animator = ValueAnimator.ofInt(originalHeight, 1).setDuration(mAnimationTime);
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mCallback.onDismiss(mView, mToken);
// Reset view presentation
setAlpha(mView, 1f);
setTranslationX(mView, 0);
lp.height = originalHeight;
mView.setLayoutParams(lp);
}
});
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
lp.height = (Integer) valueAnimator.getAnimatedValue();
mView.setLayoutParams(lp);
}
});
animator.start();
}
示例13: performDismiss
import com.nineoldandroids.animation.ValueAnimator; //导入方法依赖的package包/类
private void performDismiss() {
// Animate the dismissed view to zero-height and then fire the dismiss
// callback.
// This triggers layout on each animation frame; in the future we may
// want to do something
// smarter and more performant.
final ViewGroup.LayoutParams lp = mView.getLayoutParams();
final int originalHeight = mView.getHeight();
ValueAnimator animator = ValueAnimator.ofInt(originalHeight, 1)
.setDuration(mAnimationTime);
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mCallback.onDismiss(mView, mToken);
// Reset view presentation
setAlpha(mView, 1f);
ViewHelper.setTranslationX(mView, 0);
// mView.setAlpha(1f);
// mView.setTranslationX(0);
lp.height = originalHeight;
mView.setLayoutParams(lp);
}
});
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
lp.height = (Integer) valueAnimator.getAnimatedValue();
mView.setLayoutParams(lp);
}
});
animator.start();
}
示例14: performDismiss
import com.nineoldandroids.animation.ValueAnimator; //导入方法依赖的package包/类
/**
* Animate the dismissed list item to zero-height and fire the dismiss callback when it finishes.
*
* @param dismissView ListView item to dismiss
* @param dismissPosition Position of dismissed item
*/
private void performDismiss(final View dismissView, final int dismissPosition) {
final ViewGroup.LayoutParams lp = dismissView.getLayoutParams();
final int originalHeight = lp.height;
ValueAnimator animator = ValueAnimator.ofInt(dismissView.getHeight(), 1).setDuration(mAnimationTime);
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
// Since the view is still a part of the ListView, we can't reset the animated
// properties yet; otherwise, the view would briefly reappear. Store the original
// height in the view's tag to flag it for the recycler. This is racy since the user
// could scroll the dismissed view off the screen, then back on the screen, before
// it's removed from the adapter, causing the dismissed view to briefly reappear.
dismissView.setTag(R.id.original_height, originalHeight);
mCallback.onDismiss(mListView, dismissPosition);
mDismissing = false;
}
});
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
lp.height = (Integer) valueAnimator.getAnimatedValue();
dismissView.setLayoutParams(lp);
}
});
animator.start();
}
示例15: performDismiss
import com.nineoldandroids.animation.ValueAnimator; //导入方法依赖的package包/类
private void performDismiss(final View dismissView, final int dismissPosition) {
// Animate the dismissed list item to zero-height and notifyTicket the dismiss callback when
// all dismissed list item animations have completed. This triggers layout on each animation
// frame; in the future we may want to do something smarter and more performant.
mPendingDismisses.add(new PendingDismissData(dismissPosition, dismissView));
if (dismissView != null) {
final ViewGroup.LayoutParams lp = dismissView.getLayoutParams();
final int originalHeight = dismissView.getHeight();
ValueAnimator animator = ValueAnimator.ofInt(originalHeight, 1).setDuration(mAnimationTime);
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
finishDismiss(originalHeight);
}
});
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
lp.height = (Integer) valueAnimator.getAnimatedValue();
dismissView.setLayoutParams(lp);
}
});
animator.start();
} else {
finishDismiss(0);
}
}