@Override public void setAnimationListener(AnimationListener listener) { super.setAnimationListener(listener); } };
public static void setAnimationListener(Animation aninm, final AnimListener listener) { aninm.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { listener.onAnimFinish(); } @Override public void onAnimationRepeat(Animation animation) { } }); }
/** * @author Jack Tony */ @Override public void dismiss() { Animation anim = AnimationUtils.loadAnimation(activity, R.anim.snackbar_hide_animation); anim.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { SnackBar.super.dismiss(); } }); view.startAnimation(anim); }
public void play() { if (mTargetView == null || mSnackInAnim == null || mSnackOutAnim == null) { return; } mTargetView.setVisibility(View.VISIBLE); mSnackInAnim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { playSnackOutAnimation(); } @Override public void onAnimationRepeat(Animation animation) { } }); mTargetView.startAnimation(mSnackInAnim); }
/** * Create "animation chain" for selected view from list of animation objects * * @param animationList collection with animations * @param animationObject view for animations */ protected void createAnimationChain(final List<Animation> animationList, final View animationObject) { for (int i = 0; i < animationList.size(); i++) { Animation animation = animationList.get(i); if (i + 1 < animationList.size()) { final int finalI = i; animation.setAnimationListener(new AnimationEndListener() { public void onAnimationEnd(Animation animation) { animationObject.startAnimation(animationList.get(finalI + 1)); } }); } } }
@Override public void dismiss() { Animation anim = AnimationUtils.loadAnimation(context, R.anim.dialog_main_hide_amination); anim.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { view.post(new Runnable() { @Override public void run() { ColorSelector.super.dismiss(); } }); } }); Animation backAnim = AnimationUtils.loadAnimation(context, R.anim.dialog_root_hide_amin); view.startAnimation(anim); backView.startAnimation(backAnim); }
@Override public void dismiss() { Animation anim = AnimationUtils.loadAnimation(context, R.anim.dialog_main_hide_amination); anim.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { view.post(new Runnable() { @Override public void run() { ProgressDialog.super.dismiss(); } }); } }); Animation backAnim = AnimationUtils.loadAnimation(context, R.anim.dialog_root_hide_amin); view.startAnimation(anim); backView.startAnimation(backAnim); }
@Override public void dismiss() { Animation anim = AnimationUtils.loadAnimation(context, R.anim.dialog_main_hide_amination); anim.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { view.post(new Runnable() { @Override public void run() { Dialog.super.dismiss(); } }); } }); Animation backAnim = AnimationUtils.loadAnimation(context, R.anim.dialog_root_hide_amin); view.startAnimation(anim); backView.startAnimation(backAnim); }
private void animOut(final View v){ Animation anim = new AlphaAnimation(1f, 0f); anim.setDuration(getContext().getResources().getInteger(android.R.integer.config_mediumAnimTime)); anim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) {} @Override public void onAnimationEnd(Animation animation) { v.setVisibility(View.GONE); } @Override public void onAnimationRepeat(Animation animation) {} }); v.startAnimation(anim); }
private void fadeOutAndHideImage(final ImageView img) { Animation fadeOut = new AlphaAnimation(1, 0); fadeOut.setInterpolator(new AccelerateInterpolator()); fadeOut.setDuration(1000); fadeOut.setAnimationListener(new AnimationListener() { public void onAnimationEnd(Animation animation) { img.setVisibility(View.GONE); } public void onAnimationRepeat(Animation animation) {} public void onAnimationStart(Animation animation) {} }); img.startAnimation(fadeOut); }
private void animIn(final View v){ Animation anim = new AlphaAnimation(0f, 1f); anim.setDuration(getContext().getResources().getInteger(android.R.integer.config_mediumAnimTime)); anim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { v.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } }); v.startAnimation(anim); }
private void animOut(final View v, final boolean setGone, final boolean immediately){ if(!isShowing() || v.getVisibility() != View.VISIBLE || immediately) { v.setVisibility(setGone ? View.GONE : View.INVISIBLE); return; } Animation anim = new AlphaAnimation(1f, 0f); anim.setDuration(getContext().getResources().getInteger(android.R.integer.config_mediumAnimTime)); anim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) {} @Override public void onAnimationEnd(Animation animation) { v.setVisibility(setGone ? View.GONE : View.INVISIBLE); } @Override public void onAnimationRepeat(Animation animation) {} }); v.startAnimation(anim); }
private void animIn(final View v, boolean immediately){ if(v.getVisibility() == View.VISIBLE) return; if(!isShowing() || immediately) { v.setVisibility(View.VISIBLE); return; } Animation anim = new AlphaAnimation(0f, 1f); anim.setDuration(getContext().getResources().getInteger(android.R.integer.config_mediumAnimTime)); anim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { v.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(Animation animation) {} @Override public void onAnimationRepeat(Animation animation) {} }); v.startAnimation(anim); }
@Override public void onAnimationEnd(Animation animation) { new Handler().postDelayed(mVoteSwitcher::showNext, VOTE_DELAY_MILLIS); mScoreTextView.setText(getContext().getResources() .getQuantityString(R.plurals.score, newScore, newScore)); mVoteSwitcher.getInAnimation().setAnimationListener(null); }
@Override public void onAnimationEnd(Animation animation) { setVisibility(GONE); getHideAnimation().setAnimationListener(null); }
/** * Starts an animation on the view. * * <br> * contributed by: marcosbeirigo * * @param animId Id of the desired animation. * @param listener The listener to recieve notifications from the animation on its events. * @return self * * */ public T animate(int animId, AnimationListener listener){ Animation anim = AnimationUtils.loadAnimation(getContext(), animId); anim.setAnimationListener(listener); return animate(anim); }
/** * Sets the to be animated view on hardware layer during the animation.Note * that calling this will replace any existing animation listener on the animation * with a new one, as animations do not support more than one listeners. Therefore, * animations that already have listeners should do the layer change operations * in their existing listeners, rather than calling this function. */ void setHWLayerAnimListenerIfAlpha(View v, Animation anim) { if (v == null || anim == null) { return; } if (shouldRunOnHWLayer(v, anim)) { anim.setAnimationListener(new AnimateOnHWLayerIfNeededListener(v, anim)); } }
public void remove() { Animation exitAnimation = guidePage.getExitAnimation(); if (exitAnimation != null) { exitAnimation.setAnimationListener(new AnimationListenerAdapter() { @Override public void onAnimationEnd(Animation animation) { dismiss(); } }); startAnimation(exitAnimation); } else { dismiss(); } }
private void setupAnimations(Animation in, Animation out) { if (K9.showAnimations()) { setInAnimation(in); setOutAnimation(out); out.setAnimationListener(this); } else { setInAnimation(null); setOutAnimation(null); } }
@Test @Ignore("Needs additional work") public void start_shouldRunAnimation() { final AnimationSet set = new AnimationSet(true); final Animation move = new TranslateAnimation(0, 100, 0, 100); move.setDuration(1000); move.setAnimationListener(moveListener); final Animation spin = new RotateAnimation(0, 360); spin.setDuration(1000); spin.setStartOffset(1000); spin.setAnimationListener(spinListener); set.start(); verify(moveListener).onAnimationStart(move); Robolectric.flushForegroundThreadScheduler(); verify(moveListener).onAnimationEnd(move); } }