Example usage for android.animation ObjectAnimator setDuration

List of usage examples for android.animation ObjectAnimator setDuration

Introduction

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

Prototype

@Override
@NonNull
public ObjectAnimator setDuration(long duration) 

Source Link

Document

Sets the length of the animation.

Usage

From source file:com.example.google.maps.folding_map.MainActivity.java

public void animateFold() {
    ObjectAnimator animator = ObjectAnimator.ofFloat(mFoldingLayout, "foldFactor",
            mFoldingLayout.getFoldFactor(), 1);
    animator.setRepeatMode(ValueAnimator.REVERSE);
    animator.setRepeatCount(1);//from  w  w w  .  java  2  s.  c o m
    animator.setDuration(FOLD_ANIMATION_DURATION);
    animator.setInterpolator(new AccelerateInterpolator());
    animator.start();
}

From source file:com.mac.SafeWalk.WelcomeActivity.java

public void animate(ImageView dot) {
    if (dot != null) {
        Log.w("WelcomeActivity", "setting up animation");
        ObjectAnimator appear = ObjectAnimator.ofFloat(dot, "alpha", 0f, 1f);
        appear.setRepeatCount(2);//from  w  w w  .  j a  v  a  2 s.  c  om
        appear.setDuration(2000);
        appear.start();
        ObjectAnimator translation = ObjectAnimator.ofFloat(dot, "translationX", 0, -400f);
        translation.setDuration(2000);
        translation.setRepeatCount(2);
        translation.start();
        Log.w("WelcomeActivity", "starting animation");
    }
}

From source file:com.hannesdorfmann.home.filter.FilterAdapter.java

@Override
public FilterViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
    final FilterViewHolder holder = new FilterViewHolder(
            LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.filter_item, viewGroup, false));

    holder.itemView.setOnClickListener(new View.OnClickListener() {
        @Override//from w  w w  .j a  v  a 2 s  .c  o  m
        public void onClick(View v) {
            final int position = holder.getAdapterPosition();
            if (position == RecyclerView.NO_POSITION)
                return;

            final SourceFilterPresentationModel filter = filters.get(position);
            holder.itemView.setHasTransientState(true);
            ObjectAnimator fade = ObjectAnimator.ofInt(holder.filterIcon, ViewUtils.IMAGE_ALPHA,
                    filter.getEnabled() ? FILTER_ICON_DISABLED_ALPHA : FILTER_ICON_ENABLED_ALPHA);
            fade.setDuration(300);
            fade.setInterpolator(AnimationUtils.loadInterpolator(holder.itemView.getContext(),
                    android.R.interpolator.fast_out_slow_in));
            fade.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    holder.itemView.setHasTransientState(false);
                    clickedListener.onSourceFilterClicked(filter);
                }
            });
            fade.start();
        }
    });
    return holder;
}

From source file:io.vit.vitio.Settings.ComingSoonActivity.java

private void toggleCircle(ImageView imon, ImageView imoff[]) {
    imon.setActivated(true);/*  w  w  w  .  j a  v a 2  s  .com*/
    ObjectAnimator animatorX = ObjectAnimator.ofFloat(imon, "scaleX", 0.5f, 1.0f);
    ObjectAnimator animatorY = ObjectAnimator.ofFloat(imon, "scaleY", 0.5f, 1.0f);
    animatorX.setDuration(300);
    animatorY.setDuration(300);
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(animatorX, animatorY);
    animatorSet.start();
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
            (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10,
                    getResources().getDisplayMetrics()),
            (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10,
                    getResources().getDisplayMetrics()));
    params.setMargins(0, 0, (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 13,
            getResources().getDisplayMetrics()), 0);
    imon.setLayoutParams(params);
    for (int i = 0; i < imoff.length; i++) {
        imoff[i].setActivated(false);
        params = new LinearLayout.LayoutParams(
                (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 6,
                        getResources().getDisplayMetrics()),
                (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 6,
                        getResources().getDisplayMetrics()));
        params.setMargins(0, 0, (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 13,
                getResources().getDisplayMetrics()), 0);
        imoff[i].setLayoutParams(params);
    }
}

From source file:com.example.android.interpolator.InterpolatorFragment.java

