Java Code Examples for android.animation.ObjectAnimator#setDuration()

The following examples show how to use android.animation.ObjectAnimator#setDuration() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: X8AiHeadLockExcuteController.java    From FimiX8-RE with MIT License 6 votes vote down vote up
public void closeNextUi() {
    this.blank.setVisibility(8);
    if (this.isNextShow) {
        this.isNextShow = false;
        ObjectAnimator translationRight = ObjectAnimator.ofFloat(this.nextRootView, "translationX", new float[]{0.0f, (float) this.width});
        translationRight.setDuration(300);
        translationRight.start();
        translationRight.addListener(new AnimatorListenerAdapter() {
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                X8AiHeadLockExcuteController.this.nextRootView.setVisibility(8);
            }
        });
    }
    this.activity.taskFullScreen(false);
}
 
Example 2
Source File: ProgressBar.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private synchronized void doRefreshProgress(int id, int progress, boolean fromUser,
        boolean callBackToApp, boolean animate) {
    int range = mMax - mMin;
    final float scale = range > 0 ? (progress - mMin) / (float) range : 0;
    final boolean isPrimary = id == R.id.progress;

    if (isPrimary && animate) {
        final ObjectAnimator animator = ObjectAnimator.ofFloat(this, VISUAL_PROGRESS, scale);
        animator.setAutoCancel(true);
        animator.setDuration(PROGRESS_ANIM_DURATION);
        animator.setInterpolator(PROGRESS_ANIM_INTERPOLATOR);
        animator.start();
    } else {
        setVisualProgress(id, scale);
    }

    if (isPrimary && callBackToApp) {
        onProgressRefresh(scale, fromUser, progress);
    }
}
 
Example 3
Source File: MainActivity.java    From trekarta with GNU General Public License v3.0 6 votes vote down vote up
private void onTrackDetails(Track track, boolean current) {
    Fragment fragment = mFragmentManager.findFragmentByTag("trackInformation");
    if (fragment == null) {
        fragment = Fragment.instantiate(this, TrackInformation.class.getName());
        Slide slide = new Slide(mSlideGravity);
        // Required to sync with FloatingActionButton
        slide.setDuration(getResources().getInteger(android.R.integer.config_shortAnimTime));
        fragment.setEnterTransition(slide);
        FragmentTransaction ft = mFragmentManager.beginTransaction();
        ft.replace(R.id.contentPanel, fragment, "trackInformation");
        ft.addToBackStack("trackInformation");
        ft.commit();
        updateMapViewArea();
    }
    ((TrackInformation) fragment).setTrack(track, current);
    mViews.extendPanel.setForeground(getDrawable(R.drawable.dim));
    mViews.extendPanel.getForeground().setAlpha(0);
    ObjectAnimator anim = ObjectAnimator.ofInt(mViews.extendPanel.getForeground(), "alpha", 0, 255);
    anim.setDuration(500);
    anim.start();
}
 
Example 4
Source File: ObjectPropertyAnimActivity.java    From AndroidStudyDemo with GNU General Public License v2.0 6 votes vote down vote up
public void startRectAnimation(View v) {
    Rect local = new Rect();
    mShowAnimIV.getLocalVisibleRect(local);
    Rect from = new Rect(local);
    Rect to = new Rect(local);

    from.right = from.left + local.width()/4;
    from.bottom = from.top + local.height()/2;

    to.left = to.right - local.width()/2;
    to.top = to.bottom - local.height()/4;

    if (Build.VERSION.SDK_INT >= 18) {
        ObjectAnimator objectAnimator = ObjectAnimator.ofObject(mShowAnimIV, "clipBounds", new RectEvaluator(), from, to);
        objectAnimator.setDuration(C.Int.ANIM_DURATION * 4);
        objectAnimator.start();
    }
}
 
