类android.view.animation.LinearInterpolator源码实例Demo

下面列出了怎么用android.view.animation.LinearInterpolator的API类实例代码及写法,或者点击链接到github查看源代码。

CameraXVideoCaptureHelper(@NonNull Fragment fragment,
                          @NonNull CameraButtonView captureButton,
                          @NonNull CameraXView camera,
                          @NonNull MemoryFileDescriptor memoryFileDescriptor,
                          int      maxVideoDurationSec,
                          @NonNull Callback callback)
{
  this.fragment               = fragment;
  this.camera                 = camera;
  this.memoryFileDescriptor   = memoryFileDescriptor;
  this.callback               = callback;
  this.updateProgressAnimator = ValueAnimator.ofFloat(0f, 1f).setDuration(maxVideoDurationSec * 1000);

  updateProgressAnimator.setInterpolator(new LinearInterpolator());
  updateProgressAnimator.addUpdateListener(anim -> captureButton.setProgress(anim.getAnimatedFraction()));
  updateProgressAnimator.addListener(new AnimationEndCallback() {
    @Override
    public void onAnimationEnd(Animator animation) {
      if (isRecording) onVideoCaptureComplete();
    }
  });
}
 
源代码2 项目: scene   文件: Case1Scene.java
@NonNull
@Override
protected Animator onPopAnimator(final AnimationInfo fromInfo, final AnimationInfo toInfo) {
    final View toView = toInfo.mSceneView;
    final View fromView = fromInfo.mSceneView;

    ValueAnimator fromAlphaAnimator = ObjectAnimator.ofFloat(fromView, View.ALPHA, 1.0f, 0.0f);
    fromAlphaAnimator.setInterpolator(new LinearInterpolator());
    fromAlphaAnimator.setDuration(150 * 20);
    fromAlphaAnimator.setStartDelay(50 * 20);

    ValueAnimator fromTranslateAnimator = ObjectAnimator.ofFloat(fromView, View.TRANSLATION_Y, 0, 0.08f * toView.getHeight());
    fromTranslateAnimator.setInterpolator(new AccelerateInterpolator(2));
    fromTranslateAnimator.setDuration(200 * 20);

    ValueAnimator toAlphaAnimator = ObjectAnimator.ofFloat(toView, View.ALPHA, 0.7f, 1.0f);
    toAlphaAnimator.setInterpolator(new LinearOutSlowInInterpolator());
    toAlphaAnimator.setDuration(20 * 20);
    return TransitionUtils.mergeAnimators(fromAlphaAnimator, fromTranslateAnimator, toAlphaAnimator);
}
 
@NonNull
@Override
protected Animator onPopAnimator(final AnimationInfo fromInfo, final AnimationInfo toInfo) {
    if (fromInfo.mIsTranslucent) {
        return mDialogSceneAnimatorExecutor.onPopAnimator(fromInfo, toInfo);
    }
    final View toView = toInfo.mSceneView;
    final View fromView = fromInfo.mSceneView;

    ValueAnimator fromAlphaAnimator = ObjectAnimator.ofFloat(fromView, View.ALPHA, 1.0f, 0.0f);
    fromAlphaAnimator.setInterpolator(new LinearInterpolator());
    fromAlphaAnimator.setDuration(150);
    fromAlphaAnimator.setStartDelay(50);

    ValueAnimator fromTranslateAnimator = ObjectAnimator.ofFloat(fromView, View.TRANSLATION_Y, 0, 0.08f * toView.getHeight());
    fromTranslateAnimator.setInterpolator(new AccelerateInterpolator(2));
    fromTranslateAnimator.setDuration(200);

    ValueAnimator toAlphaAnimator = ObjectAnimator.ofFloat(toView, View.ALPHA, 0.7f, 1.0f);
    toAlphaAnimator.setInterpolator(new LinearOutSlowInInterpolator());
    toAlphaAnimator.setDuration(200);
    return TransitionUtils.mergeAnimators(fromAlphaAnimator, fromTranslateAnimator, toAlphaAnimator);
}
 
