android.animation.AnimatorSet#setDuration ( )源码实例Demo

下面列出了android.animation.AnimatorSet#setDuration ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: TelePlus-Android   文件: AndroidUtilities.java
public static void shakeView(final View view, final float x, final int num)
{
    if (view == null)
    {
        return;
    }
    if (num == 6)
    {
        view.setTranslationX(0);
        return;
    }
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(ObjectAnimator.ofFloat(view, "translationX", AndroidUtilities.dp(x)));
    animatorSet.setDuration(50);
    animatorSet.addListener(new AnimatorListenerAdapter()
    {
        @Override
        public void onAnimationEnd(Animator animation)
        {
            shakeView(view, num == 5 ? 0 : -x, num + 1);
        }
    });
    animatorSet.start();
}
 
private void runBlinkOutAnimation() {
    cancelRunningAnimation();
    mSwipedAway = 0;

    ObjectAnimator stretchX = ObjectAnimator.ofFloat(this, View.SCALE_X, 1.2f);
    ObjectAnimator shrinkY = ObjectAnimator.ofFloat(this, View.SCALE_Y, 0.f);
    ObjectAnimator fadeOut = ObjectAnimator.ofFloat(this, View.ALPHA, 0.f);

    AnimatorSet set = new AnimatorSet();
    set.playTogether(fadeOut, shrinkY, stretchX);
    set.addListener(mCloseAnimatorListener);
    set.setDuration(mCloseAnimationDurationMs);
    set.start();

    mActiveAnimation = set;
}
 
源代码3 项目: TvWidget   文件: BorderEffect.java
@Override
public void onFocusChanged(View oldFocus, View newFocus) {
    try {
        if (newFocus instanceof AbsListView) {
            return;
        }
        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.setInterpolator(new DecelerateInterpolator(1));
        animatorSet.setDuration(mDurationTraslate);
        animatorSet.playTogether(mAnimatorList);
        for (Animator.AnimatorListener listener : mAnimatorListener) {
            animatorSet.addListener(listener);
        }
        mAnimatorSet = animatorSet;
        if (oldFocus == null) {
            animatorSet.setDuration(0);
            mTarget.setVisibility(View.VISIBLE);
        }
        animatorSet.start();
    }catch (Exception ex){
        ex.printStackTrace();
    }
}
 
源代码4 项目: Telegram   文件: SecretMediaViewer.java
private void animateTo(float newScale, float newTx, float newTy, boolean isZoom, int duration) {
    if (scale == newScale && translationX == newTx && translationY == newTy) {
        return;
    }
    zoomAnimation = isZoom;
    animateToScale = newScale;
    animateToX = newTx;
    animateToY = newTy;
    animationStartTime = System.currentTimeMillis();
    imageMoveAnimation = new AnimatorSet();
    imageMoveAnimation.playTogether(
            ObjectAnimator.ofFloat(this, "animationValue", 0, 1)
    );
    imageMoveAnimation.setInterpolator(interpolator);
    imageMoveAnimation.setDuration(duration);
    imageMoveAnimation.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            imageMoveAnimation = null;
            containerView.invalidate();
        }
    });
    imageMoveAnimation.start();
}
 
源代码5 项目: mobilecloud-15   文件: FloatingActionButton.java
/**
 * Shows the Floating Action Button with some Animation.
 */
public void showFloatingActionButton() {
    if (mHidden) {
        ObjectAnimator scaleX =
            ObjectAnimator.ofFloat(this,
                                   "scaleX",
                                   0,
                                   1);
        ObjectAnimator scaleY =
            ObjectAnimator.ofFloat(this,
                                   "scaleY",
                                   0,
                                   1);
        AnimatorSet animSetXY =
            new AnimatorSet();
        animSetXY.playTogether(scaleX,
                               scaleY);
        animSetXY.setInterpolator(overshootInterpolator);
        animSetXY.setDuration(200);
        animSetXY.start();
        mHidden = false;
    }
}
 