Example 5
Source File: FlipTransitionFactory.java    From android-slideshow-widget with Apache License 2.0 6 votes vote down vote up
@Override
public Animator getOutAnimator(View target, SlideShowView parent, int fromSlide, int toSlide) {
    final PropertyValuesHolder rotation;
    final PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat(View.ALPHA, 1, 0);

    switch (axis) {
        case VERTICAL:
            target.setRotationX(0);
            target.setRotationY(0);
            rotation = PropertyValuesHolder.ofFloat(View.ROTATION_X, 90);
            break;

        case HORIZONTAL:
        default:
            target.setRotationX(0);
            target.setRotationY(0);
            rotation = PropertyValuesHolder.ofFloat(View.ROTATION_Y, 90);
            break;
    }

    ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(target, rotation/*, alpha*/);
    animator.setDuration(getDuration()/2);
    animator.setInterpolator(getInterpolator());

    return animator;
}
 
Example 6
Source File: HeadsUpManager.java    From MoeQuest with Apache License 2.0 6 votes vote down vote up
private void show(HeadsUp headsUp) {

    floatView = new FloatView(context, 20);
    WindowManager.LayoutParams params = FloatView.winParams;
    params.flags = WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
        | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_FULLSCREEN
        | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
    params.type = WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;
    params.width = WindowManager.LayoutParams.MATCH_PARENT;
    params.height = WindowManager.LayoutParams.WRAP_CONTENT;
    params.format = -3;
    params.gravity = Gravity.CENTER | Gravity.TOP;
    params.x = floatView.originalLeft;
    params.y = 0;
    params.alpha = 1f;
    wmOne.addView(floatView, params);
    ObjectAnimator a = ObjectAnimator.ofFloat(floatView.rootView, "translationY", -700, 0);
    a.setDuration(600);
    a.start();
    floatView.setNotification(headsUp);
    if (headsUp.getNotification() != null) {
      notificationManager.notify(headsUp.getCode(), headsUp.getNotification());
    }
  }
 
Example 7
Source File: VoIPActivity.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private void setEmojiTooltipVisible(boolean visible) {
    emojiTooltipVisible = visible;
    if (tooltipAnim != null)
        tooltipAnim.cancel();
    hintTextView.setVisibility(View.VISIBLE);
    ObjectAnimator oa = ObjectAnimator.ofFloat(hintTextView, View.ALPHA, visible ? 1 : 0);
    oa.setDuration(300);
    oa.setInterpolator(CubicBezierInterpolator.DEFAULT);
    oa.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            tooltipAnim = null;
        }
    });
    tooltipAnim = oa;
    oa.start();
}
 
Example 8
Source File: RadialTimePickerView.java    From AppCompat-Extension-Library with Apache License 2.0 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private static ObjectAnimator getFadeInAnimator(IntHolder target, int startAlpha, int endAlpha,
                                                InvalidateUpdateListener updateListener) {
    final float delayMultiplier = 0.25f;
    final float transitionDurationMultiplier = 1f;
    final float totalDurationMultiplier = transitionDurationMultiplier + delayMultiplier;
    final int totalDuration = (int) (FADE_IN_DURATION * totalDurationMultiplier);
    final float delayPoint = (delayMultiplier * FADE_IN_DURATION) / totalDuration;

    final Keyframe kf0, kf1, kf2;
    kf0 = Keyframe.ofInt(0f, startAlpha);
    kf1 = Keyframe.ofInt(delayPoint, startAlpha);
    kf2 = Keyframe.ofInt(1f, endAlpha);
    final PropertyValuesHolder fadeIn = PropertyValuesHolder.ofKeyframe("value", kf0, kf1, kf2);

    final ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(target, fadeIn);
    animator.setDuration(totalDuration);
    animator.addUpdateListener(updateListener);
    return animator;
}
 
