Example usage for android.animation ObjectAnimator start

List of usage examples for android.animation ObjectAnimator start

Introduction

In this page you can find the example usage for android.animation ObjectAnimator start.

Prototype

@Override
    public void start() 

Source Link

Usage

From source file:com.gitstudy.rili.liarbry.CalendarLayout.java

/**
 * ??//from   w ww . j  a v  a  2s  . co  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: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 ww.j ava  2 s  .c  o  m
        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);
}

From source file:io.plaidapp.ui.FeedAdapter.java

private void bindDribbbleShotHolder(final Shot shot, final DribbbleShotHolder holder) {
    final int[] imageSize = shot.images.bestSize();
    Glide.with(host).load(shot.images.best()).listener(new RequestListener<String, GlideDrawable>() {

        @Override/*from ww w. ja  v a  2  s  . c  o  m*/
        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();
                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(2000);
                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();
                shot.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).fitCenter().override(imageSize[0], imageSize[1])
            .into(new DribbbleTarget(holder.image, false));
}

From source file:com.jarklee.materialdatetimepicker.time.TimePickerDialog.java

private void setCurrentItemShowing(int index, boolean animateCircle, boolean delayLabelAnimate,
        boolean announce) {
    mTimePicker.setCurrentItemShowing(index, animateCircle);

    TextView labelToAnimate;/*www  .  j a v a  2  s  .c  o m*/
    switch (index) {
    case HOUR_INDEX:
        int hours = mTimePicker.getHours();
        if (!mIs24HourMode) {
            hours = hours % 12;
        }
        mTimePicker.setContentDescription(mHourPickerDescription + ": " + hours);
        if (announce) {
            Utils.tryAccessibilityAnnounce(mTimePicker, mSelectHours);
        }
        labelToAnimate = mHourView;
        break;
    case MINUTE_INDEX:
        int minutes = mTimePicker.getMinutes();
        mTimePicker.setContentDescription(mMinutePickerDescription + ": " + minutes);
        if (announce) {
            Utils.tryAccessibilityAnnounce(mTimePicker, mSelectMinutes);
        }
        labelToAnimate = mMinuteView;
        break;
    default:
        int seconds = mTimePicker.getSeconds();
        mTimePicker.setContentDescription(mSecondPickerDescription + ": " + seconds);
        if (announce) {
            Utils.tryAccessibilityAnnounce(mTimePicker, mSelectSeconds);
        }
        labelToAnimate = mSecondView;
    }

    int hourColor = (index == HOUR_INDEX) ? mSelectedColor : mUnselectedColor;
    int minuteColor = (index == MINUTE_INDEX) ? mSelectedColor : mUnselectedColor;
    int secondColor = (index == SECOND_INDEX) ? mSelectedColor : mUnselectedColor;
    mHourView.setTextColor(hourColor);
    mMinuteView.setTextColor(minuteColor);
    mSecondView.setTextColor(secondColor);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        ObjectAnimator pulseAnimator = Utils.getPulseAnimator(labelToAnimate, 0.85f, 1.1f);
        if (delayLabelAnimate) {
            pulseAnimator.setStartDelay(PULSE_ANIMATOR_DELAY);
        }
        pulseAnimator.start();
    }
}

From source file:cc.flydev.launcher.Folder.java

public void animateClosed() {
    if (!(getParent() instanceof DragLayer))
        return;//from w  w w.j  a  v a2  s .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.klinker.android.sliding.MultiShrinkScroller.java

/**
 * Scroll the activity up as the entrace animation.
 * @param scrollToCurrentPosition if true, will scroll from the bottom of the screen to the
 * current position. Otherwise, will scroll from the bottom of the screen to the top of the
 * screen./*w w w.j  a va2  s. c o  m*/
 */
public void performEntranceAnimation(OpenAnimation animation, boolean scrollToCurrentPosition) {
    final int currentPosition = getScroll();
    final int bottomScrollPosition = currentPosition - (getHeight() - getTransparentViewHeight()) + 1;

    final int desiredValue = currentPosition
            + (scrollToCurrentPosition ? currentPosition : getTransparentViewHeight());

    if (animation == OpenAnimation.EXPAND_FROM_VIEW) {
        scrollTo(0, desiredValue);
        runExpansionAnimation();

        openAnimation = animation;
    } else {
        final Interpolator interpolator;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            interpolator = AnimationUtils.loadInterpolator(getContext(),
                    android.R.interpolator.linear_out_slow_in);
        } else {
            interpolator = new DecelerateInterpolator();
        }

        final ObjectAnimator animator = ObjectAnimator.ofInt(this, "scroll", bottomScrollPosition,
                desiredValue);
        animator.setInterpolator(interpolator);
        animator.addUpdateListener(new AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                if (animation.getAnimatedValue().equals(desiredValue) && listener != null) {
                    listener.onEntranceAnimationDone();
                }
            }
        });

        animator.start();
    }

}

