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

The following examples show how to use android.animation.ObjectAnimator#setRepeatCount() . 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: ProgressView.java    From EhViewer with Apache License 2.0 6 votes vote down vote up
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);
    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);
}
 
Example 2
Source File: PropertyAnimationActivity.java    From Study_Android_Demo with Apache License 2.0 6 votes vote down vote up
/**
 * ObjectAnimator usage
 *
 * @param b
 * @return
 */
public ObjectAnimator getObjectAnimator(boolean b) {
    if (b) {
        ObjectAnimator bgColorAnimator = ObjectAnimator.ofArgb(mPuppet,
                "backgroundColor",
                0xff009688, 0xff795548);
        bgColorAnimator.setRepeatCount(1);
        bgColorAnimator.setDuration(3000);
        bgColorAnimator.setRepeatMode(ValueAnimator.REVERSE);
        bgColorAnimator.setStartDelay(0);
        return bgColorAnimator;
    } else {
        ObjectAnimator rotationXAnimator = ObjectAnimator.ofFloat(mPuppet,
                "rotationX",
                0f, 360f);
        rotationXAnimator.setRepeatCount(1);
        rotationXAnimator.setDuration(3000);
        rotationXAnimator.setRepeatMode(ValueAnimator.REVERSE);
        return rotationXAnimator;
    }
}
 
Example 3
Source File: ObjectPropertyAnimActivity.java    From AndroidStudyDemo with GNU General Public License v2.0 6 votes vote down vote up
public void startSkewAnimation(View v) {
    float scale = (float)mShowAnimIV.getHeight()/(float)mShowAnimIV.getDrawable().getIntrinsicHeight();
    Matrix from = new Matrix();
    from.setScale(scale, scale);
    from.postSkew(-0.5f, 0.0f);
    Matrix to = new Matrix(mShowAnimIV.getMatrix());
    to.setScale(scale, scale);
    to.postSkew(0.5f, 0.0f);

    mShowAnimIV.setScaleType(ImageView.ScaleType.MATRIX);
    Matrix start = new Matrix();
    start.setScale(scale, scale);
    mShowAnimIV.setImageMatrix(start);

    ObjectAnimator objectAnimator = ObjectAnimator.ofObject(mShowAnimIV, "imageMatrix", new MatrixEvaluator(), from, to);
    objectAnimator.setDuration(C.Int.ANIM_DURATION);
    objectAnimator.setRepeatCount(5);
    objectAnimator.setRepeatMode(ObjectAnimator.REVERSE);
    objectAnimator.start();
}
 
Example 4
Source File: WavePicView.java    From WavesView with MIT License 6 votes vote down vote up
/**
 * 动画
 */
private void animateDisplayWave() {
    if (left_WaveView != null && center_WaveView != null) {
        left_WaveView.setAnimationCacheEnabled(false);
        center_WaveView.setAnimationCacheEnabled(false);
        ObjectAnimator transX_waveLeft = ObjectAnimator.ofFloat(left_WaveView, "translationX", 0, 1920);
        ObjectAnimator transX_waveCenter = ObjectAnimator.ofFloat(center_WaveView, "translationX", 0, 1920);
        transX_waveLeft.setRepeatMode(ValueAnimator.RESTART);
        transX_waveLeft.setRepeatCount(Animation.INFINITE);
        transX_waveCenter.setRepeatMode(ValueAnimator.RESTART);
        transX_waveCenter.setRepeatCount(Animation.INFINITE);
        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.setDuration(16000);
        animatorSet.setInterpolator(new LinearInterpolator());
        animatorSet.playTogether(transX_waveLeft, transX_waveCenter);
        animatorSet.start();
    }
}
 
Example 5
Source File: PropertyAnimActivity.java    From AndroidStudyDemo with GNU General Public License v2.0 6 votes vote down vote up
public void testObjectAnimator(View v) {
    if (v.getId() == R.id.sdi_objectanimator_btn) {
        // 简单示例:View的横向移动
        ObjectAnimator.ofFloat(mAnimView, "translationX", 0.0f, -200.0f)
                .setDuration(C.Int.ANIM_DURATION * 2)
                .start();
    } else {
        // 复合示例:View弹性落下然后弹起,执行一次
        ObjectAnimator yBouncer = ObjectAnimator.ofFloat(mAnimView, "y", mAnimView.getY(), 400.0f);
        yBouncer.setDuration(C.Int.ANIM_DURATION * 2);
        // 设置插值器(用于调节动画执行过程的速度)
        yBouncer.setInterpolator(new BounceInterpolator());
        // 设置重复次数(缺省为0,表示不重复执行)
        yBouncer.setRepeatCount(1);
        // 设置重复模式(RESTART或REVERSE),重复次数大于0或INFINITE生效
        yBouncer.setRepeatMode(ValueAnimator.REVERSE);
        // 设置动画开始的延时时间(200ms)
        yBouncer.setStartDelay(200);
        yBouncer.start();
    }
}
 
