use of android.animation.AnimatorListenerAdapter in project Material-Animations by lgvalle.
the class RevealActivity method revealBlue.
private void revealBlue() {
animateButtonsOut();
Animator anim = animateRevealColorFromCoordinates(bgViewGroup, R.color.sample_blue, bgViewGroup.getWidth() / 2, 0);
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
animateButtonsIn();
}
});
body.setText(R.string.reveal_body4);
body.setTextColor(ContextCompat.getColor(this, R.color.theme_blue_background));
}
use of android.animation.AnimatorListenerAdapter in project android-topeka by googlesamples.
the class QuizActivity method prepareCircularReveal.
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void prepareCircularReveal(View startView, FrameLayout targetView) {
int centerX = (startView.getLeft() + startView.getRight()) / 2;
// Subtract the start view's height to adjust for relative coordinates on screen.
int centerY = (startView.getTop() + startView.getBottom()) / 2 - startView.getHeight();
float endRadius = (float) Math.hypot(centerX, centerY);
mCircularReveal = ViewAnimationUtils.createCircularReveal(targetView, centerX, centerY, startView.getWidth(), endRadius);
mCircularReveal.setInterpolator(new FastOutLinearInInterpolator());
mCircularReveal.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mIcon.setVisibility(View.GONE);
mCircularReveal.removeListener(this);
}
});
// Adding a color animation from the FAB's color to transparent creates a dissolve like
// effect to the circular reveal.
int accentColor = ContextCompat.getColor(this, mCategory.getTheme().getAccentColor());
mColorChange = ObjectAnimator.ofInt(targetView, ViewUtils.FOREGROUND_COLOR, accentColor, Color.TRANSPARENT);
mColorChange.setEvaluator(new ArgbEvaluator());
mColorChange.setInterpolator(mInterpolator);
}
use of android.animation.AnimatorListenerAdapter in project android-topeka by googlesamples.
the class QuizActivity method getSolvedStateListener.
@NonNull
private QuizFragment.SolvedStateListener getSolvedStateListener() {
return new QuizFragment.SolvedStateListener() {
@Override
public void onCategorySolved() {
setResultSolved();
setToolbarElevation(true);
displayDoneFab();
}
private void displayDoneFab() {
/* We're re-using the already existing fab and give it some
* new values. This has to run delayed due to the queued animation
* to hide the fab initially.
*/
if (null != mCircularReveal && mCircularReveal.isRunning()) {
mCircularReveal.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
showQuizFabWithDoneIcon();
mCircularReveal.removeListener(this);
}
});
} else {
showQuizFabWithDoneIcon();
}
}
private void showQuizFabWithDoneIcon() {
mQuizFab.setImageResource(R.drawable.ic_tick);
mQuizFab.setId(R.id.quiz_done);
mQuizFab.setVisibility(View.VISIBLE);
mQuizFab.setScaleX(0f);
mQuizFab.setScaleY(0f);
ViewCompat.animate(mQuizFab).scaleX(1).scaleY(1).setInterpolator(mInterpolator).setListener(null).start();
}
};
}
use of android.animation.AnimatorListenerAdapter in project cardslib by gabrielemariotti.
the class BaseDismissAnimation method invokeCallbak.
protected void invokeCallbak(final View dismissView) {
// Animate the dismissed list item to zero-height and fire 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.
final int dismissPosition = mBaseAdapter.getPosition(((CardViewWrapper) dismissView).getCard());
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) {
--mDismissAnimationRefCount;
if (mDismissAnimationRefCount == 0) {
// No active animations, process all pending dismisses.
// Sort by descending position
Collections.sort(mPendingDismisses);
int[] dismissPositions = new int[mPendingDismisses.size()];
for (int i = mPendingDismisses.size() - 1; i >= 0; i--) {
dismissPositions[i] = mPendingDismisses.get(i).position;
}
mCallbacks.onDismiss(mCardListView, dismissPositions);
// Reset mDownPosition to avoid MotionEvent.ACTION_UP trying to start a dismiss
// animation with a stale position
mDownPosition = ListView.INVALID_POSITION;
ViewGroup.LayoutParams lp;
for (PendingDismissData pendingDismiss : mPendingDismisses) {
// Reset view presentation
pendingDismiss.view.setAlpha(1f);
pendingDismiss.view.setTranslationX(0);
lp = pendingDismiss.view.getLayoutParams();
lp.height = 0;
pendingDismiss.view.setLayoutParams(lp);
}
// Send a cancel event
long time = SystemClock.uptimeMillis();
MotionEvent cancelEvent = MotionEvent.obtain(time, time, MotionEvent.ACTION_CANCEL, 0, 0, 0);
mCardListView.dispatchTouchEvent(cancelEvent);
mPendingDismisses.clear();
}
}
});
animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
lp.height = (Integer) valueAnimator.getAnimatedValue();
dismissView.setLayoutParams(lp);
}
});
mPendingDismisses.add(new PendingDismissData(dismissPosition, dismissView));
animator.start();
}
use of android.animation.AnimatorListenerAdapter in project cardslib by gabrielemariotti.
the class SwipeDismissListViewTouchListener method dismiss.
private void dismiss(final View view, final int position, boolean dismissRight) {
++mDismissAnimationRefCount;
if (view == null) {
// No view, shortcut to calling onDismiss to let it deal with adapter
// updates and all that.
mCallbacks.onDismiss(mListView, new int[] { position });
return;
}
view.animate().translationX(dismissRight ? mViewWidth : -mViewWidth).alpha(0).setDuration(mAnimationTime).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
performDismiss(view, position);
}
});
}
Aggregations