From source file:com.jarklee.materialdatetimepicker.date.DatePickerDialog.java

private void setCurrentView(final int viewIndex) {
    long millis = mCalendar.getTimeInMillis();
    ObjectAnimator pulseAnimator = null;
    switch (viewIndex) {
    case MONTH_AND_DAY_VIEW:
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            pulseAnimator = Utils.getPulseAnimator(mMonthAndDayView, 0.9f, 1.05f);
            if (mDelayAnimation) {
                pulseAnimator.setStartDelay(ANIMATION_DELAY);
                mDelayAnimation = false;
            }/*from ww w  .  j  a va2  s. com*/
        } else {
            pulseAnimator = null;
        }
        mDayPickerView.onDateChanged();
        if (mCurrentView != viewIndex) {
            mMonthAndDayView.setSelected(true);
            mYearView.setSelected(false);
            mAnimator.setDisplayedChild(MONTH_AND_DAY_VIEW);
            mCurrentView = viewIndex;
        }
        if (pulseAnimator != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            pulseAnimator.start();
        }
        int flags = DateUtils.FORMAT_SHOW_DATE;
        String dayString = DateUtils.formatDateTime(getActivity(), millis, flags);
        mAnimator.setContentDescription(mDayPickerDescription + ": " + dayString);
        Utils.tryAccessibilityAnnounce(mAnimator, mSelectDay);
        break;
    case YEAR_VIEW:
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            pulseAnimator = Utils.getPulseAnimator(mYearView, 0.85f, 1.1f);
            if (mDelayAnimation) {
                pulseAnimator.setStartDelay(ANIMATION_DELAY);
                mDelayAnimation = false;
            }
        } else {
            pulseAnimator = null;
        }
        mYearPickerView.onDateChanged();
        if (mCurrentView != viewIndex) {
            mMonthAndDayView.setSelected(false);
            mYearView.setSelected(true);
            mAnimator.setDisplayedChild(YEAR_VIEW);
            mCurrentView = viewIndex;
        }
        if (pulseAnimator != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            pulseAnimator.start();
        }
        CharSequence yearString = YEAR_FORMAT.format(millis);
        mAnimator.setContentDescription(mYearPickerDescription + ": " + yearString);
        Utils.tryAccessibilityAnnounce(mAnimator, mSelectYear);
        break;
    }
}

From source file:com.arlib.floatingsearchview.FloatingSearchView.java

private void changeIcon(ImageView imageView, Drawable newIcon, boolean withAnim) {
    imageView.setImageDrawable(newIcon);
    if (withAnim) {
        ObjectAnimator fadeInVoiceInputOrClear = ObjectAnimator.ofFloat(imageView, "alpha", 0.0f, 1.0f);
        fadeInVoiceInputOrClear.start();
    } else {/*from   w  w  w .j  a va2  s  .com*/
        imageView.setAlpha(1.0f);
    }
}

From source file:kr.wdream.ui.DialogsActivity.java

private void hideFloatingButton(boolean hide) {
    if (floatingHidden == hide) {
        return;/*  w w w .  j  av a 2  s.co m*/
    }
    floatingHidden = hide;
    ObjectAnimator animator = ObjectAnimator
            .ofFloat(floatingButton, "translationY", floatingHidden ? AndroidUtilities.dp(100) : 0)
            .setDuration(300);
    animator.setInterpolator(floatingInterpolator);
    floatingButton.setClickable(!hide);
    animator.start();
}

From source file:com.phonemetra.turbo.launcher.Folder.java

public void animateOpen() {
    positionAndSizeAsIcon();/*from  w w w. ja va  2 s .  com*/

    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();
    }
}