use of com.nineoldandroids.animation.ObjectAnimator in project ListViewAnimations by nhaarman.
the class AnimateAdditionAdapter method getView.
@Override
@NonNull
public View getView(final int position, @Nullable final View convertView, @NonNull final ViewGroup parent) {
final View view = super.getView(position, convertView, parent);
if (mInsertQueue.getActiveIndexes().contains(position)) {
int widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(ViewGroup.LayoutParams.MATCH_PARENT, View.MeasureSpec.AT_MOST);
int heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(ViewGroup.LayoutParams.WRAP_CONTENT, View.MeasureSpec.UNSPECIFIED);
view.measure(widthMeasureSpec, heightMeasureSpec);
int originalHeight = view.getMeasuredHeight();
ValueAnimator heightAnimator = ValueAnimator.ofInt(1, originalHeight);
heightAnimator.addUpdateListener(new HeightUpdater(view));
Animator[] customAnimators = getAdditionalAnimators(view, parent);
Animator[] animators = new Animator[customAnimators.length + 1];
animators[0] = heightAnimator;
System.arraycopy(customAnimators, 0, animators, 1, customAnimators.length);
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(animators);
ViewHelper.setAlpha(view, 0);
ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(view, ALPHA, 0, 1);
AnimatorSet allAnimatorsSet = new AnimatorSet();
allAnimatorsSet.playSequentially(animatorSet, alphaAnimator);
allAnimatorsSet.setDuration(mInsertionAnimationDurationMs);
allAnimatorsSet.addListener(new ExpandAnimationListener(position));
allAnimatorsSet.start();
}
return view;
}
use of com.nineoldandroids.animation.ObjectAnimator in project ListViewAnimations by nhaarman.
the class SwipeTouchListener method restoreCurrentViewTranslation.
/**
* Animates the pending {@link android.view.View} back to its original position.
*/
private void restoreCurrentViewTranslation() {
if (mCurrentView == null) {
return;
}
ObjectAnimator xAnimator = ObjectAnimator.ofFloat(mSwipingView, TRANSLATION_X, 0);
ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(mSwipingView, ALPHA, 1);
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(xAnimator, alphaAnimator);
animatorSet.setDuration(mAnimationTime);
animatorSet.addListener(new RestoreAnimatorListener(mCurrentView, mCurrentPosition));
animatorSet.start();
}
use of com.nineoldandroids.animation.ObjectAnimator in project ElasticDownload by Tibolte.
the class PathAnimatorInflater method loadObjectAnimator.
private static ObjectAnimator loadObjectAnimator(Context c, Resources res, Resources.Theme theme, AttributeSet attrs, float pathErrorScale) throws Resources.NotFoundException {
ObjectAnimator anim = new ObjectAnimator();
loadAnimator(c, res, theme, attrs, anim, pathErrorScale);
return anim;
}
use of com.nineoldandroids.animation.ObjectAnimator in project ElasticDownload by Tibolte.
the class ProgressDownloadView method drawFail.
public void drawFail() {
mState = State.STATE_FAILED;
ObjectAnimator failAnim = ObjectAnimator.ofFloat(this, "failAngle", 0, 180);
failAnim.setInterpolator(new OvershootInterpolator());
//This one doesn't do much actually, we just use it to take advantage of associating two different interpolators
ObjectAnimator anim = ObjectAnimator.ofFloat(this, "progress", getProgress(), mTarget);
anim.setInterpolator(new AccelerateInterpolator());
AnimatorSet set = new AnimatorSet();
set.setDuration((long) (ANIMATION_DURATION_BASE / 1.7f));
set.playTogether(failAnim, anim);
set.start();
}
use of com.nineoldandroids.animation.ObjectAnimator in project ElasticDownload by Tibolte.
the class ProgressDownloadView method drawSuccess.
public void drawSuccess() {
mTarget = 100;
final ObjectAnimator successAnim = ObjectAnimator.ofFloat(this, "flip", 1, -1);
successAnim.setInterpolator(new OvershootInterpolator());
successAnim.setDuration(ANIMATION_DURATION_BASE);
ObjectAnimator anim = ObjectAnimator.ofFloat(this, "progress", getProgress(), mTarget);
anim.setInterpolator(new DecelerateInterpolator());
anim.setDuration((long) (ANIMATION_DURATION_BASE + Math.abs(mTarget * 10 - getProgress() * 10) / 2));
anim.addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
}
@Override
public void onAnimationEnd(Animator animation) {
mState = State.STATE_SUCCESS;
successAnim.start();
}
@Override
public void onAnimationCancel(Animator animation) {
}
@Override
public void onAnimationRepeat(Animator animation) {
}
});
anim.start();
}
Aggregations