源代码6 项目: Telegram   文件: DrawerLayoutContainer.java
public void openDrawer(boolean fast) {
    if (!allowOpenDrawer) {
        return;
    }
    if (AndroidUtilities.isTablet() && parentActionBarLayout != null && parentActionBarLayout.parentActivity != null) {
        AndroidUtilities.hideKeyboard(parentActionBarLayout.parentActivity.getCurrentFocus());
    }
    cancelCurrentAnimation();
    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(ObjectAnimator.ofFloat(this, "drawerPosition", drawerLayout.getMeasuredWidth()));
    animatorSet.setInterpolator(new DecelerateInterpolator());
    if (fast) {
        animatorSet.setDuration(Math.max((int) (200.0f / drawerLayout.getMeasuredWidth() * (drawerLayout.getMeasuredWidth() - drawerPosition)), 50));
    } else {
        animatorSet.setDuration(250);
    }
    animatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animator) {
            onDrawerAnimationEnd(true);
        }
    });
    animatorSet.start();
    currentAnimation = animatorSet;
}
 
源代码7 项目: AndroidDemo   文件: PointView.java
private void startAnimation() {
	Point startPoint = new Point(RADIUS, RADIUS);
	Point endPoint = new Point(getWidth() - RADIUS, getHeight() - RADIUS);
	ValueAnimator anim = ValueAnimator.ofObject(new PointEvaluator(), startPoint, endPoint);
	anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
		@Override
		public void onAnimationUpdate(ValueAnimator animation) {
			currentPoint = (Point) animation.getAnimatedValue();
			invalidate();
		}
	});
	ObjectAnimator anim2 = ObjectAnimator.ofObject(this, "color", new ColorEvaluator(),
			"#00FFFF", "#FF1100");
	AnimatorSet animSet = new AnimatorSet();
	animSet.play(anim).with(anim2);
	animSet.setDuration(5000);
	animSet.start();
}
 
源代码8 项目: circleloading   文件: CircleLoading.java
private void setUpAnimators(int duration) {
    AnimatorSet outerAnimatorSet = createCircleAnimation(mOuterCircle, true);
    AnimatorSet innerAnimatorSet = createCircleAnimation(mInnerCircle, false);
    outerAnimatorSet.setDuration(duration);
    innerAnimatorSet.setDuration(duration);

    mCircleAnimator = new AnimatorSet();
    mCircleAnimator.playTogether(outerAnimatorSet, innerAnimatorSet);

    mCircleAnimator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            super.onAnimationEnd(animation);
            mCircleAnimator.start();
        }
    });
}
 
源代码9 项目: TelePlus-Android   文件: SecretMediaViewer.java
private void toggleActionBar(boolean show, final boolean animated) {
    if (show) {
        actionBar.setVisibility(View.VISIBLE);
    }
    actionBar.setEnabled(show);
    isActionBarVisible = show;

    if (animated) {
        ArrayList<Animator> arrayList = new ArrayList<>();
        arrayList.add(ObjectAnimator.ofFloat(actionBar, "alpha", show ? 1.0f : 0.0f));
        currentActionBarAnimation = new AnimatorSet();
        currentActionBarAnimation.playTogether(arrayList);
        if (!show) {
            currentActionBarAnimation.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    if (currentActionBarAnimation != null && currentActionBarAnimation.equals(animation)) {
                        actionBar.setVisibility(View.GONE);
                        currentActionBarAnimation = null;
                    }
                }
            });
        }

        currentActionBarAnimation.setDuration(200);
        currentActionBarAnimation.start();
    } else {
        actionBar.setAlpha(show ? 1.0f : 0.0f);
        if (!show) {
            actionBar.setVisibility(View.GONE);
        }
    }
}
 
源代码10 项目: AndroidHeros   文件: MainActivity.java
public void btnAnimatorSet(final View view){
    ObjectAnimator animator1 = ObjectAnimator.ofFloat(view, "translationX", 300f);
    ObjectAnimator animator2 = ObjectAnimator.ofFloat(view, "scaleX", 1f, 0f, 1f);
    ObjectAnimator animator3 = ObjectAnimator.ofFloat(view, "scaleY", 1f, 0f, 1f);
    AnimatorSet set = new AnimatorSet();
    set.setDuration(1000);
    set.playTogether(animator1, animator2, animator3);
    set.start();
}
 
