android.view.animation.LinearInterpolator#android.animation.Animator源码实例Demo

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

源代码1 项目: Carbon   文件: AnimatorsCompat.java
public static void setAutoCancel(final ObjectAnimator animator) {
    animator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationStart(Animator animation) {
            for (WeakReference<ObjectAnimator> wa : sRunningAnimators) {
                ObjectAnimator a = wa.get();
                if (a == null) {
                    continue;
                }

                if (hasSameTargetAndProperties(animator, a)) {
                    a.cancel();
                }
            }
        }
    });
}
 
源代码2 项目: MaterialMasterDetail   文件: ContainersLayout.java
private void animateInFrameDetails() {
    frameDetails.setVisibility(View.VISIBLE);
    ViewUtils.onLaidOut(frameDetails, new Runnable() {
        @Override
        public void run() {
            ObjectAnimator alpha = ObjectAnimator.ofFloat(frameDetails, View.ALPHA, 0.4f, 1f);
            ObjectAnimator translate = ofFloat(frameDetails, View.TRANSLATION_Y, frameDetails.getHeight() * 0.3f, 0f);

            AnimatorSet set = new AnimatorSet();
            set.playTogether(alpha, translate);
            set.setDuration(ANIM_DURATION);
            set.setInterpolator(new LinearOutSlowInInterpolator());
            set.addListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    super.onAnimationEnd(animation);
                    frameMaster.setVisibility(View.GONE);
                }
            });
            set.start();
        }
    });
}
 
源代码3 项目: mirror   文件: MainActivity.java
@Override
public void onDragDismiss(final ArtboardView view, boolean isDragDown) {
    mIsDragDismiss = true;
    switchToArtboardListView();
    view.animate().alpha(0.0F)
            .translationY(isDragDown ? -view.getHeight() : view.getHeight())
            .setDuration(AnimUtils.DURATION)
            .setInterpolator(new AccelerateInterpolator())
            .setListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animator) {
                    mIsDragDismiss = false;
                    mArtboardPagerView.getBackground().mutate().setAlpha(255);
                    view.setTranslationY(0.0F);
                    view.setAlpha(1.0F);
                }
            })
            .start();
}
 
源代码4 项目: PlayLikeCurl   文件: AnimateCounter.java
/**
 * Call to execute the animation
 */
public void execute(){
    mValueAnimator = ValueAnimator.ofFloat(mStartValue, mEndValue);
    mValueAnimator.setDuration(mDuration);
    mValueAnimator.setInterpolator(mInterpolator);
    mValueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            float current = Float.valueOf(valueAnimator.getAnimatedValue().toString());
            if(mListener!=null)mListener.onValueUpdate(current);
       //     mView.setText(String.format("%." + mPrecision + "f", current));
        }
    });

    mValueAnimator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            if (mListener != null) {
                mListener.onAnimateCounterEnd();
            }
        }
    });

    mValueAnimator.start();
}
 
源代码5 项目: ShizuruNotes   文件: CalendarLayout.java
/**
 * 显示内容布局
 */
@SuppressLint("NewApi")
final void showContentView() {
    if (mContentView == null)
        return;
    mContentView.setTranslationY(getHeight() - mMonthView.getHeight());
    mContentView.setVisibility(VISIBLE);
    mContentView.animate()
            .translationY(0)
            .setDuration(180)
            .setInterpolator(new LinearInterpolator())
            .setListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    super.onAnimationEnd(animation);
                }
            });
}
 
源代码6 项目: ChinaShare   文件: ShareView.java
private void shareViewTranslationAnimator(final float start, final float end) {
    if (Build.VERSION.SDK_INT >= 11) {
        ObjectAnimator bottomAnim = ObjectAnimator.ofFloat(llContent, "translationY", start, end);
        bottomAnim.setDuration(duration);
        bottomAnim.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                if (start < end) {//close ShareView
                    shareView.setVisibility(View.GONE);
                } else {//show ShareView
                }
            }
        });
        bottomAnim.start();
    }
}
 
/**
 * Animate appearance of a view
 *
 * @param view         View to animate
 * @param toVisibility Visibility at the end of animation
 * @param toAlpha      Alpha at the end of animation
 * @param duration     Animation duration in ms
 */
