List of usage examples for android.view.animation TranslateAnimation setAnimationListener
public void setAnimationListener(AnimationListener listener)
Binds an animation listener to this animation.
From source file:Main.java
public static void SlideOutLeft(View v, final Runnable onComplete) { v.clearAnimation();//from ww w. j a va 2 s. co m TranslateAnimation aout = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, -1f, Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 0f); aout.setDuration(300); aout.setFillAfter(true); v.startAnimation(aout); if (onComplete != null) aout.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation arg0) { } @Override public void onAnimationRepeat(Animation arg0) { } @Override public void onAnimationEnd(Animation arg0) { onComplete.run(); } }); }
From source file:Main.java
/** * translate the view.//w w w.j ava 2 s.c om * * @param view view to be translated * @param fromXDelta Change in X coordinate to apply at the start of the * animation * @param toXDelta Change in X coordinate to apply at the end of the * animation * @param fromYDelta Change in Y coordinate to apply at the start of the * animation * @param toYDelta Change in Y coordinate to apply at the end of the * animation * @param cycles Repeats the animation for a specified number of cycles {@link CycleInterpolator}. * @param durationMillis Duration in milliseconds * @param isBanClick whether view can click in animation */ public static void translate(final View view, float fromXDelta, float toXDelta, float fromYDelta, float toYDelta, float cycles, long durationMillis, final boolean isBanClick) { TranslateAnimation translateAnimation = new TranslateAnimation(fromXDelta, toXDelta, fromYDelta, toYDelta); translateAnimation.setDuration(durationMillis); if (cycles > 0.0) { translateAnimation.setInterpolator(new CycleInterpolator(cycles)); } translateAnimation.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { if (isBanClick) { view.setClickable(false); } } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { if (isBanClick) { view.setClickable(true); } } }); view.startAnimation(translateAnimation); }
From source file:Main.java
public static void translate(final View view, float fromXDelta, float toXDelta, float fromYDelta, float toYDelta, float cycles, long durationMillis, final boolean isBanClick) { TranslateAnimation translateAnimation = new TranslateAnimation(fromXDelta, toXDelta, fromYDelta, toYDelta); translateAnimation.setDuration(durationMillis); if (cycles > 0.0) { translateAnimation.setInterpolator(new CycleInterpolator(cycles)); }/*from ww w .ja va2s . c o m*/ translateAnimation.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { if (isBanClick) { view.setClickable(false); } } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { if (isBanClick) { view.setClickable(true); } } }); view.startAnimation(translateAnimation); }
From source file:Main.java
/** * move the background view(translate animation). * /* ww w.j a v a2 s. c o m*/ * @param view * the view will be moved * @param durationMillis * translate animation duration * @param fromX * from X coordinate * @param toX * to X coordinate * @param fromY * from Y coordinate * @param toY * to Y coordinate */ public static void translateFromBelow(final Context context, final View view, final long durationMillis, boolean fillAfter, float fromX, float toX, final float fromY, final float toY) { TranslateAnimation translateAnimation = new TranslateAnimation(fromX, toX, fromY, toY + 5); // TranslateAnimation translateAnimation = new TranslateAnimation(fromX, toX, fromY, toY-21); translateAnimation.setDuration(durationMillis); translateAnimation.setFillAfter(fillAfter);//this animation performed will persist when it is finished view.startAnimation(translateAnimation); translateAnimation.setAnimationListener(new AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { // TranslateAnimation shakeAnimation = new TranslateAnimation(0, 0, toY-21, toY+5); // shakeAnimation.setInterpolator(new BounceInterpolator()); // shakeAnimation.setDuration(durationMillis); //500 // shakeAnimation.setFillAfter(true); // view.startAnimation(shakeAnimation); } }); }
From source file:Main.java
public static void expandOrCollapse(final View v, boolean expand) { TranslateAnimation anim; if (expand) { anim = new TranslateAnimation(0.0f, 0.0f, -v.getHeight(), 0.0f); v.setVisibility(View.VISIBLE); } else {//from w w w. j av a 2 s . c om anim = new TranslateAnimation(0.0f, 0.0f, 0.0f, -v.getHeight()); Animation.AnimationListener collapselistener = new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { // Useless } @Override public void onAnimationRepeat(Animation animation) { // Useless } @Override public void onAnimationEnd(Animation animation) { v.setVisibility(View.GONE); } }; anim.setAnimationListener(collapselistener); } anim.setDuration(300); anim.setInterpolator(new AccelerateInterpolator(0.5f)); v.startAnimation(anim); }
From source file:net.bither.fragment.hot.MarketFragment.java
public void showPriceAlertAnimTo(int fromX, int fromY, Market toMarket) { int[] containerOffset = new int[2]; v.getLocationInWindow(containerOffset); containerOffset[0] += v.getPaddingLeft(); containerOffset[1] += v.getPaddingTop(); ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) ivMarketPriceAnimIcon.getLayoutParams(); lp.topMargin = fromY - containerOffset[1]; lp.leftMargin = fromX - containerOffset[0]; int marketIndex = markets.indexOf(toMarket); if (marketIndex < lv.getFirstVisiblePosition() || marketIndex > lv.getLastVisiblePosition()) { lv.setSelection(marketIndex);//from w ww . j a va 2 s. c o m } View marketView = lv.getChildAt(marketIndex - lv.getFirstVisiblePosition()); View toIconView = marketView.findViewById(R.id.iv_price_alert); int[] toLocation = new int[2]; toIconView.getLocationInWindow(toLocation); TranslateAnimation anim = new TranslateAnimation(0, toLocation[0] - fromX, 0, toLocation[1] - fromY); anim.setDuration(300); anim.setInterpolator(new AccelerateDecelerateInterpolator()); anim.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { doRefresh(); ivMarketPriceAnimIcon.setVisibility(View.INVISIBLE); } @Override public void onAnimationRepeat(Animation animation) { } }); ivMarketPriceAnimIcon.setVisibility(View.VISIBLE); ivMarketPriceAnimIcon.startAnimation(anim); }
From source file:gov.whitehouse.ui.activities.BaseDashboardActivity.java
public void hideSearch() { final int height = mSearchFragment.getView().getHeight(); TranslateAnimation slideUpAnim = new TranslateAnimation(0, 0, 0, -height); slideUpAnim.setDuration(SEARCH_FRAGMENT_ANIMATION_DURATION); slideUpAnim.setAnimationListener(new Animation.AnimationListener() { @Override/*from ww w. ja v a 2 s . com*/ public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { getSupportFragmentManager().beginTransaction().hide(mSearchFragment).commitAllowingStateLoss(); mSearchField.setText(""); mSearchField.clearFocus(); mDrawerGarment.setDrawerEnabled(true); } @Override public void onAnimationRepeat(Animation animation) { } }); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); mSearchFragment.getView().startAnimation(slideUpAnim); mShowingSearch = false; }
From source file:gov.whitehouse.ui.activities.BaseDashboardActivity.java
public void showSearch() { final int height = mSearchFragment.getView().getHeight(); TranslateAnimation slideDownAnim = new TranslateAnimation(0, 0, -height, 0); slideDownAnim.setDuration(SEARCH_FRAGMENT_ANIMATION_DURATION); slideDownAnim.setAnimationListener(new Animation.AnimationListener() { @Override/*from ww w . j a va 2 s . c o m*/ public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { getSupportFragmentManager().beginTransaction().show(mSearchFragment).commitAllowingStateLoss(); mSearchFragment.getView().requestLayout(); mDrawerGarment.setDrawerEnabled(false); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE); if (!mSearchField.getText().toString().equals("")) { mSearchFragment.setListShown(true); mSearchFragment.doSearchForQuery(mSearchField.getText().toString()); } } @Override public void onAnimationRepeat(Animation animation) { } }); mSearchFragment.getView().startAnimation(slideDownAnim); mShowingSearch = true; }
From source file:quickbeer.android.next.views.ProgressIndicatorBar.java
private void animateScroller() { Log.v(TAG, "animateScroller()"); int animEnd = getWidth() - progressBarWidth; TranslateAnimation animation = new TranslateAnimation(0, animEnd, 0, 0); animation.setDuration(ANIMATION_SCROLL_DURATION); animation.setFillAfter(true);/*ww w. java 2 s . c om*/ animation.setRepeatMode(Animation.REVERSE); animation.setRepeatCount(Animation.INFINITE); animation.setAnimationListener(new Animation.AnimationListener() { private int repeatCounter = 0; @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { if (++repeatCounter % 2 == 0 && nextStatus != Status.INDEFINITE) { applyNextStatus(); } } }); progressBar.setVisibility(VISIBLE); progressBar.clearAnimation(); progressBar.startAnimation(animation); }
From source file:quickbeer.android.views.ProgressIndicatorBar.java
private void animateScroller() { Timber.v("animateScroller()"); checkNotNull(progressBar);//from ww w . java2s. com int animEnd = getWidth() - progressBarWidth; TranslateAnimation animation = new TranslateAnimation(0, animEnd, 0, 0); animation.setDuration(ANIMATION_SCROLL_DURATION); animation.setFillAfter(true); animation.setRepeatMode(Animation.REVERSE); animation.setRepeatCount(Animation.INFINITE); animation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { } @Override public void onAnimationRepeat(Animation animation) { if (nextProgress.getStatus() != INDEFINITE) { applyNextStatus(); } } }); progressBar.setVisibility(VISIBLE); progressBar.clearAnimation(); progressBar.startAnimation(animation); }