Example 9
Source File: ToolbarPhone.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
private ObjectAnimator createEnterTabSwitcherModeAnimation() {
    ObjectAnimator enterAnimation =
            ObjectAnimator.ofFloat(this, mTabSwitcherModePercentProperty, 1.f);
    enterAnimation.setDuration(TAB_SWITCHER_MODE_ENTER_ANIMATION_DURATION_MS);
    enterAnimation.setInterpolator(new LinearInterpolator());
    enterAnimation.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            // This is to deal with the view going invisible when resuming the activity and
            // running this animation.  The view is still there and clickable but does not
            // render and only a layout triggers a refresh.  See crbug.com/306890.
            if (!mToggleTabStackButton.isEnabled()) requestLayout();
        }
    });

    return enterAnimation;
}
 
Example 10
Source File: PuzzleSelectorActivity.java    From imsdk-android with MIT License 5 votes vote down vote up
private void newShowAnim() {
    ObjectAnimator translationShow = ObjectAnimator.ofFloat(rvAlbumItems, "translationY", rootSelectorView.getTop(), 0);
    ObjectAnimator alphaShow = ObjectAnimator.ofFloat(rootViewAlbumItems, "alpha", 0.0f, 1.0f);
    translationShow.setDuration(300);
    setShow = new AnimatorSet();
    setShow.setInterpolator(new AccelerateDecelerateInterpolator());
    setShow.play(translationShow).with(alphaShow);
}
 
Example 11
Source File: ChartAnimator.java    From android-kline with Apache License 2.0 5 votes vote down vote up
/**
 * Animates the rendering of the chart on the y-axis with the specified
 * animation time. If animate(...) is called, no further calling of
 * invalidate() is necessary to refresh the chart.
 *
 * @param durationMillis
 * @param easing
 */
public void animateY(int durationMillis, EasingFunction easing) {

    if (android.os.Build.VERSION.SDK_INT < 11)
        return;

    ObjectAnimator animatorY = ObjectAnimator.ofFloat(this, "phaseY", 0f, 1f);
    animatorY.setInterpolator(easing);
    animatorY.setDuration(durationMillis);
    animatorY.addUpdateListener(mListener);
    animatorY.start();
}
 
Example 12
Source File: FilmstripBottomPanel.java    From Camera2 with Apache License 2.0 5 votes vote down vote up
public void hide()
{
    int offset = mLayout.getHeight();
    if (mLayout.getTranslationY() < offset)
    {
        ObjectAnimator animator = ObjectAnimator
                .ofFloat(mLayout, "translationY", mLayout.getTranslationY(), offset);
        animator.setDuration(ANIM_DURATION);
        animator.setInterpolator(Gusterpolator.INSTANCE);
        mViewButton.hideClings();
        animator.start();
    }
}
 
Example 13
Source File: Animators.java    From MaterialProgressBar with Apache License 2.0 5 votes vote down vote up
/**
 * Create a backported Animator for
 * {@code @android:anim/progress_indeterminate_rotation_material}.
 *
 * @param target The object whose properties are to be animated.
 * @return An Animator object that is set up to behave the same as the its native counterpart.
 */
@NonNull
public static Animator createIndeterminateRotation(@NonNull Object target) {
    @SuppressLint("ObjectAnimatorBinding")
    ObjectAnimator rotationAnimator = ObjectAnimator.ofFloat(target, "rotation", 0, 720);
    rotationAnimator.setDuration(6665);
    rotationAnimator.setInterpolator(Interpolators.LINEAR.INSTANCE);
    rotationAnimator.setRepeatCount(ValueAnimator.INFINITE);
    return rotationAnimator;
}
 
Example 14
Source File: MainActivity.java    From rnd-android-wear-tesla with MIT License 5 votes vote down vote up
private void addScaleDownAnimation(List<Animator> animations, View button) {
    ObjectAnimator scaleDownXImage = ObjectAnimator.ofFloat(button, "scaleX", MAX_SCALE, MIN_SCALE);
    scaleDownXImage.setDuration(ANIMATION_DURATION);
    scaleDownXImage.setInterpolator(new AccelerateInterpolator());
    animations.add(scaleDownXImage);

    ObjectAnimator scaleDownYImage = ObjectAnimator.ofFloat(button, "scaleY", MAX_SCALE, MIN_SCALE);
    scaleDownYImage.setDuration(ANIMATION_DURATION);
    scaleDownYImage.setInterpolator(new AccelerateInterpolator());
    animations.add(scaleDownYImage);
}
 
