List of usage examples for android.view.animation TranslateAnimation setDuration
public void setDuration(long durationMillis)
From source file:enterprayz.megatools.Tools.java
public static void replace(View source, int xTo, int yTo, float xScale, float yScale) { AnimationSet replaceAnimation = new AnimationSet(false); replaceAnimation.setFillAfter(true); ScaleAnimation scale = new ScaleAnimation(1.0f, xScale, 1.0f, yScale); scale.setDuration(1000);/*from w ww . j av a 2s . c o m*/ TranslateAnimation trans = new TranslateAnimation(0, 0, TranslateAnimation.ABSOLUTE, xTo - source.getLeft(), 0, 0, TranslateAnimation.ABSOLUTE, yTo - source.getTop()); trans.setDuration(1000); replaceAnimation.addAnimation(scale); replaceAnimation.addAnimation(trans); source.startAnimation(replaceAnimation); }
From source file:com.breadwallet.tools.animation.BRAnimator.java
/** * Animate the transition on wipe wallet fragment *//*from ww w. j a v a 2s. c o m*/ public static void pressWipeWallet(final MainActivity context, final Fragment to) { try { if (!wipeWalletOpen) { wipeWalletOpen = true; FragmentTransaction fragmentTransaction = context.getFragmentManager().beginTransaction(); fragmentTransaction.replace(R.id.main_layout, to, to.getClass().getName()); fragmentTransaction.commit(); new Handler().postDelayed(new Runnable() { @Override public void run() { TranslateAnimation trans = new TranslateAnimation(0, 0, 1920, 0); trans.setDuration(500); trans.setInterpolator(new DecelerateOvershootInterpolator(3f, 0.5f)); View view = to.getView(); if (view != null) view.startAnimation(trans); } }, 1); } else { wipeWalletOpen = false; FragmentTransaction fragmentTransaction = context.getFragmentManager().beginTransaction(); fragmentTransaction.setCustomAnimations(R.animator.from_top, R.animator.to_bottom); fragmentTransaction.replace(R.id.main_layout, new FragmentSettings(), FragmentSettings.class.getName()); fragmentTransaction.commit(); } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.breadwallet.tools.animation.BRAnimator.java
/** * Animate the transition on burgerButton/MenuButton pressed *//*www. j a v a 2 s. co m*/ public static void pressMenuButton(final MainActivity context) { try { if (context == null) return; ((BreadWalletApp) context.getApplication()).cancelToast(); final FragmentManager fragmentManager = context.getFragmentManager(); if (level == 0) { if (PLATFORM_ON) new Thread(new Runnable() { @Override public void run() { HTTPServer.startServer(); } }).start(); level++; CustomPagerAdapter.adapter.showFragments(false, context); context.setBurgerButtonImage(BRConstants.CLOSE); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); FragmentSettingsAll to = (FragmentSettingsAll) fragmentManager .findFragmentByTag(FragmentSettingsAll.class.getName()); if (to == null) to = new FragmentSettingsAll(); fragmentTransaction.add(R.id.main_layout, to, FragmentSettingsAll.class.getName()); fragmentTransaction.commit(); final FragmentSettingsAll finalTo = to; new Handler().postDelayed(new Runnable() { @Override public void run() { TranslateAnimation trans = new TranslateAnimation(0, 0, 1920, 0); trans.setDuration(500); trans.setInterpolator(new DecelerateOvershootInterpolator(3f, 0.5f)); View view = finalTo.getView(); if (view != null) view.startAnimation(trans); } }, 1); InputMethodManager keyboard = (InputMethodManager) context .getSystemService(Context.INPUT_METHOD_SERVICE); if (keyboard != null) keyboard.hideSoftInputFromWindow( CustomPagerAdapter.adapter.mainFragment.addressEditText.getWindowToken(), 0); } else if (level == 1) { if (PLATFORM_ON) new Thread(new Runnable() { @Override public void run() { HTTPServer.stopServer(); } }).start(); level--; context.setBurgerButtonImage(BRConstants.BURGER); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.setCustomAnimations(R.animator.from_top, R.animator.to_bottom); FragmentSettingsAll fragmentSettingsAll = (FragmentSettingsAll) fragmentManager .findFragmentByTag(FragmentSettingsAll.class.getName()); fragmentTransaction.remove(fragmentSettingsAll); fragmentTransaction.commit(); CustomPagerAdapter.adapter.showFragments(true, context); } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.breadwallet.tools.animation.BRAnimator.java
/** * Animates the fragment transition on button_regular_blue "Settings" pressed *///from w w w . jav a 2 s.co m public static void animateSlideToLeft(final MainActivity context, final Fragment to, Fragment previousFragment) { try { if (!checkTheHorizontalSlideAvailability()) return; level++; if (level > 1) context.setBurgerButtonImage(BRConstants.BACK); FragmentTransaction fragmentTransaction = context.getFragmentManager().beginTransaction(); fragmentTransaction.replace(R.id.main_layout, to, to.getClass().getName()); if (previousFragment != null) previous.add(previousFragment); fragmentTransaction.commit(); new Handler().postDelayed(new Runnable() { @Override public void run() { TranslateAnimation trans = new TranslateAnimation(MainActivity.screenParametersPoint.x, 0, 0, 0); trans.setDuration(horizontalSlideDuration); trans.setInterpolator(new DecelerateOvershootInterpolator(1f, 0.5f)); View view = to.getView(); if (view != null) view.startAnimation(trans); } }, 1); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.breadwallet.tools.animation.BRAnimator.java
public static void animateSlideToRight(final MainActivity context) { try {/*from w ww . j a v a 2s . com*/ if (!checkTheHorizontalSlideAvailability()) return; final Fragment tmp = previous.pop(); level--; if (level < 1) context.setBurgerButtonImage(BRConstants.BURGER); if (level == 1) context.setBurgerButtonImage(BRConstants.CLOSE); FragmentTransaction fragmentTransaction = context.getFragmentManager().beginTransaction(); fragmentTransaction.replace(R.id.main_layout, tmp, tmp.getClass().getName()); fragmentTransaction.commit(); new Handler().postDelayed(new Runnable() { @Override public void run() { TranslateAnimation trans = new TranslateAnimation(-MainActivity.screenParametersPoint.x, 0, 0, 0); trans.setDuration(horizontalSlideDuration); trans.setInterpolator(new DecelerateOvershootInterpolator(1f, 0.5f)); View view = tmp.getView(); if (view != null) view.startAnimation(trans); } }, 1); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.breadwallet.tools.animation.BRAnimator.java
public static void animateScanResultFragment() { try {/* w w w . j a v a 2s . c o m*/ final MainActivity app = MainActivity.app; if (app == null || scanResultFragmentOn) return; CustomPagerAdapter.adapter.showFragments(false, app); scanResultFragmentOn = true; InputMethodManager keyboard = (InputMethodManager) app.getSystemService(Context.INPUT_METHOD_SERVICE); try { keyboard.hideSoftInputFromWindow( CustomPagerAdapter.adapter.mainFragment.addressEditText.getWindowToken(), 0); } catch (Exception e) { e.printStackTrace(); } app.setBurgerButtonImage(BRConstants.BACK); //Disabled inspection: <Expected resource type anim> final FragmentManager fragmentManager = app.getFragmentManager(); final FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); final FragmentScanResult scanResult = new FragmentScanResult(); fragmentTransaction.replace(R.id.main_layout, scanResult, FragmentScanResult.class.getName()); fragmentTransaction.commit(); new Handler().postDelayed(new Runnable() { @Override public void run() { TranslateAnimation trans = new TranslateAnimation(MainActivity.screenParametersPoint.x, 0, 0, 0); trans.setDuration(500); trans.setInterpolator(new DecelerateOvershootInterpolator(3f, 0.5f)); View view = scanResult.getView(); if (view != null) view.startAnimation(trans); } }, 1); } catch (Exception e) { e.printStackTrace(); } }
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 ww w. ja v a 2 s. c o m 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.sarangnamu.common.ui.widget.drawerlayout.ContentSlidingDrawerListener.java
@Override public void onDrawerSlide(View drawerView, float slideOffset) { // @see http://stackoverflow.com/questions/20057084/how-to-move-main-content-with-drawer-layout-left-side float moveFactor = (getListView().getWidth() * slideOffset); TranslateAnimation anim = new TranslateAnimation(lastTranslate, moveFactor, 0.0f, 0.0f); anim.setDuration(0); anim.setFillAfter(true);/*from w w w . j a va 2s . co m*/ getContentFrame().startAnimation(anim); lastTranslate = moveFactor; }
From source file:freed.cam.ui.themesample.cameraui.HelpFragment.java
private void showOpenSettingsMenu() { TranslateAnimation animation = new TranslateAnimation(0.0f, 400.0f, 0.0f, 0.0f); animation.setDuration(1000); animation.setRepeatCount(Animation.INFINITE); animation.setRepeatMode(Animation.INFINITE); animation.setFillAfter(true);//from ww w.j a va2 s .c o m finger.startAnimation(animation); description.setText("Swipe from left to right to open Settings"); }
From source file:freed.cam.ui.themesample.cameraui.HelpFragment.java
private void showCloseSettingsMenu() { TranslateAnimation animation = new TranslateAnimation(400.0f, 0.0f, 0.0f, 0.0f); animation.setDuration(1000); animation.setRepeatCount(Animation.INFINITE); animation.setRepeatMode(Animation.INFINITE); animation.setFillAfter(true);//from w w w .j a v a2s . c om finger.startAnimation(animation); description.setText("Swipe from right to left to close Settings"); }