源代码4 项目: FlowHelper   文件: BaseAction.java
/**
 * 放大缩小效果
 */
public void autoScaleView() {
    if (mParentView != null && mIsAutoScale && mScaleFactor > 1) {
        View lastView = mParentView.getChildAt(mLastIndex);
        View curView = mParentView.getChildAt(mCurrentIndex);
        if (lastView != null && curView != null) {
            lastView.animate()
                    .scaleX(1)
                    .scaleY(1)
                    .setDuration(mAnimTime)
                    .setInterpolator(new LinearInterpolator())
                    .start();
            curView.animate()
                    .scaleX(mScaleFactor)
                    .scaleY(mScaleFactor)
                    .setDuration(mAnimTime)
                    .setInterpolator(new LinearInterpolator())
                    .start();
        }
    }
}
 
源代码5 项目: ShizuruNotes   文件: CalendarLayout.java
/**
 * 隐藏内容布局
 */
@SuppressLint("NewApi")
final void hideContentView() {
    if (mContentView == null)
        return;
    mContentView.animate()
            .translationY(getHeight() - mMonthView.getHeight())
            .setDuration(220)
            .setInterpolator(new LinearInterpolator())
            .setListener(new AnimatorListenerAdapter() {
                @Override
                public void onAnimationEnd(Animator animation) {
                    super.onAnimationEnd(animation);
                    mContentView.setVisibility(INVISIBLE);
                    mContentView.clearAnimation();
                }
            });
}
 
源代码6 项目: WanAndroid   文件: SVGBgView.java
private void init() {
    mPathDataList = new ArrayList<>();
    mSvgRealSize = new RectF();

    mSvgPaint = new Paint(Paint.ANTI_ALIAS_FLAG);

    mValueAnimator = ValueAnimator.ofFloat(0);
    mValueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mCurPathDataIndex = (float) animation.getAnimatedValue();
            postInvalidate();
        }
    });
    mValueAnimator.setInterpolator(new LinearInterpolator());
    mValueAnimator.setDuration(ANIM_TIME);

    new ParserThread().start();
}
 
源代码7 项目: HokoBlur   文件: MultiBlurActivity.java
private void setImage(@DrawableRes final int id) {
    mImageView.setImageResource(id);
    mDispatcher.submit(() -> {
        mInBitmap = BitmapFactory.decodeResource(getResources(), id);

        runOnUiThread(() -> {
            endAnimators();
            mAnimator = ValueAnimator.ofInt(0, (int) (mRadius / 25f * 1000));
            mAnimator.setInterpolator(new LinearInterpolator());
            mAnimator.addUpdateListener(animation -> {
                mSeekBar.setProgress((Integer) animation.getAnimatedValue());
                updateImage((int) ((Integer) animation.getAnimatedValue() / 1000f * 25f));
            });

            mAnimator.setDuration(300);
            mAnimator.start();
        });
    });
}
 
源代码8 项目: a   文件: SmoothCheckBox.java
private void startUnCheckedAnimation() {
    ValueAnimator animator = ValueAnimator.ofFloat(0f, 1.0f);
    animator.setDuration(mAnimDuration);
    animator.setInterpolator(new LinearInterpolator());
    animator.addUpdateListener(animation -> {
        mScaleVal = (float) animation.getAnimatedValue();
        mFloorColor = getGradientColor(mCheckedColor, mFloorUnCheckedColor, mScaleVal);
        postInvalidate();
    });
    animator.start();

    ValueAnimator floorAnimator = ValueAnimator.ofFloat(1.0f, 0.8f, 1.0f);
    floorAnimator.setDuration(mAnimDuration);
    floorAnimator.setInterpolator(new LinearInterpolator());
    floorAnimator.addUpdateListener(animation -> {
        mFloorScale = (float) animation.getAnimatedValue();
        postInvalidate();
    });
    floorAnimator.start();
}
 
源代码9 项目: timecat   文件: ArcLayout.java
/**
 * 收缩动画
 */