Example 6
Source File: MainActivity.java    From Study_Android_Demo with Apache License 2.0 6 votes vote down vote up
public void start(View view) {

		// ib.setRotation(0.8f);
		// 2.����ObjectAnimator����
		/*
		 * ����һ��ִ�ж����Ķ���
		 * 
		 * ��������������������,String,����һ��Ҫ�ṩset��get�ķ���
		 * 
		 * ������������������ֵ��
		 */
		ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(ib, "Rotation",
				0, 360);
		// ���ó���ʱ��
		objectAnimator.setDuration(2000);
		// ���ó���ʱ��
		objectAnimator.setRepeatCount(10);
		// ��������
		objectAnimator.setInterpolator(new LinearInterpolator());
		// 3.��������
		objectAnimator.start();

	}
 
Example 7
Source File: FoldingLayoutActivity.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
/**
 * Animates the folding view inwards (to a completely folded state) from its
 * current state and then back out to its original state.
 */
public void animateFold() {
    float foldFactor = mFoldLayout.getFoldFactor();

    ObjectAnimator animator = ObjectAnimator.ofFloat(mFoldLayout,
            "foldFactor", foldFactor, 1);
    animator.setRepeatMode(ValueAnimator.REVERSE);
    animator.setRepeatCount(1);
    animator.setDuration(FOLD_ANIMATION_DURATION);
    animator.setInterpolator(new AccelerateInterpolator());
    animator.start();
}
 
Example 8
Source File: RocketAvatarsAnimator.java    From welcome-coordinator with Apache License 2.0 5 votes vote down vote up
private Animator getFlameAnimator(View targetView) {
    AnimatorSet animator = new AnimatorSet();
    animator.setDuration(1000);
    animator.setInterpolator(new LinearInterpolator());
    ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(targetView, View.ALPHA, 0f, 1f, 0.5f, 1f, 0.8f, 1f);
    ObjectAnimator scaleAnimator = ObjectAnimator.ofFloat(targetView, View.SCALE_Y, 0.8f, 1f, 0.9f, 1f, 0.7f, 1f);
    alphaAnimator.setRepeatCount(ValueAnimator.INFINITE);
    alphaAnimator.setRepeatMode(ValueAnimator.REVERSE);
    scaleAnimator.setRepeatCount(ValueAnimator.INFINITE);
    scaleAnimator.setRepeatMode(ValueAnimator.REVERSE);
    animator.playTogether(alphaAnimator, scaleAnimator);
    return animator;
}
 
Example 9
Source File: NavigationWelcomeActivity.java    From GifAssistant with Apache License 2.0 5 votes vote down vote up
private void doViewPagerAnimation4(int pagerIndex) {
	// 停掉页面3的动画及显示
	mCurrentPager3Flag = false;
	if (mCloudTransAnimationX1.isRunning()) {
		mCloudTransAnimationX1.cancel();
		mCloudTransAnimationY1.cancel();

		mCloudTransAnimation2.cancel();
		mCloudTransAnimation3.cancel();
		mCloudTransAnimation4.cancel();
	}
	mNav3CloudImageView1.setVisibility(View.INVISIBLE);
	mNav3CloudImageView2.setVisibility(View.INVISIBLE);
	mNav3CloudImageView3.setVisibility(View.INVISIBLE);
	mNav3CloudImageView4.setVisibility(View.INVISIBLE);
	mRocketAnimationDrawable.stop();

	ObjectAnimator objAnim = ObjectAnimator.ofFloat(mNav4TopImageView, "rotation", 0f, 10f);
	CycleInterpolator interpolator = new CycleInterpolator(3.0f);
	objAnim.setStartDelay(500);
	objAnim.setDuration(3000);
	objAnim.setRepeatCount(Animation.INFINITE);// Animation.INFINITE
	objAnim.setRepeatMode(Animation.RESTART);
	objAnim.setInterpolator(interpolator);
	mNav4TopImageView.setPivotX(mNav4TopImageView.getWidth()*0.47f);
	mNav4TopImageView.setPivotY(mNav4TopImageView.getHeight()*0.05f);
	objAnim.start();
	
	mNavTopStaticAnimationSet.setTarget(mNav4bottomTextImageView);  
	mNavTopStaticAnimationSet.start();
}
 