public static void animateView(final View view, final int toVisibility, float toAlpha, int duration) {
    boolean show = toVisibility == View.VISIBLE;
    if (show) {
        view.setAlpha(0);
    }
    view.setVisibility(View.VISIBLE);
    view.animate()
            .setDuration(duration)
            .alpha(show ? toAlpha : 0)
            .setListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    view.setVisibility(toVisibility);
                }
            });
}
 
源代码8 项目: Melophile   文件: PersonFragment.java
@Override
public void hideLoading() {
  progress.animate()
          .scaleX(0)
          .scaleY(0)
          .setDuration(300)
          .setListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
              super.onAnimationEnd(animation);
              //if the animation is still running when the back button has been pressed
              if (progress != null) {
                progress.setVisibility(View.GONE);
              }
            }
          }).start();
}
 
源代码9 项目: ShimmerLayout   文件: ShimmerLayout.java
public void startShimmerAnimation() {
    if (isAnimationStarted) {
        return;
    }

    if (getWidth() == 0) {
        startAnimationPreDrawListener = new ViewTreeObserver.OnPreDrawListener() {
            @Override
            public boolean onPreDraw() {
                getViewTreeObserver().removeOnPreDrawListener(this);
                startShimmerAnimation();

                return true;
            }
        };

        getViewTreeObserver().addOnPreDrawListener(startAnimationPreDrawListener);

        return;
    }

    Animator animator = getShimmerAnimation();
    animator.start();
    isAnimationStarted = true;
}
 
源代码10 项目: SeeWeather   文件: CircularAnimUtil.java
/**
 * 向四周伸张,直到完成显示。
 */
@SuppressLint("NewApi")
public static void show(View myView, float startRadius, long durationMills) {
    if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP) {
        myView.setVisibility(View.VISIBLE);
        return;
    }

    int cx = (myView.getLeft() + myView.getRight()) / 2;
    int cy = (myView.getTop() + myView.getBottom()) / 2;

    int w = myView.getWidth();
    int h = myView.getHeight();

    // 勾股定理 & 进一法
    int finalRadius = (int) Math.sqrt(w * w + h * h) + 1;

    Animator anim =
        ViewAnimationUtils.createCircularReveal(myView, cx, cy, startRadius, finalRadius);
    myView.setVisibility(View.VISIBLE);
    anim.setDuration(durationMills);
    anim.start();
}
 
源代码11 项目: edslite   文件: CategoryPropertyEditor.java
private void rotateIconAndChangeState()
  {
IS_ANIMATING = true;
      _indicatorIcon.clearAnimation();
      ObjectAnimator anim = ObjectAnimator.ofFloat(_indicatorIcon, View.ROTATION, _isExpanded ? 0 : 180);
      anim.setDuration(200);
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
          _indicatorIcon.setHasTransientState(true);
      anim.addListener(new AnimatorListenerAdapter()
      {
          @Override
          public void onAnimationEnd(Animator animation)
          {
              if(_isExpanded)
                  collapse();
              else
                  expand();
              if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
                  _indicatorIcon.setHasTransientState(false);
		IS_ANIMATING = false;

          }
      });
      anim.start();
  }
 
源代码12 项目: 365browser   文件: ToolbarPhone.java
private ObjectAnimator createExitTabSwitcherAnimation(
        final boolean animateNormalToolbar) {
    ObjectAnimator exitAnimation =
            ObjectAnimator.ofFloat(this, mTabSwitcherModePercentProperty, 0.f);
    exitAnimation.setDuration(animateNormalToolbar
            ? TAB_SWITCHER_MODE_EXIT_NORMAL_ANIMATION_DURATION_MS
            : TAB_SWITCHER_MODE_EXIT_FADE_ANIMATION_DURATION_MS);
    exitAnimation.setInterpolator(new LinearInterpolator());
    exitAnimation.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            updateViewsForTabSwitcherMode();
        }
    });

    return exitAnimation;
}
 
源代码13 项目: Android-Notification   文件: NotificationView.java
/**
 * Rotate the contentView to x degree with animation.
 *
 * @param degree
 * @param alpha
 * @param listener
 * @param duration
 */
public void animateContentViewRotationX(float degree, float alpha,
                                        Animator.AnimatorListener listener,
                                        int duration) {

    if (DBG) Log.v(TAG, "animateContentViewRotationX - " +
                   "degree=" + degree + ", alpha=" + alpha);

    mContentView.animate().cancel();
    mContentView.animate()
        .alpha(alpha)
        .rotationX(degree)
        .setListener(listener)
        .setDuration(duration)
        .start();
}
 