private static Animation createShrinkAnimation(float fromXDelta, float toXDelta, float fromYDelta, float toYDelta, long startOffset, long duration, Interpolator interpolator) {
    AnimationSet animationSet = new AnimationSet(false);
    animationSet.setFillAfter(true);
    //收缩过程中,child 逆时针自旋转360度
    final long preDuration = duration / 2;
    Animation rotateAnimation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    rotateAnimation.setStartOffset(startOffset);
    rotateAnimation.setDuration(preDuration);
    rotateAnimation.setInterpolator(new LinearInterpolator());
    rotateAnimation.setFillAfter(true);

    animationSet.addAnimation(rotateAnimation);
    //收缩过程中位移,并逆时针旋转360度
    Animation translateAnimation = new RotateAndTranslateAnimation(0, toXDelta, 0, toYDelta, 360, 720);
    translateAnimation.setStartOffset(startOffset + preDuration);
    translateAnimation.setDuration(duration - preDuration);
    translateAnimation.setInterpolator(interpolator);
    translateAnimation.setFillAfter(true);

    animationSet.addAnimation(translateAnimation);

    return animationSet;
}
 
源代码10 项目: SchoolQuest   文件: LessonB.java
public void setUpSliderAnimation() {
    GameActivity gameActivity = GameActivity.getInstance();

    ImageView slider = gameActivity.findViewById(R.id.lesson_b_craft_bar_slider);
    ImageView craftBar = gameActivity.findViewById(R.id.lesson_b_craft_bar);

    int craftBarWidth = craftBar.getDrawable().getIntrinsicWidth();

    ObjectAnimator sliderAnimation = ObjectAnimator.ofFloat(slider, "translationX",
            -(craftBarWidth / 2) + (craftBarWidth / 27),
            (craftBarWidth / 2) - (craftBarWidth / 27));

    int baseSliderTime = 250;
    sliderAnimation.setDuration(baseSliderTime + (attn * baseSliderTime));
    sliderAnimation.setRepeatCount(-1);
    sliderAnimation.setRepeatMode(ValueAnimator.REVERSE);
    sliderAnimation.setInterpolator(new LinearInterpolator());

    sliderAnimation.start();
}
 
源代码11 项目: YCAudioPlayer   文件: YCLrcCustomView.java
private void scrollTo(int line, long duration) {
    float offset = getOffset(line);
    endAnimation();

    mAnimator = ValueAnimator.ofFloat(mOffset, offset);
    mAnimator.setDuration(duration);
    mAnimator.setInterpolator(new LinearInterpolator());
    mAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mOffset = (float) animation.getAnimatedValue();
            invalidate();
        }
    });
    mAnimator.start();
}
 
源代码12 项目: wallpaper   文件: PullToRefreshView.java
/**
 * init
 * 
 * @description
 * @param context
 *            hylin 2012-7-26上午10:08:33
 */
private void init() {
	// Load all of the animations we need in code rather than through XML
	mFlipAnimation = new RotateAnimation(0, -180,
			RotateAnimation.RELATIVE_TO_SELF, 0.5f,
			RotateAnimation.RELATIVE_TO_SELF, 0.5f);
	mFlipAnimation.setInterpolator(new LinearInterpolator());
	mFlipAnimation.setDuration(250);
	mFlipAnimation.setFillAfter(true);
	mReverseFlipAnimation = new RotateAnimation(-180, 0,
			RotateAnimation.RELATIVE_TO_SELF, 0.5f,
			RotateAnimation.RELATIVE_TO_SELF, 0.5f);
	mReverseFlipAnimation.setInterpolator(new LinearInterpolator());
	mReverseFlipAnimation.setDuration(250);
	mReverseFlipAnimation.setFillAfter(true);

	mInflater = LayoutInflater.from(getContext());
	// header view 在此添加,保证是第一个添加到linearlayout的最上端
	addHeaderView();
}
 
