use of com.marshalchen.common.uimodule.nineoldandroids.animation.ValueAnimator in project UltimateAndroid by cymcsg.
the class ViewPropertyAnimatorPreHC method startAnimation.
/**
* 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();
}
use of com.marshalchen.common.uimodule.nineoldandroids.animation.ValueAnimator in project UltimateAndroid by cymcsg.
the class EnhancedListView method performDismiss.
/**
* Animate the dismissed list item to zero-height and fire the dismiss callback when
* all dismissed list item animations have completed.
*
* @param dismissView The view that has been slided out.
* @param listItemView The list item view. This is the whole view of the list item, and not just
* the part, that the user swiped.
* @param dismissPosition The position of the view inside the list.
*/
private void performDismiss(final View dismissView, final View listItemView, final int dismissPosition) {
final ViewGroup.LayoutParams lp = listItemView.getLayoutParams();
final int originalLayoutHeight = lp.height;
int originalHeight = listItemView.getHeight();
ValueAnimator animator = ValueAnimator.ofInt(originalHeight, 1).setDuration(mAnimationTime);
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
// Make sure no other animation is running. Remove animation from running list, that just finished
boolean noAnimationLeft;
synchronized (mAnimationLock) {
--mDismissAnimationRefCount;
mAnimatedViews.remove(dismissView);
noAnimationLeft = mDismissAnimationRefCount == 0;
}
if (noAnimationLeft) {
for (PendingDismissData dismiss : mPendingDismisses) {
if (mUndoStyle == UndoStyle.SINGLE_POPUP) {
for (Undoable undoable : mUndoActions) {
undoable.discard();
}
mUndoActions.clear();
}
Undoable undoable = mDismissCallback.onDismiss(EnhancedListView.this, dismiss.position);
if (undoable != null) {
mUndoActions.add(undoable);
}
mValidDelayedMsgId++;
}
if (!mUndoActions.isEmpty()) {
changePopupText();
changeButtonLabel();
// Show undo popup
float yLocationOffset = getResources().getDimension(R.dimen.elv_undo_bottom_offset);
mUndoPopup.setWidth((int) Math.min(mScreenDensity * 400, getWidth() * 0.9f));
mUndoPopup.showAtLocation(EnhancedListView.this, Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM, 0, (int) yLocationOffset);
// Queue the dismiss only if required
if (!mTouchBeforeAutoHide) {
// Send a delayed message to hide popup
mHideUndoHandler.sendMessageDelayed(mHideUndoHandler.obtainMessage(mValidDelayedMsgId), mUndoHideDelay);
}
}
ViewGroup.LayoutParams lp;
for (PendingDismissData pendingDismiss : mPendingDismisses) {
ViewHelper.setAlpha(pendingDismiss.view, 1f);
ViewHelper.setTranslationX(pendingDismiss.view, 0);
lp = pendingDismiss.childView.getLayoutParams();
lp.height = originalLayoutHeight;
pendingDismiss.childView.setLayoutParams(lp);
}
mPendingDismisses.clear();
}
}
});
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
lp.height = (Integer) valueAnimator.getAnimatedValue();
listItemView.setLayoutParams(lp);
}
});
mPendingDismisses.add(new PendingDismissData(dismissPosition, dismissView, listItemView));
animator.start();
}
use of com.marshalchen.common.uimodule.nineoldandroids.animation.ValueAnimator in project UltimateAndroid by cymcsg.
the class AnimateDismissAdapter method createAnimatorForView.
private Animator createAnimatorForView(final View view) {
final ViewGroup.LayoutParams lp = view.getLayoutParams();
final int originalHeight = view.getHeight();
ValueAnimator animator = ValueAnimator.ofInt(originalHeight, 0);
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(final Animator animator) {
lp.height = 0;
view.setLayoutParams(lp);
}
});
animator.addUpdateListener(new AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(final ValueAnimator valueAnimator) {
lp.height = (Integer) valueAnimator.getAnimatedValue();
view.setLayoutParams(lp);
}
});
return animator;
}
use of com.marshalchen.common.uimodule.nineoldandroids.animation.ValueAnimator in project UltimateAndroid by cymcsg.
the class SwipeDismissListViewTouchListener method performDismiss.
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();
}
use of com.marshalchen.common.uimodule.nineoldandroids.animation.ValueAnimator in project UltimateAndroid by cymcsg.
the class DescriptionAnimation method onNextItemAppear.
/**
* When next item show in ViewPagerEx, let's make an animation to show the
* description layout.
* @param view
*/
@Override
public void onNextItemAppear(View view) {
View descriptionLayout = view.findViewById(R.id.description_layout);
if (descriptionLayout != null) {
float layoutY = ViewHelper.getY(descriptionLayout);
view.findViewById(R.id.description_layout).setVisibility(View.VISIBLE);
ValueAnimator animator = ObjectAnimator.ofFloat(descriptionLayout, "y", layoutY + descriptionLayout.getHeight(), layoutY).setDuration(500);
animator.start();
}
}
Aggregations