Example 15
Source File: MaterialRippleLayout.java    From AdvancedMaterialDrawer with Apache License 2.0 5 votes vote down vote up
@TargetApi(14)
private void startRipple(final Runnable animationEndRunnable) {
    if (eventCancelled) return;

    float endRadius = getEndRadius();

    cancelAnimations();

    rippleAnimator = new AnimatorSet();
    rippleAnimator.addListener(new AnimatorListenerAdapter() {
        @Override public void onAnimationEnd(Animator animation) {
            if (!ripplePersistent) {
                setRadius(0);
                setRippleAlpha(rippleAlpha);
            }
            if (animationEndRunnable != null && rippleDelayClick) {
                animationEndRunnable.run();
            }
            childView.setPressed(false);
        }
    });

    ObjectAnimator ripple = ObjectAnimator.ofFloat(this, radiusProperty(), radius, endRadius);
    ripple.setDuration(rippleDuration);
    ripple.setInterpolator(new DecelerateInterpolator());
    ObjectAnimator fade = ObjectAnimator.ofInt(this, circleAlphaProperty(), rippleAlpha, 0);
    fade.setDuration(rippleFadeDuration);
    fade.setInterpolator(new AccelerateInterpolator());
    fade.setStartDelay(rippleDuration - rippleFadeDuration - FADE_EXTRA_DELAY);

    if (ripplePersistent) {
        rippleAnimator.play(ripple);
    } else if (getRadius() > endRadius) {
        fade.setStartDelay(0);
        rippleAnimator.play(fade);
    } else {
        rippleAnimator.playTogether(ripple, fade);
    }
    rippleAnimator.start();
}
 
Example 16
Source File: DragManager.java    From SlideAndDragListView with Apache License 2.0 5 votes vote down vote up
@Override
public void onDragFinished(int x, int y, SlideAndDragListView.OnDragDropListener listener) {
    if (mDragView != null && mDragView.getVisibility() == View.VISIBLE) {
        ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(mDragView, "alpha", DRAG_VIEW_ALPHA, 0.0f);
        objectAnimator.setDuration(100);
        objectAnimator.addListener(new DragFinishAnimation());
        objectAnimator.start();
    }
}
 
Example 17
Source File: MaterialRippleLayout.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
private void startRipple(final Runnable animationEndRunnable) {
    if (eventCancelled) return;

    float endRadius = getEndRadius();

    cancelAnimations();

    rippleAnimator = new AnimatorSet();
    rippleAnimator.addListener(new AnimatorListenerAdapter() {
        @Override public void onAnimationEnd(Animator animation) {
            if (!ripplePersistent) {
                setRadius(0);
                setRippleAlpha(rippleAlpha);
            }
            if (animationEndRunnable != null && rippleDelayClick) {
                animationEndRunnable.run();
            }
            childView.setPressed(false);
        }
    });

    ObjectAnimator ripple = ObjectAnimator.ofFloat(this, radiusProperty, radius, endRadius);
    ripple.setDuration(rippleDuration);
    ripple.setInterpolator(new DecelerateInterpolator());
    ObjectAnimator fade = ObjectAnimator.ofInt(this, circleAlphaProperty, rippleAlpha, 0);
    fade.setDuration(rippleFadeDuration);
    fade.setInterpolator(new AccelerateInterpolator());
    fade.setStartDelay(rippleDuration - rippleFadeDuration - FADE_EXTRA_DELAY);

    if (ripplePersistent) {
        rippleAnimator.play(ripple);
    } else if (getRadius() > endRadius) {
        fade.setStartDelay(0);
        rippleAnimator.play(fade);
    } else {
        rippleAnimator.playTogether(ripple, fade);
    }
    rippleAnimator.start();
}
 