Example 10
Source File: ProgressBarView.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
public ProgressBarView(ContainerType containerType, ViewGroup container,
        XSharedPreferences prefs, ProgressBarController ctrl) {
    super(container.getContext());

    mContainerType = containerType;
    mCtrl = ctrl;

    mAnimated = prefs.getBoolean(GravityBoxSettings.PREF_KEY_STATUSBAR_DOWNLOAD_PROGRESS_ANIMATED, true);
    mCentered = prefs.getBoolean(GravityBoxSettings.PREF_KEY_STATUSBAR_DOWNLOAD_PROGRESS_CENTERED, false);
    mHeightPx = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
            prefs.getInt(GravityBoxSettings.PREF_KEY_STATUSBAR_DOWNLOAD_PROGRESS_THICKNESS, 1),
            getResources().getDisplayMetrics());
    mEdgeMarginPx = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
            prefs.getInt(GravityBoxSettings.PREF_KEY_STATUSBAR_DOWNLOAD_PROGRESS_MARGIN, 0),
            getResources().getDisplayMetrics());

    setScaleX(0f);
    setBackgroundColor(Color.WHITE);
    setVisibility(View.GONE);
    container.addView(this);

    mAnimator = new ObjectAnimator();
    mAnimator.setTarget(this);
    mAnimator.setInterpolator(new DecelerateInterpolator());
    mAnimator.setDuration(ANIM_DURATION);
    mAnimator.setRepeatCount(0);
}
 
Example 11
Source File: FirstActivity.java    From YourWeather with Apache License 2.0 5 votes vote down vote up
private void playSunAnim() {
    ObjectAnimator anim = ObjectAnimator.ofFloat(splashSun, "rotation", 0f, 360f);
    anim.setRepeatMode(ObjectAnimator.RESTART);
    anim.setRepeatCount(ObjectAnimator.INFINITE);
    anim.setInterpolator(new LinearInterpolator());
    anim.setDuration(30 * 1000);
    anim.start();
}
 
Example 12
Source File: PropertyAnimation09.java    From cogitolearning-examples with MIT License 5 votes vote down vote up
@Override
@SuppressLint("NewApi")
protected void onCreate(Bundle savedInstanceState)
{
  super.onCreate(savedInstanceState);
  setContentView(R.layout.property_animations09);

  if (android.os.Build.VERSION.SDK_INT >= 19)
  {
    ImageView someImage = (ImageView) findViewById(R.id.some_image);

    ObjectAnimator rotateAnim = ObjectAnimator.ofFloat(someImage, "rotation", 0, 360);
    rotateAnim.setDuration(1000);
    rotateAnim.setRepeatCount(5);
    rotateAnim.setRepeatMode(ObjectAnimator.RESTART);

    fpsText = (TextView) findViewById(R.id.fps_text);
    FpsTimeListener listener = new FpsTimeListener(fpsText);
    
    final TimeAnimator timeAnim = new TimeAnimator();
    timeAnim.setTimeListener(listener);
    
    anim = new AnimatorSet();
    anim.play(rotateAnim).with(timeAnim);
    rotateAnim.addListener(new AnimatorListenerAdapter()
    {
      @Override
      public void onAnimationEnd(Animator animation)
      {
        timeAnim.end(); 
      }
    });
  }
}
 
Example 13
Source File: UDAnimator.java    From VideoOS-Android-SDK with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 重复次数,负数标示无限
 *
 * @param repeatCount
 * @return
 */
public UDAnimator setRepeatCount(int repeatCount) {
    ObjectAnimator animator = getAnimator();
    if (animator != null) {
        if (repeatCount >= 0) {
            animator.setRepeatCount(repeatCount);
        } else {
            animator.setRepeatCount(ValueAnimator.INFINITE);
        }
    }
    return this;
}
 
Example 14
Source File: GuideVideoActivity.java    From smart-farmer-android with Apache License 2.0 5 votes vote down vote up
private void playAnim() {
    ObjectAnimator anim = ObjectAnimator.ofFloat(appName, "alpha", 0, 1);
    anim.setDuration(4000);
    anim.setRepeatCount(1);
    anim.setRepeatMode(ObjectAnimator.REVERSE);
    anim.start();
    anim.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            appName.setVisibility(View.INVISIBLE);
        }
    });
}
 