源代码14 项目: droidkaigi2016   文件: MapSearchView.java
private void revealOn() {
    if (binding.mapListContainer.getVisibility() == VISIBLE) return;

    View container = binding.mapListContainer;
    Animator animator = ViewAnimationUtils.createCircularReveal(
            container,
            getRevealCenterX(container),
            container.getTop(),
            0,
            (float) Math.hypot(container.getWidth(), container.getHeight()));
    animator.setInterpolator(INTERPOLATOR);
    animator.setDuration(getResources().getInteger(R.integer.view_reveal_mills));
    animator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationStart(Animator animation) {
            binding.mapListContainer.setVisibility(VISIBLE);
            if (onVisibilityChangeListener != null) {
                onVisibilityChangeListener.onChange();
            }
        }
    });

    animator.start();
}
 
源代码15 项目: 365browser   文件: EmptyBackgroundViewTablet.java
public void setEmptyContainerState(boolean shouldShow) {
    Animator nextAnimator = null;

    if (shouldShow && getVisibility() != View.VISIBLE
            && mCurrentTransitionAnimation != mAnimateInAnimation) {
        nextAnimator = mAnimateInAnimation;
        UiUtils.hideKeyboard(this);
    } else if (!shouldShow && getVisibility() != View.GONE
            && mCurrentTransitionAnimation != mAnimateOutAnimation) {
        nextAnimator = mAnimateOutAnimation;
    }

    if (nextAnimator != null) {
        if (mCurrentTransitionAnimation != null) mCurrentTransitionAnimation.cancel();
        mCurrentTransitionAnimation = nextAnimator;
        mCurrentTransitionAnimation.start();
    }
}
 
源代码16 项目: EhViewer   文件: ViewAnimationUtils.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static Animator createCircularReveal(View view,
        int centerX,  int centerY, float startRadius, float endRadius) {
    if (API_SUPPORT_CIRCULAR_REVEAL) {
        return android.view.ViewAnimationUtils.createCircularReveal(
                view, centerX, centerY, startRadius, endRadius);
    } else if (view instanceof Reveal){
        return createRevealAnimator((Reveal) view, centerX, centerY,
                startRadius, endRadius);
    } else {
        throw new IllegalStateException("Only View implements CircularReveal or" +
                " api >= 21 can create circular reveal");
    }
}
 
源代码17 项目: Genius-Android   文件: BalloonMarker.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public void animateClose() {
    mBalloonMarkerDrawable.stop();

    ViewPropertyAnimator animator = mNumber.animate();
    animator.alpha(0f);
    animator.setDuration(100);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        animator.withEndAction(new Runnable() {
            @Override
            public void run() {
                //We use INVISIBLE instead of GONE to avoid a requestLayout
                mNumber.setVisibility(View.INVISIBLE);
                mBalloonMarkerDrawable.animateToNormal();
            }
        });
    } else {
        animator.setListener(new AnimatorListener() {
            @Override
            public void onAnimationEnd(Animator animation) {
                //We use INVISIBLE instead of GONE to avoid a requestLayout
                mNumber.setVisibility(View.INVISIBLE);
                mBalloonMarkerDrawable.animateToNormal();
            }
        });
    }
    animator.start();
}
 
源代码18 项目: Carbon   文件: RecyclerView.java
public void setOutAnimator(Animator outAnim) {
    if (this.outAnim != null)
        this.outAnim.setTarget(null);
    this.outAnim = outAnim;
    if (outAnim != null)
        outAnim.setTarget(this);
}
 