源代码13 项目: MyBookshelf   文件: SmoothCheckBox.java
private void startCheckedAnimation() {
    ValueAnimator animator = ValueAnimator.ofFloat(1.0f, 0f);
    animator.setDuration(mAnimDuration / 3 * 2);
    animator.setInterpolator(new LinearInterpolator());
    animator.addUpdateListener(animation -> {
        mScaleVal = (float) animation.getAnimatedValue();
        mFloorColor = getGradientColor(mUnCheckedColor, mCheckedColor, 1 - mScaleVal);
        postInvalidate();
    });
    animator.start();

    ValueAnimator floorAnimator = ValueAnimator.ofFloat(1.0f, 0.8f, 1.0f);
    floorAnimator.setDuration(mAnimDuration);
    floorAnimator.setInterpolator(new LinearInterpolator());
    floorAnimator.addUpdateListener(animation -> {
        mFloorScale = (float) animation.getAnimatedValue();
        postInvalidate();
    });
    floorAnimator.start();

    drawTickDelayed();
}
 
源代码14 项目: SimpleVideoEdit   文件: TrimmerActivity.java
private void anim() {
    Log.d(TAG, "--anim--onProgressUpdate---->>>>>>>" + mPlayer.getCurrentPosition());
    if (positionIcon.getVisibility() == View.GONE) {
        positionIcon.setVisibility(View.VISIBLE);
    }
    final RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) positionIcon.getLayoutParams();
    int start = (int) (UIUtil.dip2px(this, INIT_THUMBVIEW_GAP) + (mStartPositionMs/*mVideoView.getCurrentPosition()*/ - scrolledMs) * pxPerMs);
    int end = (int) (UIUtil.dip2px(this, INIT_THUMBVIEW_GAP) + (mEndPositionMs - scrolledMs) * pxPerMs);
    animator = ValueAnimator
            .ofInt(start, end)
            .setDuration((mEndPositionMs - scrolledMs) - (mStartPositionMs/*mVideoView.getCurrentPosition()*/ - scrolledMs));
    animator.setInterpolator(new LinearInterpolator());
    animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            params.leftMargin = (int) animation.getAnimatedValue();
            positionIcon.setLayoutParams(params);
        }
    });
    animator.start();
}
 
源代码15 项目: mollyim-android   文件: MicrophoneRecorderView.java
void hide() {
  lockDropTarget.animate()
                .setStartDelay(0)
                .setDuration(ANIMATION_DURATION)
                .setInterpolator(new LinearInterpolator())
                .scaleX(0).scaleY(0)
                .start();
}
 
源代码16 项目: MyBookshelf   文件: PageAnimation.java
PageAnimation(int w, int h, int marginWidth, int marginTop, int marginBottom, View view, OnPageChangeListener listener) {
    mScreenWidth = w;
    mScreenHeight = h;

    //屏幕的间距
    mMarginTop = marginTop;

    mViewWidth = mScreenWidth - marginWidth * 2;
    mViewHeight = mScreenHeight - mMarginTop - marginBottom;

    mView = view;
    mListener = listener;

    mScroller = new Scroller(mView.getContext(), new LinearInterpolator());
}
 
源代码17 项目: star-zone-android   文件: PullRefreshFooter.java
private void initView(Context context) {
    View.inflate(context, R.layout.view_ptr_footer, this);
    loadingView = (ImageView) findViewById(R.id.iv_loading);
    rotateAnimation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    rotateAnimation.setDuration(600);
    rotateAnimation.setInterpolator(new LinearInterpolator());
    rotateAnimation.setRepeatCount(Animation.INFINITE);
    setVisibility(GONE);
}
 
private void initRotation(ImageView ivLoader) {
    if (loaderAnimation == null) {
        loaderAnimation = ObjectAnimator.ofFloat(ivLoader, "rotation", 0.0f, 360f);
        loaderAnimation.setDuration(1500);
        loaderAnimation.setRepeatCount(ObjectAnimator.INFINITE);
        loaderAnimation.setInterpolator(new LinearInterpolator());
        loaderAnimation.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                super.onAnimationCancel(animation);
                tvUpdateTransactions.setClickable(true);
            }
        });
    }
}
 