Example 18
Source File: MainActivity.java    From SimplicityBrowser with MIT License 4 votes vote down vote up
public static void scrollToTop(WebView mWebView) {
    ObjectAnimator anim = ObjectAnimator.ofInt(mWebView, "scrollY", mWebView.getScrollY(), 0);
    anim.setDuration(350);
    anim.start();
}
 
Example 19
Source File: AnimUtil.java    From PopupCircleMenu with MIT License 4 votes vote down vote up
public static ObjectAnimator toAlphaOne(View view, int duration) {
    ObjectAnimator objectAnimator = ObjectAnimator.ofObject(view, "alpha", new FloatEvaluator(), 0.0f, 1.0f);
    objectAnimator.setDuration(duration);
    return objectAnimator;
}
 
Example 20
Source File: LnUrlWithdrawBSDFragment.java    From zap-android with MIT License 4 votes vote down vote up
private void switchToSuccessScreen() {

        // Animate Layout changes
        ConstraintSet csRoot = new ConstraintSet();
        csRoot.clone(mRootLayout);
        csRoot.connect(mProgressScreen.getId(), ConstraintSet.TOP, ConstraintSet.PARENT_ID, ConstraintSet.TOP);
        csRoot.setVerticalBias(mProgressScreen.getId(), 0.0f);

        Transition transition = new ChangeBounds();
        transition.setInterpolator(new DecelerateInterpolator(3));
        transition.setDuration(1000);
        //transition.setStartDelay(200);
        TransitionManager.beginDelayedTransition(mRootLayout, transition);
        csRoot.applyTo(mRootLayout);


        // Animate finished Icon switch
        ObjectAnimator scaleUpX = ObjectAnimator.ofFloat(mProgressFinishedIcon, "scaleX", 0f, 1f);
        ObjectAnimator scaleUpY = ObjectAnimator.ofFloat(mProgressFinishedIcon, "scaleY", 0f, 1f);
        scaleUpX.setDuration(500);
        scaleUpY.setDuration(500);

        AnimatorSet scaleUpIcon = new AnimatorSet();
        //scaleUpIcon.setInterpolator(new AnticipateOvershootInterpolator(1.0f));
        scaleUpIcon.play(scaleUpX).with(scaleUpY);
        scaleUpIcon.start();

        ObjectAnimator scaleDownX = ObjectAnimator.ofFloat(mProgressBar, "scaleX", 1f, 0f);
        ObjectAnimator scaleDownY = ObjectAnimator.ofFloat(mProgressBar, "scaleY", 1f, 0f);
        ObjectAnimator scaleDownX2 = ObjectAnimator.ofFloat(mIvProgressPaymentTypeIcon, "scaleX", 1f, 0f);
        ObjectAnimator scaleDownY2 = ObjectAnimator.ofFloat(mIvProgressPaymentTypeIcon, "scaleY", 1f, 0f);
        scaleDownX.setDuration(500);
        scaleDownY.setDuration(500);
        scaleDownX2.setDuration(500);
        scaleDownY2.setDuration(500);

        AnimatorSet scaleDownIcon = new AnimatorSet();
        //scaleUpIcon.setInterpolator(new AnticipateOvershootInterpolator(1.0f));
        scaleDownIcon.play(scaleDownX).with(scaleDownY).with(scaleDownX2).with(scaleDownY2);
        scaleDownIcon.start();


        // Animate in
        mFinishedScreen.setAlpha(1.0f);
        AlphaAnimation animateIn = new AlphaAnimation(0f, 1.0f);
        animateIn.setDuration(300);
        animateIn.setStartOffset(300);
        animateIn.setFillAfter(true);
        mFinishedScreen.startAnimation(animateIn);

        // Enable Ok button
        mOkButton.setEnabled(true);
    }