use of android.animation.AnimatorListenerAdapter in project ShowcaseView by amlcurran.
the class AnimatorAnimationFactory method fadeOutView.
@Override
public void fadeOutView(View target, long duration, final AnimationEndListener listener) {
ObjectAnimator oa = ObjectAnimator.ofFloat(target, ALPHA, INVISIBLE);
oa.setDuration(duration).addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animator) {
listener.onAnimationEnd();
}
});
oa.start();
}
use of android.animation.AnimatorListenerAdapter in project ShowcaseView by amlcurran.
the class AnimatorAnimationFactory method fadeInView.
@Override
public void fadeInView(View target, long duration, final AnimationStartListener listener) {
ObjectAnimator oa = ObjectAnimator.ofFloat(target, ALPHA, INVISIBLE, VISIBLE);
oa.setDuration(duration).addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animator) {
listener.onAnimationStart();
}
});
oa.start();
}
use of android.animation.AnimatorListenerAdapter in project gdk-apidemo-sample by googleglass.
the class SliderActivity method processSliderRequest.
/**
* Processes a request to show a slider.
*
* Starting a new Slider, regardless of its type, automatically hides any shown Slider.
*/
private void processSliderRequest(int position) {
switch(position) {
case SCROLLER:
Slider.Scroller scroller = mSlider.startScroller(MAX_SLIDER_VALUE, 0);
// Start an animation showing the different positions of the slider, the slider
// automatically hides after a short time of inactivity.
ObjectAnimator.ofFloat(scroller, "position", 0, MAX_SLIDER_VALUE).setDuration(ANIMATION_DURATION_MILLIS).start();
break;
case DETERMINATE:
final Slider.Determinate determinate = mSlider.startDeterminate(MAX_SLIDER_VALUE, 0);
ObjectAnimator animator = ObjectAnimator.ofFloat(determinate, "position", 0, MAX_SLIDER_VALUE);
// Hide the slider when the animation stops.
animator.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
determinate.hide();
}
});
// Start an animation showing the different positions of the slider.
animator.setDuration(ANIMATION_DURATION_MILLIS).start();
break;
case GRACE_PERIOD:
// Start the grace period slider and play a sound when one of the listener method
// gets fired.
mGracePeriod = mSlider.startGracePeriod(mGracePeriodListener);
break;
case INDETERMINATE:
// Toggle between showing/hiding the indeterminate slider.
if (mIndeterminate != null) {
mIndeterminate.hide();
mIndeterminate = null;
} else {
mIndeterminate = mSlider.startIndeterminate();
}
break;
}
}
use of android.animation.AnimatorListenerAdapter in project iosched by google.
the class SearchActivity method doExitAnim.
/**
* On Lollipop+ perform a circular animation (a contracting circular mask) when hiding the
* search panel.
*/
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void doExitAnim() {
final View searchPanel = findViewById(R.id.search_panel);
// Center the animation on the top right of the panel i.e. near to the search button which
// launched this screen. The starting radius therefore is the diagonal distance from the top
// right to the bottom left
final int revealRadius = (int) Math.hypot(searchPanel.getWidth(), searchPanel.getHeight());
// Animating the radius to 0 produces the contracting effect
Animator shrink = ViewAnimationUtils.createCircularReveal(searchPanel, searchPanel.getRight(), searchPanel.getTop(), revealRadius, 0f);
shrink.setDuration(200L);
shrink.setInterpolator(AnimationUtils.loadInterpolator(SearchActivity.this, android.R.interpolator.fast_out_slow_in));
shrink.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
searchPanel.setVisibility(View.INVISIBLE);
ActivityCompat.finishAfterTransition(SearchActivity.this);
}
});
shrink.start();
// We also animate out the translucent background at the same time.
findViewById(R.id.scrim).animate().alpha(0f).setDuration(200L).setInterpolator(AnimationUtils.loadInterpolator(SearchActivity.this, android.R.interpolator.fast_out_slow_in)).start();
}
use of android.animation.AnimatorListenerAdapter in project material-sheet-fab by gowong.
the class MaterialSheetAnimation method startColorAnim.
protected void startColorAnim(final View view, final int startColor, final int endColor, long duration, Interpolator interpolator, final AnimationListener listener) {
// Setup animation
ValueAnimator anim = ValueAnimator.ofObject(new ArgbEvaluator(), startColor, endColor);
anim.setDuration(duration);
anim.setInterpolator(interpolator);
// Add listeners
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
if (listener != null) {
listener.onStart();
}
}
@Override
public void onAnimationEnd(Animator animation) {
if (listener != null) {
listener.onEnd();
}
}
});
anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animator) {
// Update background color
Integer color = (Integer) animator.getAnimatedValue();
// https://code.google.com/p/android/issues/detail?id=77843
if (isSupportCardView) {
// Use setCardBackground() method if it is available
if (setCardBackgroundColor != null) {
try {
setCardBackgroundColor.invoke(sheet, color);
} catch (Exception e) {
// Ignore exceptions since there's no other way set a support CardView's
// background color
}
}
} else // Set background color for all other views
{
view.setBackgroundColor(color);
}
}
});
// Start animation
anim.start();
}
Aggregations