Example 15
Source File: RevealView.java    From PracticeDemo with Apache License 2.0 5 votes vote down vote up
/**
 *  可以做成loading效果~~
 */
public void startLoading() {

    ObjectAnimator revealAnimator = ObjectAnimator.ofInt(this, "radius", 20, 50);
    revealAnimator.setRepeatMode(ValueAnimator.REVERSE);
    revealAnimator.setInterpolator(new LinearInterpolator());
    revealAnimator.setRepeatCount(ValueAnimator.INFINITE);
    revealAnimator.start();
    //revealAnimator.cancel();
}
 
Example 16
Source File: PomodoroTransitionActivity.java    From WearPomodoro with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onLayoutInflated(WatchViewStub stub) {
    super.onLayoutInflated(stub);
    PomodoroAlarmReceiver.completeWakefulIntent(getIntent());
    pomodoroMaster.cancelNotification();
    vibrator.vibrate(1000);

    awesomeGif = (GifImageView) stub.findViewById(R.id.transition_awesome_gif);
    awesomeGif.setBytes(PomodoroUtils.readRawResourceBytes(getResources(), R.raw.pomodoro));
    awesomeGif.startAnimation();

    if (nextActivityType.isBreak()) {
        float dp = PomodoroUtils.dipToPixels(this, 1);
        ObjectAnimator anim = ObjectAnimator.ofFloat(awesomeGif, View.TRANSLATION_X, -8*dp, 8*dp);
        anim.setDuration(1200);
        anim.setRepeatMode(ObjectAnimator.REVERSE);
        anim.setRepeatCount(ObjectAnimator.INFINITE);
        anim.setInterpolator(new AccelerateDecelerateInterpolator());
        anim.start();
    }

    final TextView messageText = (TextView) stub.findViewById(R.id.transition_text);
    final int eatenPomodoros = pomodoroMaster.getEatenPomodoros();

    if (nextActivityType.isBreak()) {
        int templateId = nextActivityType == ActivityType.LONG_BREAK ?
                R.string.transition_text_before_long_break_message_template :
                R.string.transition_text_before_short_break_message_template;
        messageText.setText(String.format(
                getString(templateId),
                eatenPomodoros + 1));
        activateStepsCounter();
    } else if (nextActivityType.isPomodoro()) {
        messageText.setText(String.format(
                getString(R.string.transition_text_before_pomodoro_message_template),
                eatenPomodoros + 1));
        uiTimer.schedule(new UITimer.Task() {
            @Override
            public void run() {
                cancelTask();
                finish();
                pomodoroMaster.start(ActivityType.POMODORO);
            }
        }, 3000, "PomodoroTransitionActivity.DelayTimer");
    }
}
 
Example 17
Source File: AndroidVsIosHeaderView.java    From youqu_master with Apache License 2.0 4 votes vote down vote up
public AndroidVsIosHeaderView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    inflate(context, R.layout.layout_irecyclerview_bat_vs_supper_refresh_header_view, this);
    ivBatMan = (ImageView) findViewById(R.id.ivBatMan);
    ivSuperMan = (ImageView) findViewById(R.id.ivSuperMan);
    ivVs = (ImageView) findViewById(R.id.imageView);

    PropertyValuesHolder translationX1 = PropertyValuesHolder.ofFloat("translationX",0.0f,100.0f,0.0f);
    PropertyValuesHolder rotate = PropertyValuesHolder.ofFloat("rotationY",0.0f,380.0f,0.0f);
    PropertyValuesHolder translationX2 = PropertyValuesHolder.ofFloat("translationX",0.0f,-100.0f,0.0f);

    ObjectAnimator objectAnimator1 = ObjectAnimator.ofPropertyValuesHolder(ivBatMan,  translationX1);
    objectAnimator1.setRepeatCount(ValueAnimator.INFINITE);
    objectAnimator1.setRepeatMode(ValueAnimator.INFINITE);

    ObjectAnimator objectAnimator2 = ObjectAnimator.ofPropertyValuesHolder(ivSuperMan,translationX2);
    objectAnimator2.setRepeatCount(ValueAnimator.INFINITE);
    objectAnimator2.setRepeatMode(ValueAnimator.INFINITE);

    ObjectAnimator objectAnimator3 = ObjectAnimator.ofPropertyValuesHolder(ivVs,  rotate);
    objectAnimator3.setRepeatCount(ValueAnimator.INFINITE);
    objectAnimator3.setRepeatMode(ValueAnimator.INFINITE);

     Animation animation =new RotateAnimation(0f,360f, Animation.RELATIVE_TO_SELF,
            0.5f,Animation.RELATIVE_TO_SELF,0.5f);
    Animation animation1 =new RotateAnimation(0f,-360f, Animation.RELATIVE_TO_SELF,
            0.5f,Animation.RELATIVE_TO_SELF,0.5f);
    animation.setFillAfter(true);
    animation.setDuration(2000);
    animation.setRepeatCount(ValueAnimator.INFINITE);
    animation.setRepeatMode(ValueAnimator.INFINITE);
    animation1.setFillAfter(true);
    animation1.setDuration(2000);
    animation1.setRepeatCount(ValueAnimator.INFINITE);
    animation1.setRepeatMode(ValueAnimator.INFINITE);
    ivBatMan.setAnimation(animation);
    ivSuperMan.setAnimation(animation1);

    btnSexAnimatorSet = new AnimatorSet();
    btnSexAnimatorSet.playTogether(objectAnimator1, objectAnimator2,objectAnimator3);
    btnSexAnimatorSet.setDuration(2000);
    btnSexAnimatorSet.start();

}
 