private void startClockwiseRotation(ImageView ivLoader) {
    loaderAnimation = ObjectAnimator.ofFloat(ivLoader, "rotation", 0.0f, 360f);
    loaderAnimation.setDuration(1500);
    loaderAnimation.setRepeatCount(ObjectAnimator.INFINITE);
    loaderAnimation.setInterpolator(new LinearInterpolator());
    loaderAnimation.start();
}
 
源代码20 项目: FimiX8-RE   文件: X8AiAutoPhotoLoadingView.java
private void init() {
    this.state = 3;
    this.objectAnimator = ObjectAnimator.ofFloat(this.imgLoading, "rotation", new float[]{0.0f, 360.0f});
    this.objectAnimator.setDuration(1500);
    this.objectAnimator.setInterpolator(new LinearInterpolator());
    this.objectAnimator.setRepeatCount(-1);
    this.objectAnimator.setRepeatMode(1);
}
 
源代码21 项目: ThermometerView   文件: ThermometerView.java
/**
 * 设置温度值并启动动画(插值器:LinearInterpolator)
 *
 * @param newValue 新温度值float(℃)
 */
public void setValueAndStartAnim(float newValue) {
    if (newValue < minScaleValue) {
        newValue = minScaleValue;
    }
    if (newValue > maxScaleValue) {
        newValue = maxScaleValue;
    }

    ObjectAnimator waveShiftAnim = ObjectAnimator.ofFloat(this, "curValue", curScaleValue, newValue);
    waveShiftAnim.setRepeatCount(0);
    waveShiftAnim.setDuration(500);
    waveShiftAnim.setInterpolator(new LinearInterpolator());
    waveShiftAnim.start();
}
 
源代码22 项目: Upchain-wallet   文件: LoadingView.java
private void buildAnimator() {
    final ValueAnimator valueAnimator = ValueAnimator.ofFloat(0f, 1f).setDuration(ANIMATOR_DURATION);
    valueAnimator.setRepeatCount(-1);
    valueAnimator.setInterpolator(new LinearInterpolator());
    valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            mRotation = (float) valueAnimator.getAnimatedValue();
            invalidate();
        }
    });
    animator = valueAnimator;
    animatorSet = buildFlexibleAnimation();
    animatorSet.addListener(animatorListener);
}
 
public void initView(Context context) {
  LayoutInflater.from(context).inflate(R.layout.layout_daisy, this);
  mTxtLoading = findViewById(R.id.txt_loading);
  mTxtLoading.setText("下拉刷新");
  mImgDaisy = findViewById(R.id.img_daisy);
  mRotation = ObjectAnimator.ofFloat(mImgDaisy, "rotation", 0, 360).setDuration(800);
  mRotation.setRepeatCount(ValueAnimator.INFINITE);
  mRotation.setInterpolator(new LinearInterpolator());

}
 
public void initView(Context context) {
  LayoutInflater.from(context).inflate(R.layout.layout_daisy, this);
  mTxtLoading = findViewById(R.id.txt_loading);
  mTxtLoading.setText("上拉加载更多...");
  mImgDaisy = findViewById(R.id.img_daisy);

  mRotation = ObjectAnimator.ofFloat(mImgDaisy, "rotation", 0, 360).setDuration(800);
  mRotation.setRepeatCount(ValueAnimator.INFINITE);
  mRotation.setInterpolator(new LinearInterpolator());

}
 
源代码25 项目: WidgetCase   文件: HalfCircleProView.java
private void initAnimation() {
    progressAnimator = ValueAnimator.ofFloat(0, mProgress);
    progressAnimator.setDuration(duration);
    progressAnimator.setStartDelay(startDelay);
    progressAnimator.setInterpolator(new LinearInterpolator());
    progressAnimator.addUpdateListener(valueAnimator -> {
        float value = (float) valueAnimator.getAnimatedValue();
        mProgress = value;
        invalidate();
    });
    progressAnimator.start();
}
 
