List of usage examples for android.animation ObjectAnimator setDuration
@Override @NonNull public ObjectAnimator setDuration(long duration)
From source file:io.doist.datetimepicker.time.RadialTimePickerView.java
private static ObjectAnimator getFadeOutAnimator(IntHolder target, int startAlpha, int endAlpha, InvalidateUpdateListener updateListener) { int duration = 500; ObjectAnimator animator = ObjectAnimator.ofInt(target, "value", startAlpha, endAlpha); animator.setDuration(duration); animator.addUpdateListener(updateListener); return animator; }
From source file:org.mozilla.focus.fragment.UrlInputFragment.java
/** * Play animation between home screen and the URL input. *///from www .ja v a2 s . com private void playHomeScreenAnimation(final boolean reverse) { int[] screenLocation = new int[2]; urlInputContainerView.getLocationOnScreen(screenLocation); int leftDelta = getArguments().getInt(ARGUMENT_X) - screenLocation[0]; int topDelta = getArguments().getInt(ARGUMENT_Y) - screenLocation[1]; float widthScale = (float) getArguments().getInt(ARGUMENT_WIDTH) / urlInputContainerView.getWidth(); float heightScale = (float) getArguments().getInt(ARGUMENT_HEIGHT) / urlInputContainerView.getHeight(); if (!reverse) { // Move all views to the position of the fake URL bar on the home screen. Hide them until // the animation starts because we need to switch between fake URL bar and the actual URL // bar once the animation starts. urlInputContainerView.setAlpha(0); urlInputContainerView.setPivotX(0); urlInputContainerView.setPivotY(0); urlInputContainerView.setScaleX(widthScale); urlInputContainerView.setScaleY(heightScale); urlInputContainerView.setTranslationX(leftDelta); urlInputContainerView.setTranslationY(topDelta); urlInputContainerView.setAnimationOffset(1.0f); toolbarBackgroundView.setAlpha(0); dismissView.setAlpha(0); } // Move the URL bar from its position on the home screen to the actual position (and scale it). urlInputContainerView.animate().setDuration(ANIMATION_DURATION).scaleX(reverse ? widthScale : 1) .scaleY(reverse ? heightScale : 1).translationX(reverse ? leftDelta : 0) .translationY(reverse ? topDelta : 0).setInterpolator(new DecelerateInterpolator()) .setListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { ViewUtils.updateAlphaIfViewExists(getActivity(), R.id.fake_urlbar, 0f); urlInputContainerView.setAlpha(1); if (reverse) { urlView.setText(""); urlView.setCursorVisible(false); urlView.clearFocus(); } } @Override public void onAnimationEnd(Animator animation) { if (reverse) { urlInputContainerView.setAlpha(0f); ViewUtils.updateAlphaIfViewExists(getActivity(), R.id.fake_urlbar, 1f); dismiss(); } else { urlView.setCursorVisible(true); } } }); final ObjectAnimator hintAnimator = ObjectAnimator.ofFloat(urlInputContainerView, "animationOffset", reverse ? 0f : 1f, reverse ? 1f : 0f); hintAnimator.setDuration(ANIMATION_DURATION); hintAnimator.start(); // Let the toolbar background come int from the top toolbarBackgroundView.animate().alpha(reverse ? 0 : 1).setDuration(ANIMATION_DURATION) .setInterpolator(new DecelerateInterpolator()); // Use an alpha animation on the transparent black background dismissView.animate().alpha(reverse ? 0 : 1).setDuration(ANIMATION_DURATION); }
From source file:com.example.android.tryanimationt.TryAnimationFragment.java
void animButtons(ImageButton bt, boolean in, int animTime, int delay) { //delay = 0;//w w w. j a v a 2 s . c om float rotateStart, rotateEnd; float scaleXStart, scaleXEnd; float scaleYStart, scaleYEnd; float transitionXStart, transitionXEnd; float transitionYStart, transitionYEnd; if (in) { rotateStart = 0; rotateEnd = 359; scaleXStart = 0.66f; scaleXEnd = 1; scaleYStart = 0.66f; scaleYEnd = 1; transitionXStart = 60; transitionXEnd = 0; transitionYStart = 10; transitionYEnd = 0; } else { rotateStart = 359; rotateEnd = 0; scaleXStart = 1; scaleXEnd = 0.66f; scaleYStart = 1; scaleYEnd = 0.66f; transitionXStart = 0; transitionXEnd = 60; transitionYStart = 0; transitionYEnd = 10; } bt.setTranslationX(transitionXStart); bt.setTranslationY(transitionYStart); AnimatorSet animSet = new AnimatorSet(); ObjectAnimator animRotate = ObjectAnimator.ofFloat(bt, "rotation", rotateStart, rotateEnd); animRotate.setDuration(animTime); ObjectAnimator animScaleX = ObjectAnimator.ofFloat(bt, "scaleX", scaleXStart, scaleXEnd); animScaleX.setDuration(animTime); animScaleX.setStartDelay(Math.round(delay * 0.66)); ObjectAnimator animScaleY = ObjectAnimator.ofFloat(bt, "scaleY", scaleYStart, scaleYEnd); animScaleY.setDuration(animTime); animScaleY.setStartDelay(Math.round(delay * 0.66)); ObjectAnimator animTrx = ObjectAnimator.ofFloat(bt, "translationX", transitionXStart, transitionXEnd); animTrx.setDuration(animTime); animTrx.setStartDelay(delay); ObjectAnimator animTry = ObjectAnimator.ofFloat(bt, "translationY", transitionYStart, transitionYEnd); animTry.setDuration(animTime); animTry.setStartDelay(delay); animSet.setInterpolator(new BounceInterpolator()); animSet.playTogether(animRotate, animScaleX, animScaleY, animTrx, animTry); animSet.start(); }
From source file:com.bluros.music.nowplaying.BaseNowplayingFragment.java
public void changeDigit(TimelyView tv, int end) { ObjectAnimator obja = tv.animate(end); obja.setDuration(400); obja.start(); }
From source file:com.zhangyp.higo.drawingboard.fragment.SketchFragment.java
private void init(Bitmap bitmap) { float scaleRatio = 1; int width = bitmap.getWidth(); int height = bitmap.getHeight(); float screenRatio = 1.0f; float imgRatio = (float) height / (float) width; if (imgRatio >= screenRatio) { //?// w w w .jav a 2s . c om scaleRatio = (float) mScreenWidth / (float) height; } if (imgRatio < screenRatio) { scaleRatio = (float) mScreenWidth / (float) width; } Matrix matrix = new Matrix(); matrix.postScale(scaleRatio, scaleRatio); Bitmap dstbmp = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true); GPUImage gpuImage = new GPUImage(getActivity()); gpuImage.setFilter(new GPUImageSketchFilter()); final Bitmap grayBmp = gpuImage.getBitmapWithFilterApplied(dstbmp); ivBg.setImageBitmap(grayBmp); mSketchView.getBackground().setAlpha(150); ivBgColor.setImageBitmap(dstbmp); ObjectAnimator alpha = ObjectAnimator.ofFloat(ivBgColor, "alpha", 1.0f, 0.0f); alpha.setDuration(2000).start(); btShowBg.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { ObjectAnimator alpha = ObjectAnimator.ofFloat(ivBgColor, "alpha", 0.0f, 1.0f); alpha.setDuration(1000).start(); } }); btShowBgGray.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { ObjectAnimator alpha = ObjectAnimator.ofFloat(ivBgColor, "alpha", 1.0f, 0.0f); alpha.setDuration(1000).start(); } }); }
From source file:org.codeforafrica.citizenreporter.eNCA.widgets.SlidingTabLayout.java
public void setBadge(int position, boolean isBadged) { final View badgeView = mTabStrip.findViewWithTag(makeBadgeTag(position)); if (badgeView == null) { return;/* ww w . j a v a 2 s .c o m*/ } boolean wasBadged = (badgeView.getVisibility() == View.VISIBLE); if (isBadged == wasBadged) { return; } float start = isBadged ? 0f : 1f; float end = isBadged ? 1f : 0f; PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat(View.SCALE_X, start, end); PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat(View.SCALE_Y, start, end); ObjectAnimator animScale = ObjectAnimator.ofPropertyValuesHolder(badgeView, scaleX, scaleY); if (isBadged) { animScale.setInterpolator(new BounceInterpolator()); animScale.setDuration(getContext().getResources().getInteger(android.R.integer.config_longAnimTime)); animScale.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { badgeView.setVisibility(View.VISIBLE); } }); } else { animScale.setInterpolator(new AccelerateInterpolator()); animScale.setDuration(getContext().getResources().getInteger(android.R.integer.config_shortAnimTime)); animScale.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { badgeView.setVisibility(View.GONE); } }); } animScale.start(); }
From source file:com.waz.zclient.views.menus.ConfirmationMenu.java
public void animateToShow(boolean show) { if (show) {/* w ww . ja v a 2 s. c o m*/ confirmed = false; cancelled = false; // Init views and post animations to get measured height of message container backgroundView.setAlpha(0); messageContainerView.setVisibility(INVISIBLE); setVisibility(VISIBLE); messageContainerView.post(new Runnable() { @Override public void run() { ObjectAnimator showBackgroundAnimator = ObjectAnimator.ofFloat(backgroundView, View.ALPHA, 0, 1); showBackgroundAnimator.setInterpolator(new Quart.EaseOut()); showBackgroundAnimator .setDuration(getResources().getInteger(R.integer.framework_animation_duration_short)); ObjectAnimator showMessageAnimator = ObjectAnimator.ofFloat(messageContainerView, View.TRANSLATION_Y, messageContainerView.getMeasuredHeight(), 0); showMessageAnimator.setInterpolator(new Expo.EaseOut()); showMessageAnimator .setDuration(getResources().getInteger(R.integer.framework_animation_duration_medium)); showMessageAnimator.setStartDelay(getResources() .getInteger(R.integer.framework_animation__confirmation_menu__show_message_delay)); showMessageAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { messageContainerView.setVisibility(VISIBLE); } }); AnimatorSet showSet = new AnimatorSet(); showSet.playTogether(showBackgroundAnimator, showMessageAnimator); showSet.setDuration(getResources() .getInteger(R.integer.background_accent_color_transition_animation_duration)); showSet.start(); } }); } else { ObjectAnimator hideBackgroundAnimator = ObjectAnimator.ofFloat(backgroundView, View.ALPHA, 1, 0); hideBackgroundAnimator.setInterpolator(new Quart.EaseOut()); hideBackgroundAnimator .setDuration(getResources().getInteger(R.integer.framework_animation_duration_short)); hideBackgroundAnimator.setStartDelay(getResources() .getInteger(R.integer.framework_animation__confirmation_menu__hide_background_delay)); hideBackgroundAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { setVisibility(GONE); boolean checkboxIsSelected = checkBoxView.getVisibility() == VISIBLE && checkBoxView.isSelected(); if (callback != null) { callback.onHideAnimationEnd(confirmed, cancelled, checkboxIsSelected); } } }); ObjectAnimator hideMessageAnimator = ObjectAnimator.ofFloat(messageContainerView, View.TRANSLATION_Y, 0, messageContainerView.getMeasuredHeight()); hideMessageAnimator.setInterpolator(new Expo.EaseIn()); hideMessageAnimator .setDuration(getResources().getInteger(R.integer.framework_animation_duration_medium)); AnimatorSet hideSet = new AnimatorSet(); hideSet.playTogether(hideMessageAnimator, hideBackgroundAnimator); hideSet.start(); } }
From source file:com.bluros.music.nowplaying.BaseNowplayingFragment.java
public void changeDigit(TimelyView tv, int start, int end) { try {/*from w w w .j a v a2 s.c om*/ ObjectAnimator obja = tv.animate(start, end); obja.setDuration(400); obja.start(); } catch (InvalidParameterException e) { e.printStackTrace(); } }
From source file:com.google.android.apps.santatracker.village.Village.java
private void showEasterEgg() { ObjectAnimator anim = ObjectAnimator.ofFloat(mImageUfo, "size", 0f, 1.0f); anim.setInterpolator(new DecelerateInterpolator()); anim.setDuration(ImageWithAlphaAndSize.ANIM_DURATION); anim.start();//w w w .j a va2s. c o m mImageUfo.setAlpha(ImageWithAlphaAndSize.OPAQUE); // [ANALYTICS EVENT]: Village Click AnalyticsManager.sendEvent(R.string.analytics_event_category_village, R.string.analytics_event_village_unlock_easteregg); }
From source file:com.money.manager.ex.fragment.HomeFragment.java
@Override public void onLoadFinished(Loader<Cursor> loader, Cursor data) { MainActivity mainActivity = null;/* www. j a v a 2 s . co m*/ 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)); } } } }