Example usage for android.animation AnimatorListenerAdapter AnimatorListenerAdapter

List of usage examples for android.animation AnimatorListenerAdapter AnimatorListenerAdapter

Introduction

In this page you can find the example usage for android.animation AnimatorListenerAdapter AnimatorListenerAdapter.

Prototype

AnimatorListenerAdapter

Source Link

Usage

From source file:com.bartoszlipinski.viewpropertyobjectanimator.ViewPropertyObjectAnimator.java

public ViewPropertyObjectAnimator withStartAction(final Runnable runnable) {
    return addListener(new AnimatorListenerAdapter() {
        @Override//  w  w w .j av  a2s .c om
        public void onAnimationStart(Animator animation) {
            runnable.run();
            removeListener(this);
        }
    });
}

From source file:com.gitstudy.rili.liarbry.CalendarLayout.java

/**
 * ??//from  w w w .ja v  a  2s  . c  om
 */
@SuppressLint("NewApi")
final void hideContentView() {
    if (mContentView == null)
        return;
    mContentView.animate().translationY(getHeight() - mMonthView.getHeight()).setDuration(220)
            .setInterpolator(new LinearInterpolator()).setListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    super.onAnimationEnd(animation);
                    mContentView.setVisibility(INVISIBLE);
                    mContentView.clearAnimation();
                }
            });
}

From source file:com.btmura.android.reddit.app.AbstractBrowserActivity.java

private AnimatorSet newOpenNavAnimator() {
    ObjectAnimator ncTransX = ObjectAnimator.ofFloat(navContainer, "translationX", -fullNavWidth, 0);
    ObjectAnimator tpTransX = ObjectAnimator.ofFloat(thingContainer, "translationX", 0, fullNavWidth);

    AnimatorSet as = new AnimatorSet();
    as.setDuration(durationMs).play(ncTransX).with(tpTransX);
    as.addListener(new AnimatorListenerAdapter() {
        @Override//from  w ww. java2s.  c  om
        public void onAnimationStart(Animator animation) {
            navContainer.setLayerType(View.LAYER_TYPE_HARDWARE, null);
            navContainer.setVisibility(View.VISIBLE);
            thingContainer.setLayerType(View.LAYER_TYPE_HARDWARE, null);
            thingContainer.setVisibility(View.VISIBLE);
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            navContainer.setLayerType(View.LAYER_TYPE_NONE, null);
            thingContainer.setLayerType(View.LAYER_TYPE_NONE, null);
            thingContainer.setVisibility(View.GONE);
        }
    });
    return as;
}

From source file:com.grarak.kerneladiutor.fragments.RecyclerViewFragment.java

public void showForeground() {
    if (mForegroundStrText != null) {
        mForegroundText.setText(mForegroundStrText);
    }//from   ww  w. j av  a  2s  . c om
    if (mForegroundAnimator != null)
        mForegroundAnimator.cancel();
    mForegroundAnimator = ValueAnimator.ofFloat(mForegroundHeight, 0f);
    mForegroundAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mForegroundParent.setTranslationY((float) animation.getAnimatedValue());
        }
    });
    mForegroundAnimator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationStart(Animator animation) {
            super.onAnimationStart(animation);
            mForegroundParent.setVisibility(View.VISIBLE);
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            mForegroundVisible = true;
            mForegroundAnimator = null;
        }
    });
    mForegroundAnimator.start();
}

From source file:com.github.shareme.gwsmaterialuikit.library.mscrollbar.MaterialScrollBar.java

protected void onUp() {
    if (indicator != null && indicator.getVisibility() == VISIBLE) {
        if (Build.VERSION.SDK_INT <= 12) {
            indicator.clearAnimation();//from  ww w.  j a v  a 2 s  .co  m
        }
        if (Build.VERSION.SDK_INT >= 12) {
            indicator.animate().alpha(0F).setDuration(150).setListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    super.onAnimationEnd(animation);

                    indicator.setVisibility(INVISIBLE);
                }
            });
        } else {
            indicator.setVisibility(INVISIBLE);
        }
    }

    if (lightOnTouch) {
        handle.setBackgroundColor(handleOffColour);
    }
}

From source file:com.bartoszlipinski.viewpropertyobjectanimator.ViewPropertyObjectAnimator.java

public ViewPropertyObjectAnimator withEndAction(final Runnable runnable) {
    return addListener(new AnimatorListenerAdapter() {
        private boolean mIsCanceled;

        @Override//from  w  ww .  j a  va  2s . c  om
        public void onAnimationCancel(Animator animation) {
            mIsCanceled = true;
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            if (!mIsCanceled) {
                runnable.run();
            }
            removeListener(this);
        }
    });
}

From source file:com.betterAlarm.deskclock.timer.TimerFragment.java