/**
 * Start an animation on the sample view.
 * The view is animated using an {@link android.animation.ObjectAnimator} on the
 * {@link View#SCALE_X} and {@link View#SCALE_Y} properties, with its animation based on a path.
 * The only two paths defined here ({@link #mPathIn} and {@link #mPathOut}) scale the view
 * uniformly.//  w  ww  .j a  v a2s.c o  m
 *
 * @param interpolator The interpolator to use for the animation.
 * @param duration     Duration of the animation in ms.
 * @param path         Path of the animation
 * @return The ObjectAnimator used for this animation
 * @see android.animation.ObjectAnimator#ofFloat(Object, String, String, android.graphics.Path)
 */
public ObjectAnimator startAnimation(Interpolator interpolator, long duration, Path path) {
    // This ObjectAnimator uses the path to change the x and y scale of the mView object.
    ObjectAnimator animator = ObjectAnimator.ofFloat(mView, View.SCALE_X, View.SCALE_Y, path);

    // Set the duration and interpolator for this animation
    animator.setDuration(duration);
    animator.setInterpolator(interpolator);

    animator.start();

    return animator;
}

From source file:im.actor.sdk.view.emoji.keyboard.emoji.EmojiKeyboard.java

@Override
protected View createView() {
    final View emojiPagerView = LayoutInflater.from(activity).inflate(R.layout.emoji_smiles_pager, null);

    final ViewPager emojiPager = (ViewPager) emojiPagerView.findViewById(R.id.emoji_pager);

    final PagerSlidingTabStrip emojiPagerIndicator = (PagerSlidingTabStrip) emojiPagerView
            .findViewById(R.id.emoji_pager_indicator);
    View backspace = emojiPagerView.findViewById(R.id.backspace);
    final View backToSmiles = emojiPagerView.findViewById(R.id.back_to_smiles);
    final View indicatorContainer = emojiPagerView.findViewById(R.id.indicator_container);
    stickerIndicatorContainer = emojiPagerView.findViewById(R.id.sticker_indicator_container);
    stickerSwitchContainer = emojiPagerView.findViewById(R.id.sticker_switch_container);

    emojiPagerIndicator.setTabBackground(R.drawable.clickable_background);
    emojiPagerIndicator.setIndicatorColorResource(R.color.primary);
    emojiPagerIndicator.setIndicatorHeight(Screen.dp(2));
    emojiPagerIndicator.setDividerColor(0x00000000);
    emojiPagerIndicator.setUnderlineHeight(0);
    emojiPagerIndicator.setTabLayoutParams(new LinearLayout.LayoutParams(Screen.dp(48), Screen.dp(48)));

    backspace.setOnTouchListener(new RepeatListener(500, 100, new OnClickListener() {
        @Override//  w  ww  .j  ava2 s.c om
        public void onClick(View v) {
            onBackspaceClick(v);
        }
    }));

    mEmojisAdapter = new SmilePagerAdapter(this);
    mEmojisAdapter.setTabs(emojiPagerIndicator);
    emojiPager.setAdapter(mEmojisAdapter);
    emojiPagerIndicator.setViewPager(emojiPager);

    backToSmiles.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            emojiPager.setCurrentItem(3, false);

            ObjectAnimator oa = ObjectAnimator.ofFloat(indicatorContainer, "translationX", 0, 0);
            oa.setDuration(0);
            oa.start();
            if (stickerIndicatorContainer.getVisibility() == View.INVISIBLE) {
                stickerIndicatorContainer.setVisibility(View.VISIBLE);
            }
            ObjectAnimator oas = ObjectAnimator.ofFloat(stickerIndicatorContainer, "translationX",
                    Screen.getWidth(), Screen.getWidth());
            oas.setDuration(0);
            oas.start();

            emojiPager.setCurrentItem(1, true);

        }
    });

    final FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) stickerIndicatorContainer.getLayoutParams();

    emojiPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            if (position == 4) {

                ObjectAnimator oa = ObjectAnimator.ofFloat(indicatorContainer, "translationX",
                        indicatorContainer.getX(), -positionOffsetPixels);
                oa.setDuration(0);
                oa.start();
                if (stickerIndicatorContainer.getVisibility() == View.INVISIBLE) {
                    stickerIndicatorContainer.setVisibility(View.VISIBLE);
                }
                ObjectAnimator oas = ObjectAnimator.ofFloat(stickerIndicatorContainer, "translationX",
                        stickerIndicatorContainer.getX() + Screen.getWidth(),
                        -positionOffsetPixels + Screen.getWidth());
                oas.setDuration(0);
                oas.start();

            }
        }

        @Override
        public void onPageSelected(int position) {

        }

        @Override
        public void onPageScrollStateChanged(int state) {

        }
    });

    //emojiPagerIndicator.setLayoutParams(new RelativeLayout.LayoutParams(Screen.dp(58 * mEmojisAdapter.getCount()), Screen.dp(48)));
    //        emojiPager.postDelayed(new Runnable() {
    //            @Override
    //            public void run() {
    //                emojiPager.setAlpha(0f);
    //                emojiPagerIndicator.setAlpha(0f);
    //                animateView(emojiPager);
    //                animateView(emojiPagerIndicator);
    //                emojiPager.setAdapter(mEmojisAdapter);
    //                emojiPagerIndicator.setViewPager(emojiPager);
    //            }
    //        }, BINDING_DELAY);

    if (SmilesPack.getRecent().size() == 0) {
        emojiPager.setCurrentItem(1);
    }

    return emojiPagerView;
}

