List of usage examples for android.view.animation DecelerateInterpolator DecelerateInterpolator
public DecelerateInterpolator()
From source file:org.readium.sdk.android.biblemesh.WebViewActivity.java
private void snapBack() { if (mWebview.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) { final ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) mWebview .getLayoutParams();//w w w.ja v a 2 s. c o m final int startValueX = marginLayoutParams.leftMargin; final int endValueX = 0; //final float startValueAlpha = mWebview.getAlpha(); mWebview.clearAnimation(); Animation animation = new Animation() { @Override protected void applyTransformation(float interpolatedTime, Transformation t) { int leftMarginInterpolatedValue = (int) (startValueX + (endValueX - startValueX) * interpolatedTime); //float alphaInterpolatedValue = startValueAlpha -startValueAlpha * interpolatedTime; marginLayoutParams.leftMargin = leftMarginInterpolatedValue; marginLayoutParams.rightMargin = -leftMarginInterpolatedValue; //mWebview.setAlpha(alphaInterpolatedValue); mWebview.requestLayout(); } }; animation.setDuration(200); animation.setInterpolator(new DecelerateInterpolator()); mWebview.startAnimation(animation); } }
From source file:com.money.manager.ex.home.HomeFragment.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { switch (loader.getId()) { case LOADER_ACCOUNT_BILLS: try {//from w w w . j a v a2s .c o m renderAccountsList(data); } catch (Exception e) { Timber.e(e, "rendering account list"); } // set total for accounts in the main Drawer. EventBus.getDefault().post(new AccountsTotalLoadedEvent(txtTotalAccounts.getText().toString())); break; case LOADER_INCOME_EXPENSES: double income = 0, expenses = 0; if (data != null) { while (data.moveToNext()) { expenses = data.getDouble(data.getColumnIndex(IncomeVsExpenseReportEntity.Expenses)); income = data.getDouble(data.getColumnIndex(IncomeVsExpenseReportEntity.Income)); } } TextView txtIncome = (TextView) getActivity().findViewById(R.id.textViewIncome); TextView txtExpenses = (TextView) getActivity().findViewById(R.id.textViewExpenses); TextView txtDifference = (TextView) getActivity().findViewById(R.id.textViewDifference); // set value if (txtIncome != null) txtIncome.setText(mCurrencyService.getCurrencyFormatted(mCurrencyService.getBaseCurrencyId(), MoneyFactory.fromDouble(income))); if (txtExpenses != null) txtExpenses.setText(mCurrencyService.getCurrencyFormatted(mCurrencyService.getBaseCurrencyId(), MoneyFactory.fromDouble(Math.abs(expenses)))); if (txtDifference != null) txtDifference.setText(mCurrencyService.getCurrencyFormatted(mCurrencyService.getBaseCurrencyId(), MoneyFactory.fromDouble(income - Math.abs(expenses)))); // manage progressbar final ProgressBar barIncome = (ProgressBar) getActivity().findViewById(R.id.progressBarIncome); final ProgressBar barExpenses = (ProgressBar) getActivity().findViewById(R.id.progressBarExpenses); if (barIncome != null && barExpenses != null) { barIncome.setMax((int) (Math.abs(income) + Math.abs(expenses))); barExpenses.setMax((int) (Math.abs(income) + Math.abs(expenses))); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) { ObjectAnimator animationIncome = ObjectAnimator.ofInt(barIncome, "progress", (int) Math.abs(income)); animationIncome.setDuration(1000); // 0.5 second animationIncome.setInterpolator(new DecelerateInterpolator()); animationIncome.start(); ObjectAnimator animationExpenses = ObjectAnimator.ofInt(barExpenses, "progress", (int) Math.abs(expenses)); animationExpenses.setDuration(1000); // 0.5 second animationExpenses.setInterpolator(new DecelerateInterpolator()); animationExpenses.start(); } else { barIncome.setProgress((int) Math.abs(income)); barExpenses.setProgress((int) Math.abs(expenses)); } } break; } // Close the cursor. MmxDatabaseUtils.closeCursor(data); }
From source file:com.appolica.interactiveinfowindow.InfoWindowManager.java
private void internalHide(@NonNull final View container, @NonNull final InfoWindow toHideWindow, final boolean animated) { if (animated) { final Animation animation; if (hideAnimation == null) { final int containerWidth = container.getWidth(); final int containerHeight = container.getHeight(); final float pivotX = container.getX() + containerWidth / 2; final float pivotY = container.getY() + containerHeight; animation = new ScaleAnimation(1f, 0f, 1f, 0f, pivotX, pivotY); animation.setDuration(DURATION_WINDOW_ANIMATION); animation.setInterpolator(new DecelerateInterpolator()); } else {/* w w w .jav a 2s .c om*/ animation = hideAnimation; } animation.setAnimationListener(new SimpleAnimationListener() { @Override public void onAnimationStart(Animation animation) { toHideWindow.setWindowState(InfoWindow.State.HIDING); propagateShowEvent(toHideWindow, InfoWindow.State.HIDING); } @Override public void onAnimationEnd(Animation animation) { removeWindow(toHideWindow, container); if (container.getId() != InfoWindowManager.this.currentContainer.getId()) { parent.removeView(container); } toHideWindow.setWindowState(InfoWindow.State.HIDDEN); propagateShowEvent(toHideWindow, InfoWindow.State.HIDDEN); } }); this.currentContainer.startAnimation(animation); } else { removeWindow(toHideWindow, container); propagateShowEvent(toHideWindow, InfoWindow.State.HIDDEN); } }
From source file:com.android.camera.ActivityBase.java
private void onFullScreenChanged(boolean full) { if (mShowCameraAppView == full) return;/*from w ww . j av a 2 s . co m*/ mShowCameraAppView = full; if (mPaused || isFinishing()) return; // Initialize the animation. if (mHideCameraAppView == null) { mHideCameraAppView = new HideCameraAppView(); mCameraAppView.animate().setInterpolator(new DecelerateInterpolator()); } updateCameraAppView(); // If we received DELETE_PICTURE broadcasts while the Camera UI is // hidden, we update the thumbnail now. if (full && mUpdateThumbnailDelayed) { getLastThumbnailUncached(); mUpdateThumbnailDelayed = false; } }
From source file:com.adityarathi.muo.ui.activities.NowPlayingActivity.java
/** * Animates the play button to a pause button. *///from ww w .j av a2 s.co m private void animatePlayToPause() { //Check to make sure the current icon is the play icon. if (mPlayPauseButton.getId() != R.drawable.ic_play) return; //Fade out the play button. final ScaleAnimation scaleOut = new ScaleAnimation(1.0f, 0.0f, 1.0f, 0.0f, mPlayPauseButton.getWidth() / 2, mPlayPauseButton.getHeight() / 2); scaleOut.setDuration(150); scaleOut.setInterpolator(new AccelerateInterpolator()); //Scale in the pause button. final ScaleAnimation scaleIn = new ScaleAnimation(0.0f, 1.0f, 0.0f, 1.0f, mPlayPauseButton.getWidth() / 2, mPlayPauseButton.getHeight() / 2); scaleIn.setDuration(150); scaleIn.setInterpolator(new DecelerateInterpolator()); scaleOut.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { mPlayPauseButton.setImageResource(R.drawable.ic_play); mPlayPauseButton.setPadding(0, 0, 0, 0); mPlayPauseButton.startAnimation(scaleIn); } @Override public void onAnimationRepeat(Animation animation) { } }); scaleIn.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { mPlayPauseButton.setScaleX(1.0f); mPlayPauseButton.setScaleY(1.0f); mPlayPauseButton.setId(R.drawable.ic_play); } @Override public void onAnimationRepeat(Animation animation) { } }); mPlayPauseButton.startAnimation(scaleOut); }
From source file:com.gsoc.ijosa.liquidgalaxycontroller.PW.NearbyBeaconsFragment.java
private void showListView() { if (getListView() != null) { if (getListView().getVisibility() == View.VISIBLE) { return; }//w w w . j ava 2s. c om mSwipeRefreshWidget.setRefreshing(false); getListView().setAlpha(0f); getListView().setVisibility(View.VISIBLE); safeNotifyChange(); ObjectAnimator alphaAnimation = ObjectAnimator.ofFloat(getListView(), "alpha", 0f, 1f); alphaAnimation.setDuration(400); alphaAnimation.setInterpolator(new DecelerateInterpolator()); alphaAnimation.addListener(new AnimatorListener() { @Override public void onAnimationStart(Animator animation) { } @Override public void onAnimationEnd(Animator animation) { mScanningAnimationTextView.setAlpha(0f); mScanningAnimationDrawable.stop(); arrowDownLayout.setVisibility(View.VISIBLE); } @Override public void onAnimationRepeat(Animator animation) { } @Override public void onAnimationCancel(Animator animation) { } }); alphaAnimation.start(); } }
From source file:com.nononsenseapps.feeder.ui.BaseActivity.java
protected void onActionBarAutoShowOrHide(boolean shown) { if (mStatusBarColorAnimator != null) { mStatusBarColorAnimator.cancel(); }// ww w. jav a2 s . co m mStatusBarColorAnimator = ObjectAnimator .ofInt(mLPreviewUtils, "statusBarColor", shown ? mThemedStatusBarColor : Color.BLACK) .setDuration(250); mStatusBarColorAnimator.setEvaluator(ARGB_EVALUATOR); mStatusBarColorAnimator.start(); for (View view : mHideableHeaderViews) { if (shown) { view.animate().translationY(0).alpha(1).setDuration(HEADER_HIDE_ANIM_DURATION) .setInterpolator(new DecelerateInterpolator()); } else { view.animate().translationY(-view.getBottom()).alpha(0).setDuration(HEADER_HIDE_ANIM_DURATION) .setInterpolator(new DecelerateInterpolator()); } } for (View view : mHideableFooterViews) { if (shown) { view.animate().translationY(0).alpha(1).setDuration(HEADER_HIDE_ANIM_DURATION) .setInterpolator(new DecelerateInterpolator()); } else { view.animate().translationY(view.getHeight()).alpha(0).setDuration(HEADER_HIDE_ANIM_DURATION) .setInterpolator(new DecelerateInterpolator()); } } }
From source file:xyz.template.material.menu.ui.fragment.SessionsFragment.java
public void animateReload() { int curTop = mCollectionView.getTop(); mCollectionView.setAlpha(0);//ww w .ja v a2s .c o m mCollectionView.setTop(getResources().getDimensionPixelSize(R.dimen.browse_sessions_anim_amount)); mCollectionView.animate().y(curTop).alpha(1).setDuration(ANIM_DURATION) .setInterpolator(new DecelerateInterpolator()); mCollectionView.animate().alpha(1).setDuration(ANIM_DURATION).setInterpolator(new DecelerateInterpolator()); }
From source file:com.google.samples.apps.iosched.ui.SessionsFragment.java
public void animateReload() { //int curTop = mCollectionView.getTop(); mCollectionView.setAlpha(0);//from ww w.j a v a2s . c om //mCollectionView.setTop(getResources().getDimensionPixelSize(R.dimen.browse_sessions_anim_amount)); //mCollectionView.animate().y(curTop).alpha(1).setDuration(ANIM_DURATION).setInterpolator(new DecelerateInterpolator()); mCollectionView.animate().alpha(1).setDuration(ANIM_DURATION).setInterpolator(new DecelerateInterpolator()); }
From source file:com.arlib.floatingsearchview.util.view.MenuView.java
/** * Shows all the menu items that were hidden by hideIfRoomItems(boolean withAnim) * * @param withAnim//w w w . ja v a 2s. com */ public void showIfRoomItems(boolean withAnim) { if (mMenu == -1) return; cancelChildAnimListAndClear(); if (mMenuItems.isEmpty()) return; anims = new ArrayList<>(); for (int i = 0; i < getChildCount(); i++) { final View currentView = getChildAt(i); if (i < mActionItems.size()) { ImageView action = (ImageView) currentView; final MenuItem actionItem = mActionItems.get(i); action.setImageDrawable(Util.setIconColor(actionItem.getIcon(), mActionIconColor)); action.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mMenuCallback != null) mMenuCallback.onMenuItemSelected(mMenuBuilder, actionItem); } }); } //todo go over logic int animDuration = withAnim ? SHOW_IF_ROOM_ITEMS_ANIM_DURATION : 0; Interpolator interpolator = new DecelerateInterpolator(); //todo check logic if (i > mActionShowAlwaysItems.size() - 1) interpolator = new LinearInterpolator(); currentView.setClickable(true); anims.add(ViewPropertyObjectAnimator.animate(currentView).addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { currentView.setTranslationX(0); } }).setInterpolator(interpolator).setDuration(animDuration).translationX(0).get()); anims.add(ViewPropertyObjectAnimator.animate(currentView).addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { currentView.setScaleX(1.0f); } }).setInterpolator(interpolator).setDuration(animDuration).scaleX(1.0f).get()); anims.add(ViewPropertyObjectAnimator.animate(currentView).addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { currentView.setScaleY(1.0f); } }).setInterpolator(interpolator).setDuration(animDuration).scaleY(1.0f).get()); anims.add(ViewPropertyObjectAnimator.animate(currentView).addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { currentView.setAlpha(1.0f); } }).setInterpolator(interpolator).setDuration(animDuration).alpha(1.0f).get()); } AnimatorSet animSet = new AnimatorSet(); //temporary, from laziness if (!withAnim) animSet.setDuration(0); animSet.playTogether(anims.toArray(new ObjectAnimator[anims.size()])); animSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (mOnVisibleWidthChanged != null) mOnVisibleWidthChanged.onVisibleWidthChanged( (getChildCount() * (int) ACTION_DIMENSION_PX) - (mHasOverflow ? Util.dpToPx(8) : 0)); } }); animSet.start(); }