Example 18
Source File: AnimationSVGImageViewSampleActivity.java    From SVG-Android with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_animation_svg_imageview_sample);
    setTitle(getIntent().getStringExtra("title"));

    final SVGImageView imageView1 = (SVGImageView) findViewById(R.id.animation_svgimageview_image1);
    ObjectAnimator animatorRotation = ObjectAnimator.ofFloat(imageView1, "svgRotation", 0, 360);
    animatorRotation.setDuration(2000);
    animatorRotation.setRepeatCount(ValueAnimator.INFINITE);
    animatorRotation.setInterpolator(new LinearInterpolator());
    animatorRotation.start();

    SVGImageView imageView2 = (SVGImageView) findViewById(R.id.animation_svgimageview_image2);
    ObjectAnimator animatorAlpha = ObjectAnimator.ofFloat(imageView2, "svgAlpha", 0, 1);
    animatorAlpha.setDuration(4000);
    animatorAlpha.setRepeatCount(ValueAnimator.INFINITE);
    animatorAlpha.setRepeatMode(ValueAnimator.REVERSE);
    animatorAlpha.setInterpolator(new LinearInterpolator());
    animatorAlpha.start();

    final SVGImageView imageView3 = (SVGImageView) findViewById(R.id.animation_svgimageview_image3);
    ObjectAnimator animatorWidth = ObjectAnimator.ofInt(imageView3, "svgWidth", 50, 150);
    animatorWidth.setDuration(2000);
    animatorWidth.setInterpolator(new LinearInterpolator());
    animatorWidth.setRepeatCount(ValueAnimator.INFINITE);
    animatorWidth.setRepeatMode(ValueAnimator.REVERSE);
    animatorWidth.start();
    animatorWidth.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator valueAnimator) {
            // There is a bug in ImageView(ImageButton), in this case, we must call requestLayout() here.
            imageView3.requestLayout();
        }
    });

    SVGImageView imageView4 = (SVGImageView) findViewById(R.id.animation_svgimageview_image4);
    ObjectAnimator animatorColor = ObjectAnimator.ofInt(imageView4, "svgColor", Color.BLACK, Color.BLUE);
    animatorColor.setDuration(2000);
    animatorColor.setRepeatCount(ValueAnimator.INFINITE);
    animatorColor.setRepeatMode(ValueAnimator.REVERSE);
    animatorColor.setInterpolator(new LinearInterpolator());
    animatorColor.start();

}
 