From source file:com.hippo.widget.ProgressView.java

private void setupAnimators() {
    ObjectAnimator trimStart = ObjectAnimator.ofFloat(this, "trimStart", 0.0f, 0.75f);
    trimStart.setDuration(1333L);
    trimStart.setInterpolator(TRIM_START_INTERPOLATOR);
    trimStart.setRepeatCount(Animation.INFINITE);

    ObjectAnimator trimEnd = ObjectAnimator.ofFloat(this, "trimEnd", 0.0f, 0.75f);
    trimEnd.setDuration(1333L);// w  ww .j  a  va2  s .co m
    trimEnd.setInterpolator(TRIM_END_INTERPOLATOR);
    trimEnd.setRepeatCount(Animation.INFINITE);

    ObjectAnimator trimOffset = ObjectAnimator.ofFloat(this, "trimOffset", 0.0f, 0.25f);
    trimOffset.setDuration(1333L);
    trimOffset.setInterpolator(LINEAR_INTERPOLATOR);
    trimOffset.setRepeatCount(Animation.INFINITE);

    ObjectAnimator trimRotation = ObjectAnimator.ofFloat(this, "trimRotation", 0.0f, 720.0f);
    trimRotation.setDuration(6665L);
    trimRotation.setInterpolator(LINEAR_INTERPOLATOR);
    trimRotation.setRepeatCount(Animation.INFINITE);

    mAnimators.add(trimStart);
    mAnimators.add(trimEnd);
    mAnimators.add(trimOffset);
    mAnimators.add(trimRotation);
}

From source file:com.android.tabletcustomui.views.LeftCircleContainer.java

private void animateClockWise(View view) {
    ObjectAnimator animation = ObjectAnimator.ofFloat(view, "rotation", 0.0f, 360f);
    animation.setDuration(3000);
    animation.setInterpolator(new FastOutSlowInInterpolator());
    animation.start();//  w  w  w  .j  a v  a  2  s. co  m
}

From source file:com.android.tabletcustomui.views.LeftCircleContainer.java

private void animateAntiClockWise(View view) {
    ObjectAnimator animation1 = ObjectAnimator.ofFloat(view, "rotation", 360f, 0.0f);
    animation1.setDuration(3000);
    animation1.setInterpolator(new FastOutSlowInInterpolator());
    animation1.start();/* ww  w  .  j  av a 2s.  c  o  m*/
}

From source file:org.taurusxi.taurusxicommon.view.drawer.DrawerArrowDrawable.java

public void animateToBack() {
    ObjectAnimator backAnim = ObjectAnimator.ofFloat(this, "parameter", 0f, 1f);
    backAnim.setDuration(500);
    backAnim.setInterpolator(LINEAR_INTERPOLATOR);
    backAnim.start();//from  www  .j a v  a 2 s  . c o m
}