List of usage examples for android.view.animation DecelerateInterpolator DecelerateInterpolator
public DecelerateInterpolator()
From source file:android.support.v7.internal.widget.ActionBarContextView.java
private ViewPropertyAnimatorCompatSet makeInAnimation() { ViewCompat.setTranslationX(mClose,// w w w .j a v a2s .c om -mClose.getWidth() - ((MarginLayoutParams) mClose.getLayoutParams()).leftMargin); ViewPropertyAnimatorCompat buttonAnimator = ViewCompat.animate(mClose).translationX(0); buttonAnimator.setDuration(200); buttonAnimator.setListener(this); buttonAnimator.setInterpolator(new DecelerateInterpolator()); ViewPropertyAnimatorCompatSet set = new ViewPropertyAnimatorCompatSet(); set.play(buttonAnimator); if (mMenuView != null) { final int count = mMenuView.getChildCount(); if (count > 0) { for (int i = count - 1, j = 0; i >= 0; i--, j++) { View child = mMenuView.getChildAt(i); ViewCompat.setScaleY(child, 0); ViewPropertyAnimatorCompat a = ViewCompat.animate(child).scaleY(1); a.setDuration(300); set.play(a); } } } return set; }
From source file:com.anyline.reactnative.DocumentActivity.java
private void showErrorMessageUiAnimated(String message) { if (lastErrorRecieved == 0) { // the cleanup takes care of removing the message after some time if the error did not show up again handler.post(errorMessageCleanup); }/*w w w.ja va2 s . c o m*/ lastErrorRecieved = System.currentTimeMillis(); if (errorMessageAnimator != null && (errorMessageAnimator.isRunning() || errorMessage.getText().equals(message))) { return; } errorMessageLayout.setVisibility(View.VISIBLE); errorMessage.setBackgroundColor(ContextCompat.getColor(this, getResources().getIdentifier("anyline_blue_darker", "color", getPackageName()))); errorMessage.setAlpha(0f); errorMessage.setText(message); errorMessageAnimator = ObjectAnimator.ofFloat(errorMessage, "alpha", 0f, 1f); errorMessageAnimator.setDuration(getResources() .getInteger(getResources().getIdentifier("error_message_delay", "integer", getPackageName()))); errorMessageAnimator.setInterpolator(new DecelerateInterpolator()); errorMessageAnimator.start(); }
From source file:com.crazymin2.retailstore.ui.BaseActivity.java
protected void onActionBarAutoShowOrHide(boolean shown) { if (mStatusBarColorAnimator != null) { mStatusBarColorAnimator.cancel(); }//w w w. j a v a 2 s. com mStatusBarColorAnimator.setEvaluator(ARGB_EVALUATOR); mStatusBarColorAnimator.start(); updateSwipeRefreshProgressBarTop(); for (final View view : mHideableHeaderViews) { if (shown) { ViewCompat.animate(view).translationY(0).alpha(1).setDuration(HEADER_HIDE_ANIM_DURATION) .setInterpolator(new DecelerateInterpolator()) // Setting Alpha animations should be done using the // layer_type set to layer_type_hardware for the duration of the animation. .withLayer(); } else { ViewCompat.animate(view).translationY(-view.getBottom()).alpha(0) .setDuration(HEADER_HIDE_ANIM_DURATION).setInterpolator(new DecelerateInterpolator()) // Setting Alpha animations should be done using the // layer_type set to layer_type_hardware for the duration of the animation. .withLayer(); } } }
From source file:com.actionbarsherlock.internal.widget.ActionBarContextView.java
private Animator makeInAnimation() { mClose.setTranslationX(-mClose.getWidth() - ((MarginLayoutParams) mClose.getLayoutParams()).leftMargin); ObjectAnimator buttonAnimator = ObjectAnimator.ofFloat(mClose, "translationX", 0); buttonAnimator.setDuration(200);/* w w w . j a v a 2s. c om*/ buttonAnimator.addListener(this); buttonAnimator.setInterpolator(new DecelerateInterpolator()); AnimatorSet set = new AnimatorSet(); AnimatorSet.Builder b = set.play(buttonAnimator); if (mMenuView != null) { final int count = mMenuView.getChildCount(); if (count > 0) { for (int i = count - 1, j = 0; i >= 0; i--, j++) { AnimatorProxy child = AnimatorProxy.wrap(mMenuView.getChildAt(i)); child.setScaleY(0); ObjectAnimator a = ObjectAnimator.ofFloat(child, "scaleY", 0, 1); a.setDuration(100); a.setStartDelay(j * 70); b.with(a); } } } return set; }
From source file:com.money.manager.ex.fragment.HomeFragment.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { MainActivity mainActivity = null;/*from w w w.j a va 2s. com*/ if (getActivity() != null && getActivity() instanceof MainActivity) mainActivity = (MainActivity) getActivity(); switch (loader.getId()) { case ID_LOADER_USER_NAME: if (data != null && data.moveToFirst()) { while (data.isAfterLast() == false) { String infoValue = data.getString(data.getColumnIndex(infoTable.INFONAME)); // save into preferences username and basecurrency id if (Constants.INFOTABLE_USERNAME.equalsIgnoreCase(infoValue)) { application.setUserName(data.getString(data.getColumnIndex(infoTable.INFOVALUE))); } else if (Constants.INFOTABLE_BASECURRENCYID.equalsIgnoreCase(infoValue)) { //application.setBaseCurrencyId(data.getInt(data.getColumnIndex(infoTable.INFOVALUE))); } data.moveToNext(); } } // show username if (!TextUtils.isEmpty(application.getUserName())) ((SherlockFragmentActivity) getActivity()).getSupportActionBar() .setSubtitle(application.getUserName()); // set user name on drawer if (mainActivity != null) mainActivity.setDrawableUserName(application.getUserName()); break; case ID_LOADER_ACCOUNT_BILLS: double curTotal = 0, curReconciled = 0; AccountBillsAdapter adapter = null; linearHome.setVisibility(data != null && data.getCount() > 0 ? View.VISIBLE : View.GONE); linearWelcome.setVisibility(linearHome.getVisibility() == View.GONE ? View.VISIBLE : View.GONE); // cycle cursor if (data != null && data.moveToFirst()) { while (data.isAfterLast() == false) { curTotal += data.getDouble(data.getColumnIndex(QueryAccountBills.TOTALBASECONVRATE)); curReconciled += data.getDouble(data.getColumnIndex(QueryAccountBills.RECONCILEDBASECONVRATE)); data.moveToNext(); } // create adapter adapter = new AccountBillsAdapter(getActivity(), data); } // write accounts total txtTotalAccounts.setText(currencyUtils.getBaseCurrencyFormatted(curTotal)); // manage footer listview if (linearFooter == null) { linearFooter = (LinearLayout) getActivity().getLayoutInflater().inflate(R.layout.item_account_bills, null); // textview into layout txtFooterSummary = (TextView) linearFooter.findViewById(R.id.textVievItemAccountTotal); txtFooterSummaryReconciled = (TextView) linearFooter .findViewById(R.id.textVievItemAccountTotalReconciled); // set text TextView txtTextSummary = (TextView) linearFooter.findViewById(R.id.textVievItemAccountName); txtTextSummary.setText(R.string.summary); // invisibile image ImageView imgSummary = (ImageView) linearFooter.findViewById(R.id.imageViewAccountType); imgSummary.setVisibility(View.INVISIBLE); // set color textview txtTextSummary.setTextColor(Color.GRAY); txtFooterSummary.setTextColor(Color.GRAY); txtFooterSummaryReconciled.setTextColor(Color.GRAY); } // remove footer lstAccountBills.removeFooterView(linearFooter); // set text txtFooterSummary.setText(txtTotalAccounts.getText()); txtFooterSummaryReconciled.setText(currencyUtils.getBaseCurrencyFormatted(curReconciled)); // add footer lstAccountBills.addFooterView(linearFooter, null, false); // set adapter and shown lstAccountBills.setAdapter(adapter); setListViewAccountBillsVisible(true); // set total accounts in drawer if (mainActivity != null) { mainActivity.setDrawableTotalAccounts(txtTotalAccounts.getText().toString()); } break; case ID_LOADER_BILL_DEPOSITS: mainActivity.setDrawableRepeatingTransactions(data != null ? data.getCount() : 0); break; case ID_LOADER_INCOME_EXPENSES: double income = 0, expenses = 0; if (data != null && data.moveToFirst()) { while (!data.isAfterLast()) { expenses = data.getDouble(data.getColumnIndex(QueryReportIncomeVsExpenses.Expenses)); income = data.getDouble(data.getColumnIndex(QueryReportIncomeVsExpenses.Income)); //move to next record data.moveToNext(); } } 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(currencyUtils.getCurrencyFormatted(currencyUtils.getBaseCurrencyId(), income)); if (txtExpenses != null) txtExpenses.setText( currencyUtils.getCurrencyFormatted(currencyUtils.getBaseCurrencyId(), Math.abs(expenses))); if (txtDifference != null) txtDifference.setText(currencyUtils.getCurrencyFormatted(currencyUtils.getBaseCurrencyId(), 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)); } } } }
From source file:android.support.v17.leanback.widget.AbstractMediaItemPresenter.java
/** * Each media item row can have multiple focusable elements; the details on the left and a set * of optional custom actions on the right. * The selector is a highlight that moves to highlight to cover whichever views is in focus. * * @param selectorView the selector view used to highlight an individual element within a row. * @param focusChangedView The component within the media row whose focus got changed. * @param layoutAnimator the ValueAnimator producing animation frames for the selector's width * and x-translation, generated by this method and stored for the each * {@link ViewHolder}. * @param isDetails Whether the changed-focused view is for a media item details (true) or * an action (false)./*from w w w . j a va 2 s . c om*/ */ private static ValueAnimator updateSelector(final View selectorView, View focusChangedView, ValueAnimator layoutAnimator, boolean isDetails) { int animationDuration = focusChangedView.getContext().getResources() .getInteger(android.R.integer.config_shortAnimTime); DecelerateInterpolator interpolator = new DecelerateInterpolator(); int layoutDirection = ViewCompat.getLayoutDirection(selectorView); if (!focusChangedView.hasFocus()) { // if neither of the details or action views are in focus (ie. another row is in focus), // animate the selector out. selectorView.animate().cancel(); selectorView.animate().alpha(0f).setDuration(animationDuration).setInterpolator(interpolator).start(); // keep existing layout animator return layoutAnimator; } else { // cancel existing layout animator if (layoutAnimator != null) { layoutAnimator.cancel(); layoutAnimator = null; } float currentAlpha = selectorView.getAlpha(); selectorView.animate().alpha(1f).setDuration(animationDuration).setInterpolator(interpolator).start(); final ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) selectorView.getLayoutParams(); ViewGroup rootView = (ViewGroup) selectorView.getParent(); sTempRect.set(0, 0, focusChangedView.getWidth(), focusChangedView.getHeight()); rootView.offsetDescendantRectToMyCoords(focusChangedView, sTempRect); if (isDetails) { if (layoutDirection == View.LAYOUT_DIRECTION_RTL) { sTempRect.right += rootView.getHeight(); sTempRect.left -= rootView.getHeight() / 2; } else { sTempRect.left -= rootView.getHeight(); sTempRect.right += rootView.getHeight() / 2; } } final int targetLeft = sTempRect.left; final int targetWidth = sTempRect.width(); final float deltaWidth = lp.width - targetWidth; final float deltaLeft = lp.leftMargin - targetLeft; if (deltaLeft == 0f && deltaWidth == 0f) { // no change needed } else if (currentAlpha == 0f) { // change selector to the proper width and marginLeft without animation. lp.width = targetWidth; lp.leftMargin = targetLeft; selectorView.requestLayout(); } else { // animate the selector to the proper width and marginLeft. layoutAnimator = ValueAnimator.ofFloat(0f, 1f); layoutAnimator.setDuration(animationDuration); layoutAnimator.setInterpolator(interpolator); layoutAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { // Set width to the proper width for this animation step. float fractionToEnd = 1f - valueAnimator.getAnimatedFraction(); lp.leftMargin = Math.round(targetLeft + deltaLeft * fractionToEnd); lp.width = Math.round(targetWidth + deltaWidth * fractionToEnd); selectorView.requestLayout(); } }); layoutAnimator.start(); } return layoutAnimator; } }
From source file:com.anyline.reactnative.DocumentActivity.java
private void showHighlightErrorMessageUiAnimated(String message) { lastErrorRecieved = System.currentTimeMillis(); errorMessageLayout.setVisibility(View.VISIBLE); errorMessage.setBackgroundColor(ContextCompat.getColor(this, getResources().getIdentifier("anyline_red", "color", getPackageName()))); errorMessage.setAlpha(0f);/*from w w w . j a v a 2 s. c o m*/ errorMessage.setText(message); if (errorMessageAnimator != null && errorMessageAnimator.isRunning()) { errorMessageAnimator.cancel(); } errorMessageAnimator = ObjectAnimator.ofFloat(errorMessage, "alpha", 0f, 1f); errorMessageAnimator.setDuration(getResources() .getInteger(getResources().getIdentifier("error_message_delay", "integer", getPackageName()))); errorMessageAnimator.setInterpolator(new DecelerateInterpolator()); errorMessageAnimator.setRepeatMode(ValueAnimator.REVERSE); errorMessageAnimator.setRepeatCount(1); errorMessageAnimator.start(); }
From source file:android.support.v7.internal.widget.ActionBarContextView.java
private ViewPropertyAnimatorCompatSet makeOutAnimation() { ViewPropertyAnimatorCompat buttonAnimator = ViewCompat.animate(mClose) .translationX(-mClose.getWidth() - ((MarginLayoutParams) mClose.getLayoutParams()).leftMargin); buttonAnimator.setDuration(200);// ww w . j a v a 2 s. c om buttonAnimator.setListener(this); buttonAnimator.setInterpolator(new DecelerateInterpolator()); ViewPropertyAnimatorCompatSet set = new ViewPropertyAnimatorCompatSet(); set.play(buttonAnimator); if (mMenuView != null) { final int count = mMenuView.getChildCount(); if (count > 0) { for (int i = 0; i < 0; i++) { View child = mMenuView.getChildAt(i); ViewCompat.setScaleY(child, 1); ViewPropertyAnimatorCompat a = ViewCompat.animate(child).scaleY(0); a.setDuration(300); set.play(a); } } } return set; }
From source file:com.android.deskclock.timer.TimerFragment.java
/** * @param timerToRemove the timer to be removed during the animation *///from ww w . ja va 2s . c o m private void animateTimerRemove(final Timer timerToRemove) { final Animator fadeOut = ObjectAnimator.ofFloat(mViewPager, ALPHA, 1, 0); fadeOut.setDuration(mShortAnimationDuration); fadeOut.setInterpolator(new DecelerateInterpolator()); fadeOut.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { DataModel.getDataModel().removeTimer(timerToRemove); Events.sendTimerEvent(R.string.action_delete, R.string.label_deskclock); } }); final Animator fadeIn = ObjectAnimator.ofFloat(mViewPager, ALPHA, 0, 1); fadeIn.setDuration(mShortAnimationDuration); fadeIn.setInterpolator(new AccelerateInterpolator()); final AnimatorSet animatorSet = new AnimatorSet(); animatorSet.play(fadeOut).before(fadeIn); animatorSet.start(); }
From source file:com.adityarathi.muo.ui.activities.NowPlayingActivity.java
/** * Animates the pause button to a play button. *//*from w ww . j a va 2 s . c om*/ private void animatePauseToPlay() { //Check to make sure the current icon is the pause icon. if (mPlayPauseButton.getId() != R.drawable.ic_play) return; //Scale out the pause 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 play 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, -5, 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); }