@Override
public void onLeftButtonClick(View view) {
    // Respond to delete timer
    final TimerObj timer = getCurrentTimer();
    if (timer == null) {
        return; // Prevent NPE if user click delete faster than the fade animation
    }//w w w  .ja v a 2  s . c  om
    if (timer.mState == TimerObj.STATE_TIMESUP) {
        mNotificationManager.cancel(timer.mTimerId);
    }
    if (mAdapter.getCount() == 1) {
        final AnimatorListenerAdapter adapter = new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                mTimerView.setScaleX(1.0f); // Reset the scale for timer view
                deleteTimer(timer);
            }
        };
        createRotateAnimator(adapter, true).start();
    } else {
        TransitionManager.beginDelayedTransition(mContentView, mDeleteTransition);
        deleteTimer(timer);
    }
}

From source file:com.android.deskclock.timer.TimerFullScreenFragment.java

private void gotoSetupView() {
    if (mLastVisibleView == null || mLastVisibleView.getId() == R.id.timer_setup) {
        mTimerSetup.setVisibility(View.VISIBLE);
        mTimerSetup.setScaleX(1f);/* www .j a v a2  s .  c o  m*/
        mTimersListPage.setVisibility(View.GONE);
    } else {
        // Animate
        ObjectAnimator a = ObjectAnimator.ofFloat(mTimersListPage, View.SCALE_X, 1f, 0f);
        a.setInterpolator(new AccelerateInterpolator());
        a.setDuration(125);
        a.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                mTimersListPage.setVisibility(View.GONE);
                mTimerSetup.setScaleX(0);
                mTimerSetup.setVisibility(View.VISIBLE);
                ObjectAnimator b = ObjectAnimator.ofFloat(mTimerSetup, View.SCALE_X, 0f, 1f);
                b.setInterpolator(new DecelerateInterpolator());
                b.setDuration(225);
                b.start();
            }
        });
        a.start();

    }
    stopClockTicks();
    mTimerSetup.updateDeleteButtonAndDivider();
    mLastVisibleView = mTimerSetup;
}

From source file:com.onyx.deskclock.deskclock.alarms.AlarmActivity.java

private Animator getAlertAnimator(final View source, final int titleResId, final String infoText,
        final String accessibilityText, final int revealColor, final int backgroundColor) {
    final ViewGroup containerView = (ViewGroup) findViewById(android.R.id.content);

    final Rect sourceBounds = new Rect(0, 0, source.getHeight(), source.getWidth());
    containerView.offsetDescendantRectToMyCoords(source, sourceBounds);

    final int centerX = sourceBounds.centerX();
    final int centerY = sourceBounds.centerY();

    final int xMax = Math.max(centerX, containerView.getWidth() - centerX);
    final int yMax = Math.max(centerY, containerView.getHeight() - centerY);

    final float startRadius = Math.max(sourceBounds.width(), sourceBounds.height()) / 2.0f;
    final float endRadius = (float) Math.sqrt(xMax * xMax + yMax * yMax);

    final CircleView revealView = new CircleView(this).setCenterX(centerX).setCenterY(centerY)
            .setFillColor(revealColor);//from  www. j  av  a2 s  . c om
    containerView.addView(revealView);

    // TODO: Fade out source icon over the reveal (like LOLLIPOP version).

    final Animator revealAnimator = ObjectAnimator.ofFloat(revealView, CircleView.RADIUS, startRadius,
            endRadius);
    revealAnimator.setDuration(ALERT_REVEAL_DURATION_MILLIS);
    revealAnimator.setInterpolator(REVEAL_INTERPOLATOR);
    revealAnimator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animator) {
            mAlertView.setVisibility(View.VISIBLE);
            mAlertTitleView.setText(titleResId);

            if (infoText != null) {
                mAlertInfoView.setText(infoText);
                mAlertInfoView.setVisibility(View.VISIBLE);
            }
            mContentView.setVisibility(View.GONE);

            getWindow().setBackgroundDrawable(new ColorDrawable(backgroundColor));
        }
    });

    final ValueAnimator fadeAnimator = ObjectAnimator.ofFloat(revealView, View.ALPHA, 0.0f);
    fadeAnimator.setDuration(ALERT_FADE_DURATION_MILLIS);
    fadeAnimator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            containerView.removeView(revealView);
        }
    });

    final AnimatorSet alertAnimator = new AnimatorSet();
    alertAnimator.play(revealAnimator).before(fadeAnimator);
    alertAnimator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animator) {
            if (Build.VERSION.SDK_INT >= 16) {
                mAlertView.announceForAccessibility(accessibilityText);
            }

            mHandler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    finish();
                }
            }, ALERT_DISMISS_DELAY_MILLIS);
        }
    });

    return alertAnimator;
}

From source file:com.gitstudy.rili.liarbry.CalendarLayout.java

/**
 * /*from   w w  w . j a v a2s.c o  m*/
 */
@SuppressLint("NewApi")
final void showContentView() {
    if (mContentView == null)
        return;
    mContentView.setTranslationY(getHeight() - mMonthView.getHeight());
    mContentView.setVisibility(VISIBLE);
    mContentView.animate().translationY(0).setDuration(180).setInterpolator(new LinearInterpolator())
            .setListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    super.onAnimationEnd(animation);
                }
            });
}