源代码11 项目: kaif-android   文件: VoteAnimation.java
public static Animator voteUpAnimation(View view) {
  Context context = view.getContext();
  ValueAnimator colorAnimation = colorChangeAnimation(view,
      context.getResources().getColor(R.color.vote_state_empty),
      context.getResources().getColor(R.color.vote_state_up));
  AnimatorSet animatorSet = new AnimatorSet();
  final ObjectAnimator rotateAnimation = ObjectAnimator.ofFloat(view, "rotation", 0, 360f);
  animatorSet.play(colorAnimation).with(rotateAnimation);
  animatorSet.setDuration(300);
  return animatorSet;
}
 
源代码12 项目: EasyPhotos   文件: JCameraView.java
@Override
public boolean handlerFoucs(float x, float y) {
    if (y > mCaptureLayout.getTop()) {
        return false;
    }
    mFoucsView.setVisibility(VISIBLE);
    if (x < mFoucsView.getWidth() / 2) {
        x = mFoucsView.getWidth() / 2;
    }
    if (x > layout_width - mFoucsView.getWidth() / 2) {
        x = layout_width - mFoucsView.getWidth() / 2;
    }
    if (y < mFoucsView.getWidth() / 2) {
        y = mFoucsView.getWidth() / 2;
    }
    if (y > mCaptureLayout.getTop() - mFoucsView.getWidth() / 2) {
        y = mCaptureLayout.getTop() - mFoucsView.getWidth() / 2;
    }
    mFoucsView.setX(x - mFoucsView.getWidth() / 2);
    mFoucsView.setY(y - mFoucsView.getHeight() / 2);
    ObjectAnimator scaleX = ObjectAnimator.ofFloat(mFoucsView, "scaleX", 1, 0.6f);
    ObjectAnimator scaleY = ObjectAnimator.ofFloat(mFoucsView, "scaleY", 1, 0.6f);
    ObjectAnimator alpha = ObjectAnimator.ofFloat(mFoucsView, "alpha", 1f, 0.4f, 1f, 0.4f, 1f, 0.4f, 1f);
    AnimatorSet animSet = new AnimatorSet();
    animSet.play(scaleX).with(scaleY).before(alpha);
    animSet.setDuration(400);
    animSet.start();
    return true;
}
 
源代码13 项目: ReadMark   文件: MultiFloatingActionButton.java
private void scaleToShow(){
    for(int i = 2; i<getChildCount(); i++){
        View view = getChildAt(i);
        view.setVisibility(VISIBLE);
        view.setAlpha(0);
        ObjectAnimator scaleX = ObjectAnimator.ofFloat(view, "scaleX", 0f, 1f);
        ObjectAnimator scaleY = ObjectAnimator.ofFloat(view, "scaleY", 0f, 1f);
        ObjectAnimator alpha = ObjectAnimator.ofFloat(view, "alpha", 0f, 1f);
        AnimatorSet set = new AnimatorSet();
        set.playTogether(scaleX, scaleY, alpha);
        set.setDuration(mAnimationDuration);
        set.start();
    }
}
 
源代码14 项目: PracticeDemo   文件: ShareMenu.java
private void closeMenu(){

        AnimatorSet set = new AnimatorSet();
        set.setDuration(200);
        int size = mViews.size();
        mObjectAnimators = new ObjectAnimator[size];
        for (int i = 0; i < size; i++) {
            View view = mViews.get(i);
            mObjectAnimators[i]= makeCloseAnimator(view);
        }

        set.playTogether(mObjectAnimators);
        set.addListener(mAnimatorListener);
        set.start();
    }
 
源代码15 项目: ImagePicker   文件: FolderPopUpWindow.java
private void enterAnimator() {
    ObjectAnimator alpha = ObjectAnimator.ofFloat(masker, "alpha", 0, 1);
    ObjectAnimator translationY = ObjectAnimator.ofFloat(listView, "translationY", listView.getHeight(), 0);
    AnimatorSet set = new AnimatorSet();
    set.setDuration(400);
    set.playTogether(alpha, translationY);
    set.setInterpolator(new AccelerateDecelerateInterpolator());
    set.start();
}
 