源代码26 项目: WidgetCase   文件: ShadowProBar.java
/**
     * 进度移动动画  通过插值的方式改变移动的距离
     */
    private void initAnimation() {
        progressAnimator = ValueAnimator.ofFloat(0, mProgress);
        progressAnimator.setDuration(duration);
        progressAnimator.setStartDelay(startDelay);
        progressAnimator.setInterpolator(new LinearInterpolator());
        progressAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator valueAnimator) {
                float value = (float) valueAnimator.getAnimatedValue();
                //进度数值只显示整数,我们自己的需求,可以忽略
                //把当前百分比进度转化成view宽度对应的比例
                currentProgress = getWidth() * value / 100;

                if (currentProgress < progressRound && currentProgress != 0) {
                    currentProgress = progressRound;
                }

                if (currentProgress > getWidth()) {
                    currentProgress = getWidth();
                }
                //进度回调方法
//                if (progressListener != null) {
//                    progressListener.currentProgressListener(value);
//                }
                invalidate();
            }
        });
        progressAnimator.start();
    }
 
源代码27 项目: WidgetCase   文件: HorProBar.java
/**
 * 进度移动动画  通过插值的方式改变移动的距离
 */
private void initAnimation() {
    progressAnimator = ValueAnimator.ofFloat(0, mProgress);
    progressAnimator.setDuration(duration);
    progressAnimator.setStartDelay(startDelay);
    progressAnimator.setInterpolator(new LinearInterpolator());
    progressAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            float value = (float) valueAnimator.getAnimatedValue();
            //进度数值只显示整数,我们自己的需求,可以忽略
            textString = formatNum(/*format2Int(*/value);
            tipWidth = (int) (textPaint.measureText(textString + "%") + dp2px(10));
            //把当前百分比进度转化成view宽度对应的比例
            currentProgress = (mProgressWidth) * value / 100;
            if (currentProgress < dp2px(2) && currentProgress != 0) {
                currentProgress = dp2px(2);
            }
            //进度回调方法
            if (progressListener != null) {
                progressListener.currentProgressListener(value);
            }
            //移动百分比提示框,只有当前进度到提示框中间位置之后开始移动,
            //当进度框移动到最右边的时候停止移动,但是进度条还可以继续移动
            //moveDis是tip框移动的距离
            if (currentProgress <= (mProgressWidth)) {
                moveDis = (mWidth - mProgressWidth - tipWidth) / 2 + currentProgress;
            } else  /*if (currentProgress > mWidth-tipWidth)*/ {
                moveDis = (mWidth + mProgressWidth - tipWidth) / 2;
            }
            if (moveDis == 0) {
                moveDis = (mWidth - mProgressWidth - tipWidth) / 2;
            }

            invalidate();
        }
    });
    progressAnimator.start();
}
 
源代码28 项目: DS4Android   文件: LinkedView.java
private void init() {
    //初始化主画笔
    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaint.setColor(Color.BLUE);
    mPaint.setStrokeWidth(5);
    mPaint.setTextAlign(Paint.Align.CENTER);
    mPaint.setTextSize(50);
    //初始化主路径
    mPath = new Path();
    //初始化文字画笔
    mTxtPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mTxtPaint.setColor(Color.WHITE);
    mTxtPaint.setTextAlign(Paint.Align.CENTER);
    mTxtPaint.setTextSize(40);
    //初始化路径画笔
    mPathPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPathPaint.setColor(0xff810DF3);
    mPathPaint.setStrokeWidth(4);
    mPathPaint.setStyle(Paint.Style.STROKE);
    mCooPicture = HelpDraw.getCoo(getContext(), mCoo, false);
    mGridPicture = HelpDraw.getGrid(getContext());
    //初始化圆球按钮画笔
    mCtrlPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mCtrlPaint.setColor(Color.RED);
    mCtrlPaint.setTextAlign(Paint.Align.CENTER);
    mCtrlPaint.setTextSize(30);
    //初始化时间流ValueAnimator
    mAnimator = ValueAnimator.ofFloat(0, 1);
    mAnimator.setRepeatCount(-1);
    mAnimator.setDuration(2000);
    mAnimator.setRepeatMode(ValueAnimator.REVERSE);
    mAnimator.setInterpolator(new LinearInterpolator());
    mAnimator.addUpdateListener(animation -> {
        updateBall();//更新小球位置
        invalidate();
    });
}
 