源代码19 项目: Telegram   文件: MediaActivity.java
private boolean onItemLongClick(MessageObject item, View view, int a) {
    if (actionBar.isActionModeShowed() || getParentActivity() == null) {
        return false;
    }
    AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus());
    selectedFiles[item.getDialogId() == dialog_id ? 0 : 1].put(item.getId(), item);
    if (!item.canDeleteMessage(false, null)) {
        cantDeleteMessagesCount++;
    }
    actionBar.createActionMode().getItem(delete).setVisibility(cantDeleteMessagesCount == 0 ? View.VISIBLE : View.GONE);
    if (gotoItem != null) {
        gotoItem.setVisibility(View.VISIBLE);
    }
    selectedMessagesCountTextView.setNumber(1, false);
    AnimatorSet animatorSet = new AnimatorSet();
    ArrayList<Animator> animators = new ArrayList<>();
    for (int i = 0; i < actionModeViews.size(); i++) {
        View view2 = actionModeViews.get(i);
        AndroidUtilities.clearDrawableAnimation(view2);
        animators.add(ObjectAnimator.ofFloat(view2, View.SCALE_Y, 0.1f, 1.0f));
    }
    animatorSet.playTogether(animators);
    animatorSet.setDuration(250);
    animatorSet.start();
    scrolling = false;
    if (view instanceof SharedDocumentCell) {
        ((SharedDocumentCell) view).setChecked(true, true);
    } else if (view instanceof SharedPhotoVideoCell) {
        ((SharedPhotoVideoCell) view).setChecked(a, true, true);
    } else if (view instanceof SharedLinkCell) {
        ((SharedLinkCell) view).setChecked(true, true);
    } else if (view instanceof SharedAudioCell) {
        ((SharedAudioCell) view).setChecked(true, true);
    }
    if (!actionBar.isActionModeShowed()) {
        actionBar.showActionMode(null, actionModeBackground, null, null, null, 0);
        resetScroll();
    }
    return true;
}
 
源代码20 项目: android-topeka   文件: TextResizeTransition.java
@Override
public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues,
                               TransitionValues endValues) {
    if (startValues == null || endValues == null) {
        return null;
    }

    float initialTextSize = (float) startValues.values.get(PROPERTY_NAME_TEXT_RESIZE);
    float targetTextSize = (float) endValues.values.get(PROPERTY_NAME_TEXT_RESIZE);
    TextView targetView = (TextView) endValues.view;
    targetView.setTextSize(TypedValue.COMPLEX_UNIT_PX, initialTextSize);

    int initialPaddingStart = (int) startValues.values.get(PROPERTY_NAME_PADDING_RESIZE);
    int targetPaddingStart = (int) endValues.values.get(PROPERTY_NAME_PADDING_RESIZE);

    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.playTogether(
            ObjectAnimator.ofFloat(targetView,
                    ViewUtils.PROPERTY_TEXT_SIZE,
                    initialTextSize,
                    targetTextSize),
            ObjectAnimator.ofInt(targetView,
                    ViewUtils.PROPERTY_TEXT_PADDING_START,
                    initialPaddingStart,
                    targetPaddingStart));
    return animatorSet;
}
 
源代码21 项目: AchievementView   文件: FunctionsUtil.java
public static void applyAlpha(View view, long delay, float alpha, Animator.AnimatorListener animatorListener){
    ViewPropertyAnimator animator2 = view.animate();
    animator2.alpha(alpha);
    animator2.setInterpolator(new DecelerateInterpolator());
    animator2.setStartDelay(delay);
    animator2.setListener(animatorListener);
    animator2.start();
}
 
private void removeViewInternal(final View child) {
    if (child.getVisibility() != VISIBLE) {
        super.removeView(child);
        return;
    }
    executeRemoveViewTask();
    View current = findNextTopView(child);
    if (current == null) {
        mRemoveViewReference = new WeakReference<View>(child);
        sendRemoveViewMessage();
        return;
    }
    final TransitionAdapter adapter = switchView(current, true);
    if (mHandler.hasMessages(MESSAGE_REMOVE_VIEW)) {
        mHandler.removeMessages(MESSAGE_REMOVE_VIEW);
    }
    mRemoveViewReference = new WeakReference<View>(child);
    mValueAnimator = adapter.getAnimator();
    mValueAnimator.setInterpolator(new DecelerateInterpolator());
    mValueAnimator.addListener(new AnimatorListenerAdapter() {

        @Override
        public void onAnimationEnd(Animator animation) {
            sendRemoveViewMessage();
        }
    });
    startAnimator();
    return;
}
 