Example 19
Source File: RippleBackground.java    From RippleBackground with Apache License 2.0 4 votes vote down vote up
private void init(final Context context, final AttributeSet attrs) {
    if (isInEditMode())
        return;

    TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.RippleBackground);
    int rippleColor = typedArray.getColor(R.styleable.RippleBackground_rb_color, ContextCompat.getColor(context, R.color.ripple_color));
    rippleStrokeWidth = typedArray.getDimension(R.styleable.RippleBackground_rb_strokeWidth, getResources().getDimension(R.dimen.rippleStrokeWidth));
    rippleRadius = typedArray.getDimension(R.styleable.RippleBackground_rb_radius, getResources().getDimension(R.dimen.rippleRadius));
    int rippleDuration = typedArray.getInt(R.styleable.RippleBackground_rb_duration, DEFAULT_DURATION);
    int rippleDelay = typedArray.getInt(R.styleable.RippleBackground_rb_delay, DEFAULT_DURATION);
    int rippleAmount = typedArray.getInt(R.styleable.RippleBackground_rb_rippleAmount, DEFAULT_RIPPLE_COUNT);
    float rippleScale = typedArray.getFloat(R.styleable.RippleBackground_rb_scale, DEFAULT_SCALE);
    int rippleType = typedArray.getInt(R.styleable.RippleBackground_rb_type, DEFAULT_FILL_TYPE);
    typedArray.recycle();

    paint = new Paint();
    paint.setAntiAlias(true);
    if (rippleType == DEFAULT_FILL_TYPE) {
        rippleStrokeWidth = 0;
        paint.setStyle(Paint.Style.FILL);
    } else
        paint.setStyle(Paint.Style.STROKE);
    paint.setColor(rippleColor);

    LayoutParams params = new LayoutParams((int) (2 * (rippleRadius + rippleStrokeWidth)), (int) (2 * (rippleRadius + rippleStrokeWidth)));
    params.addRule(CENTER_IN_PARENT, TRUE);

    animatorSet = new AnimatorSet();
    animatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
    ArrayList<Animator> animators = new ArrayList<>();

    for (int i = 0; i < rippleAmount; i++) {
        RippleView rippleView = new RippleView(context);
        addView(rippleView, params);
        list.add(rippleView);

        ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(rippleView, View.SCALE_X, 1.0f, rippleScale);
        scaleXAnimator.setRepeatCount(ObjectAnimator.INFINITE);
        scaleXAnimator.setRepeatMode(ObjectAnimator.RESTART);
        scaleXAnimator.setStartDelay(i * rippleDelay);
        scaleXAnimator.setDuration(rippleDuration);
        scaleXAnimator.setInterpolator(new AccelerateInterpolator());
        animators.add(scaleXAnimator);

        ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(rippleView, View.SCALE_Y, 1.0f, rippleScale);
        scaleYAnimator.setRepeatCount(ObjectAnimator.INFINITE);
        scaleYAnimator.setRepeatMode(ObjectAnimator.RESTART);
        scaleYAnimator.setStartDelay(i * rippleDelay);
        scaleYAnimator.setDuration(rippleDuration);
        scaleXAnimator.setInterpolator(new AccelerateInterpolator());
        animators.add(scaleYAnimator);

        ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(rippleView, View.ALPHA, 1.0f, 0f);
        alphaAnimator.setRepeatCount(ObjectAnimator.INFINITE);
        alphaAnimator.setRepeatMode(ObjectAnimator.RESTART);
        alphaAnimator.setStartDelay(i * rippleDelay);
        alphaAnimator.setDuration(rippleDuration);
        scaleXAnimator.setInterpolator(new AccelerateInterpolator());
        animators.add(alphaAnimator);
    }

    animatorSet.playTogether(animators);
}
 
Example 20
Source File: NearbyAddContactActivity.java    From zom-android-matrix with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_nearby);

    setTitle("");

    ImageView iv = (ImageView) findViewById(R.id.nearbyIcon);
    mList = findViewById(R.id.nearbyList);
    mList.setLayoutManager(new LinearLayoutManager(this));
    mList.setItemAnimator(new DefaultItemAnimator());

    NearbyListRecyclerViewAdapter adapter = new NearbyListRecyclerViewAdapter(this,new ArrayList<Contact>(contactList.values()));
    mList.setAdapter(adapter);

    ObjectAnimator scaleDown = ObjectAnimator.ofPropertyValuesHolder(
            iv,
            PropertyValuesHolder.ofFloat("scaleX", 1.2f),
            PropertyValuesHolder.ofFloat("scaleY", 1.2f));
    scaleDown.setDuration(310);
    scaleDown.setInterpolator(new FastOutSlowInInterpolator());

    scaleDown.setRepeatCount(ObjectAnimator.INFINITE);
    scaleDown.setRepeatMode(ObjectAnimator.REVERSE);

    scaleDown.start();

    mApp = (ImApp)getApplication();

    if (getSupportActionBar() != null)
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    // Showing status
    if(checkPlayServices())
    {
        String nearbyMessage = getIntent().getStringExtra(EXTRA_TEXT);
        initNearby(nearbyMessage);
    }
    else
    {
        Toast.makeText(this, R.string.nearby_not_supported,Toast.LENGTH_LONG).show();
        finish();
    }
}