源代码16 项目: Telegram   文件: ColorPicker.java
private void toggleSecondField() {
    boolean hide = clearButton.getTag() != null;
    clearButton.setTag(hide ? null : 1);
    AnimatorSet animatorSet = new AnimatorSet();
    ArrayList<Animator> animators = new ArrayList<>();
    animators.add(ObjectAnimator.ofFloat(clearButton, View.ROTATION, hide ? 45 : 0));
    animators.add(ObjectAnimator.ofFloat(colorEditText[2], View.ALPHA, hide ? 0.0f : 1.0f));
    animators.add(ObjectAnimator.ofFloat(colorEditText[3], View.ALPHA, hide ? 0.0f : 1.0f));
    animators.add(ObjectAnimator.ofFloat(exchangeButton, View.ALPHA, hide ? 0.0f : 1.0f));
    if (currentResetType == 2 && !hide) {
        animators.add(ObjectAnimator.ofFloat(resetButton, View.ALPHA, 0.0f));
    }
    animatorSet.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            if (currentResetType == 2 && !hide) {
                resetButton.setVisibility(GONE);
                resetButton.setTag(null);
            }
        }
    });
    animatorSet.playTogether(animators);
    animatorSet.setDuration(180);
    animatorSet.start();

    if (hide && !ignoreTextChange && (minBrightness > 0f || maxBrightness < 1f)) {
        setColorInner(getFieldColor(1, 0xffffffff));
        int color = getColor();
        int red = Color.red(color);
        int green = Color.green(color);
        int blue = Color.blue(color);
        ignoreTextChange = true;
        String text = String.format("%02x%02x%02x", (byte) red, (byte) green, (byte) blue).toUpperCase();
        colorEditText[1].setText(text);
        colorEditText[1].setSelection(text.length());
        ignoreTextChange = false;
        delegate.setColor(color, 0, true);
        invalidate();
    }
}
 
源代码17 项目: KrGallery   文件: CameraActivity.java
private boolean processTouchEvent(MotionEvent event) {
    if (!pressed && event.getActionMasked() == MotionEvent.ACTION_DOWN || event.getActionMasked() == MotionEvent.ACTION_POINTER_DOWN) {
        if (!takingPhoto) {
            pressed = true;
            maybeStartDraging = true;
            lastY = event.getY();
        }
    } else if (pressed) {
        if (event.getActionMasked() == MotionEvent.ACTION_MOVE) {
        } else if (event.getActionMasked() == MotionEvent.ACTION_CANCEL || event.getActionMasked() == MotionEvent.ACTION_UP || event.getActionMasked() == MotionEvent.ACTION_POINTER_UP) {
            pressed = false;
            if (dragging) {
                dragging = false;
                if (cameraView != null) {
                    if (Math.abs(cameraView.getTranslationY()) > cameraView.getMeasuredHeight() / 6.0f) {
                        closeCamera(true);
                    } else {
                        AnimatorSet animatorSet = new AnimatorSet();
                        animatorSet.playTogether(
                                ObjectAnimator.ofFloat(cameraView, "translationY", 0.0f),
                                ObjectAnimator.ofFloat(cameraPanel, "alpha", 1.0f),
                                ObjectAnimator.ofFloat(flashModeButton[0], "alpha", 1.0f),
                                ObjectAnimator.ofFloat(flashModeButton[1], "alpha", 1.0f));
                        animatorSet.setDuration(250);
                        animatorSet.setInterpolator(interpolator);
                        animatorSet.start();
                        cameraPanel.setTag(null);
                    }
                }
            } else {
                cameraView.getLocationOnScreen(viewPosition);
                float viewX = event.getRawX() - viewPosition[0];
                float viewY = event.getRawY() - viewPosition[1];
                cameraView.focusToPoint((int) viewX, (int) viewY);
            }
        }
    }
    return true;
}
 