源代码23 项目: Telegram   文件: ChatListItemAnimator.java
protected boolean endChangeAnimationIfNecessary(ChangeInfo changeInfo, RecyclerView.ViewHolder item) {
    if (BuildVars.LOGS_ENABLED) {
        FileLog.d("end change if necessary");
    }
    Animator a = animators.remove(item);
    if (a != null) {
        a.cancel();
    }

    boolean oldItem = false;
    if (changeInfo.newHolder == item) {
        changeInfo.newHolder = null;
    } else if (changeInfo.oldHolder == item) {
        changeInfo.oldHolder = null;
        oldItem = true;
    } else {
        return false;
    }
    item.itemView.setAlpha(1);
    if (item.itemView instanceof ChatMessageCell) {
        ((ChatMessageCell) item.itemView).setAnimationOffsetX(0);
        ((ChatMessageCell) item.itemView).getTransitionParams().resetAnimation();
    } else {
        item.itemView.setTranslationX(0);
    }
    item.itemView.setTranslationY(0);
    dispatchChangeFinished(item, oldItem);

    return true;
}
 
源代码24 项目: Flubber   文件: FABRevealProvider.java
@Override
public Animator createAnimationFor(AnimationBody animationBody, final View view) {
    final AnimatorSet animatorSet = new AnimatorSet();

    final Animator animationClose = getCloseReveal(view);
    final Animator animationOpen = getOpenReveal(view);

    animationClose.addListener(
            SimpleAnimatorListener.forEnd(animation -> ((FloatingActionButton) view).setImageResource(newIconResId)));

    animatorSet.play(animationOpen).after(animationClose);

    return animatorSet;
}
 
源代码25 项目: Camera2   文件: ModeListView.java
@Override
public void startAnimation(Animator.AnimatorListener listener)
{
    if (mPeepHoleAnimator != null && mPeepHoleAnimator.isRunning())
    {
        return;
    }
    if (mPeepHoleCenterY == UNSET || mPeepHoleCenterX == UNSET)
    {
        mPeepHoleCenterX = mWidth / 2;
        mPeepHoleCenterY = mHeight / 2;
    }

    mCirclePaint.setAlpha(255);
    mCoverPaint.setAlpha(255);

    // add peephole and reveal animators to a set, so we can
    // freely add the listener without having to worry about
    // listener dupes
    AnimatorSet s = new AnimatorSet();
    s.play(mPeepHoleAnimator).with(mRevealAlphaAnimator);
    if (listener != null)
    {
        s.addListener(listener);
    }
    s.start();
}
 
源代码26 项目: delion   文件: SwipableOverlayView.java
/**
 * Creates an AnimatorListenerAdapter that cleans up after an animation is completed.
 * @return {@link AnimatorListenerAdapter} to use for animations.
 */
private AnimatorListener createAnimatorListener() {
    return new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            mGestureState = GESTURE_NONE;
            mCurrentAnimation = null;
            mIsBeingDisplayedForFirstTime = false;
        }
    };
}
 
@Override
public void setInterpolator(Interpolator value) {
    Animator a = mAnimator.get();
    if(a != null) {
        a.setInterpolator(value);
    }
}
 
源代码28 项目: WeGit   文件: SupportAnimatorLollipop.java
@Override
public void setInterpolator(Interpolator value) {
    Animator a = mNativeAnimator.get();
    if(a != null) {
        a.setInterpolator(value);
    }
}
 
源代码29 项目: TurboLauncher   文件: LauncherAnimUtils.java
public static void onDestroyActivity() {
    HashSet<Animator> animators = new HashSet<Animator>(sAnimators.keySet());
    for (Animator a : animators) {
        if (a.isRunning()) {
            a.cancel();
        }
        sAnimators.remove(a);
    }
}
 
源代码30 项目: tilt-game-android   文件: WorldController.java
public void playLevelEndAnimation() {
    Vector2 destPos = _gameLevel.getSinkholeLocation();

    // if level doesn't have a sink, don't bother with the animation
    if (_ballSprite == null || destPos == null) {
        _gameLevelStateListener.onOutAnimationComplete();
        return;
    }

    _isAnimating = true;

    long duration = 200;

    ObjectAnimator.ofFloat(_ballSprite, "x", destPos.x).setDuration(duration).start();
    ObjectAnimator animator = ObjectAnimator.ofFloat(_ballSprite, "y", destPos.y).setDuration(duration);
    animator.start();

    animator.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            _ballSprite.hide(100);

            _sinkHole.hide(200, null);
            _sinkHoleBorder.hide(300, new AnimationCallback() {
                @Override
                public void onComplete() {
                    if (_gameLevelStateListener != null) {
                        _gameLevelStateListener.onOutAnimationComplete();
                    }

                    _isAnimating = false;
                }
            });
        }
    });
}