List of usage examples for android.animation ObjectAnimator setDuration
@Override @NonNull public ObjectAnimator setDuration(long duration)
From source file:com.klinker.android.sliding.MultiShrinkScroller.java
public void reverseExpansionAnimation() { final Interpolator interpolator; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { interpolator = AnimationUtils.loadInterpolator(getContext(), android.R.interpolator.linear_out_slow_in); } else {/*from ww w. j a v a 2 s . c om*/ interpolator = new DecelerateInterpolator(); } WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size); int screenHeight = size.y; int screenWidth = size.x; final ValueAnimator heightExpansion = ValueAnimator.ofInt(screenHeight, expansionViewHeight); heightExpansion.setInterpolator(interpolator); heightExpansion.setDuration(ANIMATION_DURATION); heightExpansion.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { int val = (int) animation.getAnimatedValue(); ViewGroup.LayoutParams params = getLayoutParams(); params.height = val; setLayoutParams(params); } }); heightExpansion.start(); final ValueAnimator widthExpansion = ValueAnimator.ofInt(getWidth(), expansionViewWidth); widthExpansion.setInterpolator(interpolator); widthExpansion.setDuration(ANIMATION_DURATION); widthExpansion.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { int val = (int) animation.getAnimatedValue(); ViewGroup.LayoutParams params = getLayoutParams(); params.width = val; setLayoutParams(params); } }); widthExpansion.start(); ObjectAnimator translationX = ObjectAnimator.ofFloat(this, View.TRANSLATION_X, 0f, expansionLeftOffset); translationX.setInterpolator(interpolator); translationX.setDuration(ANIMATION_DURATION); translationX.start(); ObjectAnimator translationY = ObjectAnimator.ofFloat(this, View.TRANSLATION_Y, 0f, expansionTopOffset); translationY.setInterpolator(interpolator); translationY.setDuration(ANIMATION_DURATION); translationY.addListener(exitAnimationListner); translationY.start(); }
From source file:com.klinker.android.sliding.MultiShrinkScroller.java
/** * Scroll the activity off the bottom of the screen. *//*from w ww . j av a 2s.com*/ public void scrollOffBottom() { isTouchDisabledForDismissAnimation = true; scroller.forceFinished(true); if (!willUseReverseExpansion()) { final Interpolator interpolator = new AcceleratingFlingInterpolator(EXIT_FLING_ANIMATION_DURATION_MS, getCurrentVelocity(), getScrollUntilOffBottom()); ObjectAnimator translateAnimation = ObjectAnimator.ofInt(this, "scroll", getScroll() - getScrollUntilOffBottom()); translateAnimation.setRepeatCount(0); translateAnimation.setInterpolator(interpolator); translateAnimation.setDuration(EXIT_FLING_ANIMATION_DURATION_MS); translateAnimation.addListener(exitAnimationListner); translateAnimation.start(); } else { reverseExpansionAnimation(); } if (listener != null) { listener.onStartScrollOffBottom(); } }
From source file:com.tengio.FloatingSearchView.java
private void transitionOutLeftSection(boolean withAnim) { switch (mLeftActionMode) { case LEFT_ACTION_MODE_SHOW_HAMBURGER: closeMenuDrawable(mMenuBtnDrawable, withAnim); break;/*from w w w .j ava 2s.c om*/ case LEFT_ACTION_MODE_SHOW_SEARCH: changeIcon(mLeftAction, mIconSearch, withAnim); break; case LEFT_ACTION_MODE_SHOW_HOME: //do nothing break; case LEFT_ACTION_MODE_NO_LEFT_ACTION: mLeftAction.setImageDrawable(mIconBackArrow); if (withAnim) { ObjectAnimator searchInputTransXAnim = ViewPropertyObjectAnimator.animate(mSearchInputParent) .translationX(-Util.dpToPx(LEFT_MENU_WIDTH_AND_MARGIN_START)).get(); ObjectAnimator scaleXArrowAnim = ViewPropertyObjectAnimator.animate(mLeftAction).scaleX(0.5f).get(); ObjectAnimator scaleYArrowAnim = ViewPropertyObjectAnimator.animate(mLeftAction).scaleY(0.5f).get(); ObjectAnimator fadeArrowAnim = ViewPropertyObjectAnimator.animate(mLeftAction).alpha(0.5f).get(); scaleXArrowAnim.setDuration(300); scaleYArrowAnim.setDuration(300); fadeArrowAnim.setDuration(300); scaleXArrowAnim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { //restore normal state mLeftAction.setScaleX(1.0f); mLeftAction.setScaleY(1.0f); mLeftAction.setAlpha(1.0f); mLeftAction.setVisibility(View.INVISIBLE); } }); AnimatorSet animSet = new AnimatorSet(); animSet.setDuration(350); animSet.playTogether(scaleXArrowAnim, scaleYArrowAnim, fadeArrowAnim, searchInputTransXAnim); animSet.start(); } else { mLeftAction.setVisibility(View.INVISIBLE); } break; } }
From source file:com.android.calendar.AllInOneActivity.java
@Override public void handleEvent(EventInfo event) { long displayTime = -1; if (event.eventType == EventType.GO_TO) { if ((event.extraLong & CalendarController.EXTRA_GOTO_BACK_TO_PREVIOUS) != 0) { mBackToPreviousView = true;//from w ww .j a va 2 s .c om } else if (event.viewType != mController.getPreviousViewType() && event.viewType != ViewType.EDIT) { // Clear the flag is change to a different view type mBackToPreviousView = false; } setMainPane(null, R.id.main_pane, event.viewType, event.startTime.toMillis(false), false); if (mSearchView != null) { mSearchView.clearFocus(); } if (mShowCalendarControls) { int animationSize = (mOrientation == Configuration.ORIENTATION_LANDSCAPE) ? mControlsAnimateWidth : mControlsAnimateHeight; boolean noControlsView = event.viewType == ViewType.MONTH || event.viewType == ViewType.AGENDA; if (mControlsMenu != null) { mControlsMenu.setVisible(!noControlsView); mControlsMenu.setEnabled(!noControlsView); } if (noControlsView || mHideControls) { // hide minimonth and calendar frag mShowSideViews = false; if (!mHideControls) { final ObjectAnimator slideAnimation = ObjectAnimator.ofInt(this, "controlsOffset", 0, animationSize); slideAnimation.addListener(mSlideAnimationDoneListener); slideAnimation.setDuration(mCalendarControlsAnimationTime); ObjectAnimator.setFrameDelay(0); slideAnimation.start(); } else { mMiniMonth.setVisibility(View.GONE); mCalendarsList.setVisibility(View.GONE); mMiniMonthContainer.setVisibility(View.GONE); } } else { // show minimonth and calendar frag mShowSideViews = true; mMiniMonth.setVisibility(View.VISIBLE); mCalendarsList.setVisibility(View.VISIBLE); mMiniMonthContainer.setVisibility(View.VISIBLE); if (!mHideControls && (mController.getPreviousViewType() == ViewType.MONTH || mController.getPreviousViewType() == ViewType.AGENDA)) { final ObjectAnimator slideAnimation = ObjectAnimator.ofInt(this, "controlsOffset", animationSize, 0); slideAnimation.setDuration(mCalendarControlsAnimationTime); ObjectAnimator.setFrameDelay(0); slideAnimation.start(); } } } displayTime = event.selectedTime != null ? event.selectedTime.toMillis(true) : event.startTime.toMillis(true); if (!mIsTabletConfig) { refreshActionbarTitle(displayTime); } } else if (event.eventType == EventType.VIEW_EVENT) { // If in Agenda view and "show_event_details_with_agenda" is "true", // do not create the event info fragment here, it will be created by the Agenda // fragment if (mCurrentView == ViewType.AGENDA && mShowEventDetailsWithAgenda) { if (event.startTime != null && event.endTime != null) { // Event is all day , adjust the goto time to local time if (event.isAllDay()) { Utils.convertAlldayUtcToLocal(event.startTime, event.startTime.toMillis(false), mTimeZone); Utils.convertAlldayUtcToLocal(event.endTime, event.endTime.toMillis(false), mTimeZone); } mController.sendEvent(this, EventType.GO_TO, event.startTime, event.endTime, event.selectedTime, event.id, ViewType.AGENDA, CalendarController.EXTRA_GOTO_TIME, null, null); } else if (event.selectedTime != null) { mController.sendEvent(this, EventType.GO_TO, event.selectedTime, event.selectedTime, event.id, ViewType.AGENDA); } } else { // TODO Fix the temp hack below: && mCurrentView != // ViewType.AGENDA if (event.selectedTime != null && mCurrentView != ViewType.AGENDA) { mController.sendEvent(this, EventType.GO_TO, event.selectedTime, event.selectedTime, -1, ViewType.CURRENT); } int response = event.getResponse(); if ((mCurrentView == ViewType.AGENDA && mShowEventInfoFullScreenAgenda) || ((mCurrentView == ViewType.DAY || (mCurrentView == ViewType.WEEK) || mCurrentView == ViewType.MONTH) && mShowEventInfoFullScreen)) { // start event info as activity Intent intent = new Intent(Intent.ACTION_VIEW); Uri eventUri = ContentUris.withAppendedId(Events.CONTENT_URI, event.id); intent.setData(eventUri); intent.setClass(this, EventInfoActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP); intent.putExtra(EXTRA_EVENT_BEGIN_TIME, event.startTime.toMillis(false)); intent.putExtra(EXTRA_EVENT_END_TIME, event.endTime.toMillis(false)); intent.putExtra(ATTENDEE_STATUS, response); startActivity(intent); } else { // start event info as a dialog EventInfoFragment fragment = new EventInfoFragment(this, event.id, event.startTime.toMillis(false), event.endTime.toMillis(false), response, true, EventInfoFragment.DIALOG_WINDOW_STYLE, null /* No reminders to explicitly pass in. */); fragment.setDialogParams(event.x, event.y, mActionBar.getHeight()); FragmentManager fm = getFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); // if we have an old popup replace it Fragment fOld = fm.findFragmentByTag(EVENT_INFO_FRAGMENT_TAG); if (fOld != null && fOld.isAdded()) { ft.remove(fOld); } ft.add(fragment, EVENT_INFO_FRAGMENT_TAG); ft.commit(); } } displayTime = event.startTime.toMillis(true); } else if (event.eventType == EventType.UPDATE_TITLE) { setTitleInActionBar(event); if (!mIsTabletConfig) { refreshActionbarTitle(mController.getTime()); } } updateSecondaryTitleFields(displayTime); }
From source file:com.android.launcher3.folder.Folder.java
public void animateOpen() { if (!(getParent() instanceof DragLayer)) return;// ww w . j a v a 2s. c om mContent.completePendingPageChanges(); if (!mDragInProgress) { // Open on the first page. mContent.snapToPageImmediately(0); } // This is set to true in close(), but isn't reset to false until onDropCompleted(). This // leads to an inconsistent state if you drag out of the folder and drag back in without // dropping. One resulting issue is that replaceFolderWithFinalItem() can be called twice. mDeleteFolderOnDropCompleted = false; Animator openFolderAnim = null; final Runnable onCompleteRunnable; if (!Utilities.ATLEAST_LOLLIPOP) { positionAndSizeAsIcon(); centerAboutIcon(); final ObjectAnimator oa = LauncherAnimUtils.ofViewAlphaAndScale(this, 1, 1, 1); oa.setDuration(mExpandDuration); openFolderAnim = oa; setLayerType(LAYER_TYPE_HARDWARE, null); onCompleteRunnable = new Runnable() { @Override public void run() { setLayerType(LAYER_TYPE_NONE, null); } }; } else { prepareReveal(); centerAboutIcon(); AnimatorSet anim = LauncherAnimUtils.createAnimatorSet(); int width = getPaddingLeft() + getPaddingRight() + mContent.getDesiredWidth(); int height = getFolderHeight(); float transX = -0.075f * (width / 2 - getPivotX()); float transY = -0.075f * (height / 2 - getPivotY()); setTranslationX(transX); setTranslationY(transY); PropertyValuesHolder tx = PropertyValuesHolder.ofFloat(TRANSLATION_X, transX, 0); PropertyValuesHolder ty = PropertyValuesHolder.ofFloat(TRANSLATION_Y, transY, 0); Animator drift = ObjectAnimator.ofPropertyValuesHolder(this, tx, ty); drift.setDuration(mMaterialExpandDuration); drift.setStartDelay(mMaterialExpandStagger); drift.setInterpolator(new LogDecelerateInterpolator(100, 0)); int rx = (int) Math.max(Math.max(width - getPivotX(), 0), getPivotX()); int ry = (int) Math.max(Math.max(height - getPivotY(), 0), getPivotY()); float radius = (float) Math.hypot(rx, ry); Animator reveal = new CircleRevealOutlineProvider((int) getPivotX(), (int) getPivotY(), 0, radius) .createRevealAnimator(this); reveal.setDuration(mMaterialExpandDuration); reveal.setInterpolator(new LogDecelerateInterpolator(100, 0)); mContent.setAlpha(0f); Animator iconsAlpha = ObjectAnimator.ofFloat(mContent, "alpha", 0f, 1f); iconsAlpha.setDuration(mMaterialExpandDuration); iconsAlpha.setStartDelay(mMaterialExpandStagger); iconsAlpha.setInterpolator(new AccelerateInterpolator(1.5f)); mFooter.setAlpha(0f); Animator textAlpha = ObjectAnimator.ofFloat(mFooter, "alpha", 0f, 1f); textAlpha.setDuration(mMaterialExpandDuration); textAlpha.setStartDelay(mMaterialExpandStagger); textAlpha.setInterpolator(new AccelerateInterpolator(1.5f)); anim.play(drift); anim.play(iconsAlpha); anim.play(textAlpha); anim.play(reveal); openFolderAnim = anim; mContent.setLayerType(LAYER_TYPE_HARDWARE, null); mFooter.setLayerType(LAYER_TYPE_HARDWARE, null); onCompleteRunnable = new Runnable() { @Override public void run() { mContent.setLayerType(LAYER_TYPE_NONE, null); mFooter.setLayerType(LAYER_TYPE_NONE, null); mLauncher.getUserEventDispatcher().resetElapsedContainerMillis(); } }; } openFolderAnim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { Utilities.sendCustomAccessibilityEvent(Folder.this, AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED, mContent.getAccessibilityDescription()); mState = STATE_ANIMATING; } @Override public void onAnimationEnd(Animator animation) { mState = STATE_OPEN; onCompleteRunnable.run(); mContent.setFocusOnFirstChild(); } }); // Footer animation if (mContent.getPageCount() > 1 && !mInfo.hasOption(FolderInfo.FLAG_MULTI_PAGE_ANIMATION)) { int footerWidth = mContent.getDesiredWidth() - mFooter.getPaddingLeft() - mFooter.getPaddingRight(); float textWidth = mFolderName.getPaint().measureText(mFolderName.getText().toString()); float translation = (footerWidth - textWidth) / 2; mFolderName.setTranslationX(mContent.mIsRtl ? -translation : translation); mPageIndicator.prepareEntryAnimation(); // Do not update the flag if we are in drag mode. The flag will be updated, when we // actually drop the icon. final boolean updateAnimationFlag = !mDragInProgress; openFolderAnim.addListener(new AnimatorListenerAdapter() { @SuppressLint("InlinedApi") @Override public void onAnimationEnd(Animator animation) { mFolderName.animate().setDuration(FOLDER_NAME_ANIMATION_DURATION).translationX(0) .setInterpolator(Utilities.ATLEAST_LOLLIPOP ? AnimationUtils.loadInterpolator(mLauncher, android.R.interpolator.fast_out_slow_in) : new LogDecelerateInterpolator(100, 0)); mPageIndicator.playEntryAnimation(); if (updateAnimationFlag) { mInfo.setOption(FolderInfo.FLAG_MULTI_PAGE_ANIMATION, true, mLauncher); } } }); } else { mFolderName.setTranslationX(0); } mPageIndicator.stopAllAnimations(); openFolderAnim.start(); // Make sure the folder picks up the last drag move even if the finger doesn't move. if (mDragController.isDragging()) { mDragController.forceTouchMove(); } mContent.verifyVisibleHighResIcons(mContent.getNextPage()); }
From source file:com.android.mail.browse.ConversationItemView.java
private ObjectAnimator createTranslateXAnimation(boolean show) { SwipeableListView parent = getListView(); // If we can't get the parent...we have bigger problems. int width = parent != null ? parent.getMeasuredWidth() : 0; final float start = show ? width : 0f; final float end = show ? 0f : width; ObjectAnimator slide = ObjectAnimator.ofFloat(this, "translationX", start, end); slide.setInterpolator(new DecelerateInterpolator(2.0f)); slide.setDuration(sSlideAnimationDuration); return slide; }
From source file:com.android.mail.browse.ConversationItemView.java
private ObjectAnimator createHeightAnimation(boolean show) { final float start = show ? 0f : 1.0f; final float end = show ? 1.0f : 0f; ObjectAnimator height = ObjectAnimator.ofFloat(this, "animatedHeightFraction", start, end); height.setInterpolator(new DecelerateInterpolator(2.0f)); height.setDuration(sShrinkAnimationDuration); return height; }
From source file:com.waz.zclient.pages.main.participants.ParticipantFragment.java
@Override public void onHidePickUser(IPickUserController.Destination destination, boolean closeWithoutSelectingPeople) { if (LayoutSpec.isPhone(getActivity())) { return;/* ww w. ja v a2 s . c o m*/ } if (!destination.equals(getCurrentPickerDestination())) { return; } // Workaround for animation bug with nested child fragments // Animating fragment container views and then popping stack at end of animation int showParticipantsDelay = getResources().getInteger(R.integer.framework_animation_delay_long); int hidePickUserAnimDuration = getResources().getInteger(R.integer.framework_animation_duration_medium); TimeInterpolator hidePickUserInterpolator = new Expo.EaseIn(); ObjectAnimator hidePickUserAnimator; // Fade animation in participants dialog on tablet if (LayoutSpec.isTablet(getActivity())) { hidePickUserAnimator = ObjectAnimator.ofFloat(pickUserContainerView, View.ALPHA, 1f, 0f); hidePickUserAnimator.setInterpolator(new Linear.EaseIn()); } else { hidePickUserAnimator = ObjectAnimator.ofFloat(pickUserContainerView, View.TRANSLATION_Y, 0f, pickUserContainerView.getMeasuredHeight()); hidePickUserAnimator.setInterpolator(hidePickUserInterpolator); hidePickUserAnimator.setDuration(hidePickUserAnimDuration); } hidePickUserAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { if (!isResumed()) { return; } getChildFragmentManager().popBackStackImmediate(PickUserFragment.TAG, FragmentManager.POP_BACK_STACK_INCLUSIVE); if (LayoutSpec.isTablet(getActivity())) { // Reset for fade animation in participants dialog on tablet pickUserContainerView.setAlpha(1f); } else { pickUserContainerView.setTranslationY(0f); } } }); participantsContainerView.setAlpha(0); participantsContainerView.setVisibility(View.VISIBLE); ObjectAnimator showParticipantsAnimator = ObjectAnimator.ofFloat(participantsContainerView, View.ALPHA, 0f, 1f); showParticipantsAnimator.setInterpolator(new Quart.EaseOut()); showParticipantsAnimator .setDuration(getResources().getInteger(R.integer.framework_animation_duration_medium)); showParticipantsAnimator.setStartDelay(showParticipantsDelay); AnimatorSet hideSet = new AnimatorSet(); hideSet.playTogether(hidePickUserAnimator, showParticipantsAnimator); hideSet.start(); if (LayoutSpec.isPhone(getActivity()) && getControllerFactory().getNavigationController() .getPagerPosition() == NavigationController.SECOND_PAGE) { // TODO: https://wearezeta.atlassian.net/browse/AN-3081 if (getControllerFactory().getConversationScreenController().isShowingParticipant()) { getControllerFactory().getNavigationController().setRightPage(Page.PARTICIPANT, TAG); } else { getControllerFactory().getNavigationController().setRightPage(Page.MESSAGE_STREAM, TAG); } } }
From source file:cc.flydev.launcher.Folder.java
public void animateClosed() { if (!(getParent() instanceof DragLayer)) return;/*from w w w .j a v a 2s.c o m*/ PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 0); PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 0.9f); PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 0.9f); final ObjectAnimator oa = LauncherAnimUtils.ofPropertyValuesHolder(this, alpha, scaleX, scaleY); oa.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { onCloseComplete(); setLayerType(LAYER_TYPE_NONE, null); mState = STATE_SMALL; } @Override public void onAnimationStart(Animator animation) { sendCustomAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED, getContext().getString(R.string.folder_closed)); mState = STATE_ANIMATING; } }); oa.setDuration(mExpandDuration); setLayerType(LAYER_TYPE_HARDWARE, null); oa.start(); }
From source file:com.stanleyidesis.quotograph.ui.activity.LWQSettingsActivity.java
Animator animateFAB(final View fabToAnimate, final boolean dismiss) { fabToAnimate.setVisibility(View.VISIBLE); float[] toFrom = dismiss ? new float[] { 1f, .2f } : new float[] { .2f, 1f }; AnimatorSet animatorSet = new AnimatorSet(); animatorSet.addListener(new AnimatorListenerAdapter() { @Override//from www . j a v a 2s . c o m public void onAnimationEnd(Animator animation) { fabToAnimate.setVisibility(dismiss ? View.GONE : View.VISIBLE); } }); ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(fabToAnimate, "alpha", toFrom); alphaAnimator.setDuration(200); alphaAnimator.setInterpolator(new AccelerateDecelerateInterpolator()); // Create a scale + fade animation ObjectAnimator scaleDown = ObjectAnimator.ofPropertyValuesHolder(fabToAnimate, PropertyValuesHolder.ofFloat("scaleX", toFrom), PropertyValuesHolder.ofFloat("scaleY", toFrom)); scaleDown.setDuration(200); scaleDown.setInterpolator(new AccelerateDecelerateInterpolator()); animatorSet.playTogether(scaleDown, alphaAnimator); return animatorSet; }