源代码18 项目: BlogDemo   文件: BossTransferView.java
private void handleRootView() {
    ObjectAnimator setScaleY = ObjectAnimator.ofFloat(mRootView, "scaleY", 1f, 0.95f);
    ObjectAnimator setScaleX = ObjectAnimator.ofFloat(mRootView, "scaleX", 1f, 0.95f);
    AnimatorSet set = new AnimatorSet();
    set.play(setScaleX).with(setScaleY);
    set.setDuration(500);
    set.start();
}
 
源代码19 项目: C9MJ   文件: ExploreFragment.java
@OnClick({
        R.id.iv_expandable,
        R.id.tv_section,
        R.id.scroll_view
})
public void onClick(View view) {
    switch (view.getId()) {
        case R.id.iv_expandable:

            navigator.notifyDataSetChanged();    // must call firstly
            fragmentAdapter.notifyDataSetChanged();

            isExpanded = !isExpanded;
            iv_expandable.setImageResource(isExpanded ? R.drawable.ic_expand_close : R.drawable.ic_expand_open);
            //栏目切换的动画
            ObjectAnimator animator0 = ObjectAnimator.ofFloat(tv_section, "translationX", isExpanded ? 0 : tv_section.getWidth());
            ObjectAnimator animator1 = ObjectAnimator.ofFloat(scrollView, "translationY", isExpanded ? 0 : -scrollView.getHeight());
            AnimatorSet animatorSet = new AnimatorSet();
            animatorSet.playTogether(animator0, animator1);
            animatorSet.setDuration(500);
            animatorSet.setInterpolator(new BounceInterpolator());
            animatorSet.start();

            //保存已选择&未选择的栏目列表
            selectedTitleString = parseListToStringByColons(selectedTitleList);
            unselectedTitleString = parseListToStringByColons(unSelectedTitleList);
            App.getSpUtils().putString(Constants.STRING_TITLE_SELECTED, selectedTitleString);
            App.getSpUtils().putString(Constants.STRING_TITLE_UNSELECTED, unselectedTitleString);
            break;

        case R.id.tv_section:
            break;
        case R.id.scroll_view:
            break;
    }
}
 
源代码20 项目: Telegram-FOSS   文件: ActionBarLayout.java
public void movePreviewFragment(float dy) {
    if (!inPreviewMode || transitionAnimationPreviewMode) {
        return;
    }
    float currentTranslation = containerView.getTranslationY();
    float nextTranslation = -dy;
    if (nextTranslation > 0) {
        nextTranslation = 0;
    } else if (nextTranslation < -AndroidUtilities.dp(60)) {
        previewOpenAnimationInProgress = true;
        inPreviewMode = false;
        nextTranslation = 0;

        BaseFragment prevFragment = fragmentsStack.get(fragmentsStack.size() - 2);
        BaseFragment fragment = fragmentsStack.get(fragmentsStack.size() - 1);

        if (Build.VERSION.SDK_INT >= 21) {
            fragment.fragmentView.setOutlineProvider(null);
            fragment.fragmentView.setClipToOutline(false);
        }
        FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) fragment.fragmentView.getLayoutParams();
        layoutParams.topMargin = layoutParams.bottomMargin = layoutParams.rightMargin = layoutParams.leftMargin = 0;
        fragment.fragmentView.setLayoutParams(layoutParams);

        presentFragmentInternalRemoveOld(false, prevFragment);

        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.playTogether(
                ObjectAnimator.ofFloat(fragment.fragmentView, View.SCALE_X, 1.0f, 1.05f, 1.0f),
                ObjectAnimator.ofFloat(fragment.fragmentView, View.SCALE_Y, 1.0f, 1.05f, 1.0f));
        animatorSet.setDuration(200);
        animatorSet.setInterpolator(new CubicBezierInterpolator(0.42, 0.0, 0.58, 1.0));
        animatorSet.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                previewOpenAnimationInProgress = false;
            }
        });
        animatorSet.start();
        performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP);

        fragment.setInPreviewMode(false);
    }
    if (currentTranslation != nextTranslation) {
        containerView.setTranslationY(nextTranslation);
        invalidate();
    }
}