源代码29 项目: android_9.0.0_r45   文件: BurnInProtectionHelper.java
public BurnInProtectionHelper(Context context, int minHorizontalOffset,
        int maxHorizontalOffset, int minVerticalOffset, int maxVerticalOffset,
        int maxOffsetRadius) {
    mMinHorizontalBurnInOffset = minHorizontalOffset;
    mMaxHorizontalBurnInOffset = maxHorizontalOffset;
    mMinVerticalBurnInOffset = minVerticalOffset;
    mMaxVerticalBurnInOffset = maxVerticalOffset;
    if (maxOffsetRadius != BURN_IN_MAX_RADIUS_DEFAULT) {
        mBurnInRadiusMaxSquared = maxOffsetRadius * maxOffsetRadius;
    } else {
        mBurnInRadiusMaxSquared = BURN_IN_MAX_RADIUS_DEFAULT;
    }

    mDisplayManagerInternal = LocalServices.getService(DisplayManagerInternal.class);
    mAlarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
    context.registerReceiver(mBurnInProtectionReceiver,
            new IntentFilter(ACTION_BURN_IN_PROTECTION));
    Intent intent = new Intent(ACTION_BURN_IN_PROTECTION);
    intent.setPackage(context.getPackageName());
    intent.setFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
    mBurnInProtectionIntent = PendingIntent.getBroadcast(context, 0,
            intent, PendingIntent.FLAG_UPDATE_CURRENT);
    DisplayManager displayManager =
            (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);
    mDisplay = displayManager.getDisplay(Display.DEFAULT_DISPLAY);
    displayManager.registerDisplayListener(this, null /* handler */);

    mCenteringAnimator = ValueAnimator.ofFloat(1f, 0f);
    mCenteringAnimator.setDuration(CENTERING_ANIMATION_DURATION_MS);
    mCenteringAnimator.setInterpolator(new LinearInterpolator());
    mCenteringAnimator.addListener(this);
    mCenteringAnimator.addUpdateListener(this);
}
 
源代码30 项目: DS4Android   文件: SingleLinkedView.java
private void init() {
    //初始化主画笔
    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaint.setColor(Color.BLUE);
    mPaint.setStrokeWidth(5);
    mPaint.setTextAlign(Paint.Align.CENTER);
    mPaint.setTextSize(50);
    //初始化主路径
    mPath = new Path();
    //初始化文字画笔
    mTxtPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mTxtPaint.setColor(Color.WHITE);
    mTxtPaint.setTextAlign(Paint.Align.CENTER);
    mTxtPaint.setTextSize(40);
    //初始化路径画笔
    mPathPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPathPaint.setColor(0xff810DF3);
    mPathPaint.setStrokeWidth(4);
    mPathPaint.setStyle(Paint.Style.STROKE);
    mCooPicture = HelpDraw.getCoo(getContext(), mCoo, false);
    mGridPicture = HelpDraw.getGrid(getContext());
    //初始化圆球按钮画笔
    mCtrlPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mCtrlPaint.setColor(Color.RED);
    mCtrlPaint.setTextAlign(Paint.Align.CENTER);
    mCtrlPaint.setTextSize(30);
    //初始化时间流ValueAnimator
    mAnimator = ValueAnimator.ofFloat(0, 1);
    mAnimator.setRepeatCount(-1);
    mAnimator.setDuration(2000);
    mAnimator.setRepeatMode(ValueAnimator.REVERSE);
    mAnimator.setInterpolator(new LinearInterpolator());
    mAnimator.addUpdateListener(animation -> {
        updateBall();//更新小球位置
        invalidate();
    });
}