List of usage examples for android.animation ObjectAnimator addListener
public void addListener(AnimatorListener listener)
From source file:io.plaidapp.core.ui.FeedAdapter.java
private void bindDribbbleShotHolder(final Shot shot, final DribbbleShotHolder holder, int position) { final Images.ImageSize imageSize = shot.getImages().bestSize(); GlideApp.with(host).load(shot.getImages().best()).listener(new RequestListener<Drawable>() { @Override//from w w w . jav a2 s. c om public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) { if (!shot.getHasFadedIn()) { holder.image.setHasTransientState(true); final ObservableColorMatrix cm = new ObservableColorMatrix(); final ObjectAnimator saturation = ObjectAnimator.ofFloat(cm, ObservableColorMatrix.SATURATION, 0f, 1f); saturation.addUpdateListener(valueAnimator -> { // just animating the color matrix does not invalidate the // drawable so need this update listener. Also have to create a // new CMCF as the matrix is immutable :( holder.image.setColorFilter(new ColorMatrixColorFilter(cm)); }); saturation.setDuration(2000L); saturation.setInterpolator(getFastOutSlowInInterpolator(host)); saturation.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { holder.image.clearColorFilter(); holder.image.setHasTransientState(false); } }); saturation.start(); shot.setHasFadedIn(true); } return false; } @Override public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) { return false; } }).placeholder(shotLoadingPlaceholders[position % shotLoadingPlaceholders.length]) .diskCacheStrategy(DiskCacheStrategy.DATA).fitCenter() .transition(DrawableTransitionOptions.withCrossFade()) .override(imageSize.getWidth(), imageSize.getHeight()) .into(new DribbbleTarget(holder.image, false)); // need both placeholder & background to prevent seeing through shot as it fades in holder.image.setBackground(shotLoadingPlaceholders[position % shotLoadingPlaceholders.length]); holder.image.setDrawBadge(shot.getAnimated()); // need a unique transition name per shot, let's use it's url holder.image.setTransitionName(shot.getHtmlUrl()); shotPreloadSizeProvider.setView(holder.image); }
From source file:com.auratech.launcher.Folder.java
public void animateOpen() { positionAndSizeAsIcon();// ww w . j ava 2 s .c o m if (!(getParent() instanceof DragLayer)) return; centerAboutIcon(); PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 1); PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 1.0f); PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 1.0f); final ObjectAnimator oa = LauncherAnimUtils.ofPropertyValuesHolder(this, alpha, scaleX, scaleY); oa.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { sendCustomAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED, String.format(getContext().getString(R.string.folder_opened), mContent.getCountX(), mContent.getCountY())); mState = STATE_ANIMATING; } @Override public void onAnimationEnd(Animator animation) { mState = STATE_OPEN; setLayerType(LAYER_TYPE_NONE, null); // Only show cling if we are not in the middle of a drag - this would be quite jarring. if (!mDragController.isDragging()) { Cling cling = mLauncher.getLauncherClings().showFoldersCling(); if (cling != null) { cling.bringScrimToFront(); bringToFront(); cling.bringToFront(); } } setFocusOnFirstChild(); } }); oa.setDuration(mExpandDuration); setLayerType(LAYER_TYPE_HARDWARE, null); oa.start(); // Make sure the folder picks up the last drag move even if the finger doesn't move. if (mDragController.isDragging()) { mDragController.forceTouchMove(); } }
From source file:com.igniva.filemanager.utils.Futils.java
public void revealShow(final View view, boolean reveal) { if (reveal) { ObjectAnimator animator = ObjectAnimator.ofFloat(view, View.ALPHA, 0f, 1f); animator.setDuration(300); //ms animator.addListener(new AnimatorListenerAdapter() { @Override/* www .ja v a 2s . co m*/ public void onAnimationStart(Animator animation) { view.setVisibility(View.VISIBLE); } }); animator.start(); } else { ObjectAnimator animator = ObjectAnimator.ofFloat(view, View.ALPHA, 1f, 0f); animator.setDuration(300); //ms animator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { view.setVisibility(View.GONE); } }); animator.start(); } }
From source file:com.phonemetra.turbo.launcher.Folder.java
public void animateOpen() { positionAndSizeAsIcon();//from w w w . j a va 2 s . c o m if (!(getParent() instanceof DragLayer)) return; centerAboutIcon(); PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat("alpha", 1); PropertyValuesHolder scaleX = PropertyValuesHolder.ofFloat("scaleX", 1.0f); PropertyValuesHolder scaleY = PropertyValuesHolder.ofFloat("scaleY", 1.0f); final ObjectAnimator oa = LauncherAnimUtils.ofPropertyValuesHolder(this, alpha, scaleX, scaleY); oa.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { sendCustomAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED, String.format(getContext().getString(R.string.folder_opened), mContent.getCountX(), mContent.getCountY())); mState = STATE_ANIMATING; } @Override public void onAnimationEnd(Animator animation) { mState = STATE_OPEN; setLayerType(LAYER_TYPE_NONE, null); setFocusOnFirstChild(); } }); oa.setDuration(mExpandDuration); setLayerType(LAYER_TYPE_HARDWARE, null); oa.start(); // Make sure the folder picks up the last drag move even if the finger doesn't move. if (mDragController.isDragging()) { mDragController.forceTouchMove(); } }
From source file:com.xandy.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 ww w . j a v a2 s . co m } 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) { mActionBarMenuSpinnerAdapter.setTime(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(); FragmentManager fm = getSupportFragmentManager(); 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) { mActionBarMenuSpinnerAdapter.setTime(mController.getTime()); } } updateSecondaryTitleFields(displayTime); }
From source file:com.gitstudy.rili.liarbry.CalendarLayout.java
/** * ??/* ww w. ja va2 s . c o m*/ */ final void initStatus() { if (mContentView == null) { return; } if ((mDefaultStatus == STATUS_SHRINK || mCalendarShowMode == CALENDAR_SHOW_MODE_ONLY_WEEK_VIEW) && mCalendarShowMode != CALENDAR_SHOW_MODE_ONLY_MONTH_VIEW) { post(new Runnable() { @Override public void run() { ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(mContentView, "translationY", mContentView.getTranslationY(), -mContentViewTranslateY); objectAnimator.setDuration(0); objectAnimator.addUpdateListener(new AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { float currentValue = (Float) animation.getAnimatedValue(); float percent = currentValue * 1.0f / mContentViewTranslateY; mMonthView.setTranslationY(mViewPagerTranslateY * percent); isAnimating = true; } }); objectAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); isAnimating = false; showWeek(); } }); objectAnimator.start(); } }); } else { if (mDelegate.mViewChangeListener == null) { return; } post(new Runnable() { @Override public void run() { mDelegate.mViewChangeListener.onViewChange(true); } }); } }
From source file:us.phyxsi.gameshelf.ui.FeedAdapter.java
private void bindBoardgameHolder(final Boardgame game, final BoardgameHolder holder) { final int[] imageSize = { 400, 400 }; Glide.with(host).load("http:" + game.image).listener(new RequestListener<String, GlideDrawable>() { @Override/*from w w w . j a va 2s. c om*/ public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) { if (!game.hasFadedIn) { holder.image.setHasTransientState(true); final ObservableColorMatrix cm = new ObservableColorMatrix(); ObjectAnimator saturation = ObjectAnimator.ofFloat(cm, ObservableColorMatrix.SATURATION, 0f, 1f); saturation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { // just animating the color matrix does not invalidate the // drawable so need this update listener. Also have to create a // new CMCF as the matrix is immutable :( if (holder.image.getDrawable() != null) { holder.image.getDrawable().setColorFilter(new ColorMatrixColorFilter(cm)); } } }); saturation.setDuration(1000); saturation.setInterpolator( AnimationUtils.loadInterpolator(host, android.R.interpolator.fast_out_slow_in)); saturation.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { holder.image.setHasTransientState(false); } }); saturation.start(); game.hasFadedIn = true; } return false; } @Override public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) { return false; } }).placeholder(shotLoadingPlaceholders[holder.getAdapterPosition() % shotLoadingPlaceholders.length]) .diskCacheStrategy(DiskCacheStrategy.SOURCE).centerCrop().override(imageSize[0], imageSize[1]) .into(new BoardgameTarget(holder.image, false)); }
From source file:com.android.incallui.CallCardFragment.java
/** * Animator that performs the upwards shrinking animation of the blue call card scrim. * At the start of the animation, each child view is moved downwards by a pre-specified amount * and then translated upwards together with the scrim. *///from w ww. j a va2s. co m private Animator getShrinkAnimator(int startHeight, int endHeight) { final ObjectAnimator shrinkAnimator = ObjectAnimator.ofInt(mPrimaryCallCardContainer, "bottom", startHeight, endHeight); shrinkAnimator.setDuration(mShrinkAnimationDuration); shrinkAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { mFloatingActionButton.setEnabled(true); } }); shrinkAnimator.setInterpolator(AnimUtils.EASE_IN); return shrinkAnimator; }
From source file:com.waz.zclient.pages.main.participants.ParticipantFragment.java
@Override public void onShowPickUser(IPickUserController.Destination destination, View anchorView) { if (LayoutSpec.isPhone(getActivity())) { return;/*from w w w . j a v a 2s. c o m*/ } if (!getCurrentPickerDestination().equals(destination)) { onHidePickUser(getCurrentPickerDestination(), true); return; } FragmentManager fragmentManager = getChildFragmentManager(); int pickUserAnimation = LayoutSpec.isTablet(getActivity()) ? R.anim.fade_in : R.anim.slide_in_from_bottom_pick_user; if (!groupConversation && otherUser != null) { getControllerFactory().getPickUserController().addUser(otherUser); } fragmentManager.beginTransaction().setCustomAnimations(pickUserAnimation, R.anim.fade_out) .add(R.id.fl__add_to_conversation__pickuser__container, PickUserFragment.newInstance(true, groupConversation), PickUserFragment.TAG) .addToBackStack(PickUserFragment.TAG).commit(); if (LayoutSpec.isPhone(getActivity())) { getControllerFactory().getNavigationController().setRightPage(Page.PICK_USER_ADD_TO_CONVERSATION, TAG); } final ObjectAnimator hideParticipantsAnimator = ObjectAnimator.ofFloat(participantsContainerView, View.ALPHA, 1f, 0f); hideParticipantsAnimator.setInterpolator(new Quart.EaseOut()); hideParticipantsAnimator .setDuration(getResources().getInteger(R.integer.framework_animation_duration_medium)); hideParticipantsAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { participantsContainerView.setVisibility(View.GONE); } }); hideParticipantsAnimator.start(); }
From source file:io.plaidapp.ui.FeedAdapter.java
private void bindDribbbleShotHolder(final Shot shot, final DribbbleShotHolder holder, int position) { final int[] imageSize = shot.images.bestSize(); Glide.with(host).load(shot.images.best()).listener(new RequestListener<String, GlideDrawable>() { @Override//from w w w. ja va 2 s .c om public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) { if (!shot.hasFadedIn) { holder.image.setHasTransientState(true); final ObservableColorMatrix cm = new ObservableColorMatrix(); final ObjectAnimator saturation = ObjectAnimator.ofFloat(cm, ObservableColorMatrix.SATURATION, 0f, 1f); saturation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { // just animating the color matrix does not invalidate the // drawable so need this update listener. Also have to create a // new CMCF as the matrix is immutable :( holder.image.setColorFilter(new ColorMatrixColorFilter(cm)); } }); saturation.setDuration(2000L); saturation.setInterpolator(getFastOutSlowInInterpolator(host)); saturation.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { holder.image.clearColorFilter(); holder.image.setHasTransientState(false); } }); saturation.start(); shot.hasFadedIn = true; } return false; } @Override public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) { return false; } }).placeholder(shotLoadingPlaceholders[position % shotLoadingPlaceholders.length]) .diskCacheStrategy(DiskCacheStrategy.SOURCE).fitCenter().override(imageSize[0], imageSize[1]) .into(new DribbbleTarget(holder.image, false)); // need both placeholder & background to prevent seeing through shot as it fades in holder.image.setBackground(shotLoadingPlaceholders[position % shotLoadingPlaceholders.length]); holder.image.showBadge(shot.animated); // need a unique transition name per shot, let's use it's url holder.image.setTransitionName(shot.html_url); }