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

The following examples show how to use android.animation.ObjectAnimator#ofArgb() . 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: PropertyAnimationActivity.java    From Android-Animation-Set 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 2
Source File: VoIPActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private void showRetry(){
      if(retryAnim!=null)
          retryAnim.cancel();
      endBtn.setEnabled(false);
      retrying=true;
      cancelBtn.setVisibility(View.VISIBLE);
      cancelBtn.setAlpha(0);
      AnimatorSet set=new AnimatorSet();
      ObjectAnimator colorAnim;
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
          colorAnim = ObjectAnimator.ofArgb(endBtnBg, "color", 0xFFe61e44, 0xFF45bc4d);
      } else {
          colorAnim = ObjectAnimator.ofInt(endBtnBg, "color", 0xFFe61e44, 0xFF45bc4d);
          colorAnim.setEvaluator(new ArgbEvaluator());
      }
      set.playTogether(
              ObjectAnimator.ofFloat(cancelBtn, "alpha", 0, 1),
              ObjectAnimator.ofFloat(endBtn, "translationX", 0, content.getWidth()/2-AndroidUtilities.dp(52)-endBtn.getWidth()/2),
              colorAnim,
              ObjectAnimator.ofFloat(endBtnIcon, "rotation", 0, -135)//,
              //ObjectAnimator.ofFloat(spkToggle, "alpha", 0),
              //ObjectAnimator.ofFloat(micToggle, "alpha", 0),
              //ObjectAnimator.ofFloat(chatBtn, "alpha", 0)
      );
      set.setStartDelay(200);
      set.setDuration(300);
      set.setInterpolator(CubicBezierInterpolator.DEFAULT);
      set.addListener(new AnimatorListenerAdapter(){
          @Override
          public void onAnimationEnd(Animator animation){
              //bottomButtons.setVisibility(View.GONE);
              retryAnim=null;
              endBtn.setEnabled(true);
          }
      });
retryAnim=set;
      set.start();
  }
 
Example 3
Source File: ViewUtil.java    From Phonograph with GNU General Public License v3.0 5 votes vote down vote up
private static Animator createColorAnimator(Object target, String propertyName, @ColorInt int startColor, @ColorInt int endColor) {
    ObjectAnimator animator;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        animator = ObjectAnimator.ofArgb(target, propertyName, startColor, endColor);
    } else {
        animator = ObjectAnimator.ofInt(target, propertyName, startColor, endColor);
        animator.setEvaluator(new ArgbEvaluator());
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        animator.setInterpolator(new PathInterpolator(0.4f, 0f, 1f, 1f));
    }
    animator.setDuration(PHONOGRAPH_ANIM_TIME);
    return animator;
}
 
Example 4
Source File: BubbleActionOverlay.java    From BubbleActions with Apache License 2.0 5 votes vote down vote up
BubbleActionOverlay(Context context) {
    super(context);
    contentClipRect = new RectF();
    dragShadowBuilder = new DragShadowBuilder();
    dragData = DragUtils.getClipData();

    LayoutInflater inflater = LayoutInflater.from(context);
    bubbleActionIndicator = (ImageView) inflater.inflate(R.layout.bubble_actions_indicator, this, false);
    bubbleActionIndicator.setAlpha(0f);
    addView(bubbleActionIndicator, -1);

    interpolator = new OvershootInterpolator(OVERSHOOT_TENSION);

    int transparentBackgroundColor = ContextCompat.getColor(context, R.color.bubble_actions_background_transparent);
    int darkenedBackgroundColor = ContextCompat.getColor(context, R.color.bubble_actions_background_darkened);
    setBackgroundColor(transparentBackgroundColor);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        backgroundAnimator = ObjectAnimator.ofArgb(this, "backgroundColor", transparentBackgroundColor, darkenedBackgroundColor);
    } else {
        backgroundAnimator = ObjectAnimator.ofObject(this, "backgroundColor", new BackgroundAlphaTypeEvaluator(), transparentBackgroundColor, darkenedBackgroundColor);
    }

    animationDuration = BASE_ANIMATION_DURATION;

    bubbleDimension = (int) getResources().getDimension(R.dimen.bubble_actions_indicator_dimension);
    startActionDistanceFromCenter = getResources().getDimension(R.dimen.bubble_actions_start_distance);
    stopActionDistanceFromCenter = getResources().getDimension(R.dimen.bubble_actions_stop_distance);

    for (int i = 0; i < MAX_ACTIONS; i++) {
        BubbleView itemView = new BubbleView(getContext());
        itemView.setVisibility(INVISIBLE);
        itemView.setAlpha(0f);
        addView(itemView, -1, new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    }
}
 
Example 5
Source File: VoIPActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private void hideRetry() {
    if (retryAnim != null)
        retryAnim.cancel();
    retrying = false;
    //bottomButtons.setVisibility(View.VISIBLE);
    ObjectAnimator colorAnim;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        colorAnim = ObjectAnimator.ofArgb(endBtnBg, "color", 0xFF45bc4d, 0xFFe61e44);
    } else {
        colorAnim = ObjectAnimator.ofInt(endBtnBg, "color", 0xFF45bc4d, 0xFFe61e44);
        colorAnim.setEvaluator(new ArgbEvaluator());
    }
    AnimatorSet set = new AnimatorSet();
    set.playTogether(
            colorAnim,
            ObjectAnimator.ofFloat(endBtnIcon, "rotation", -135, 0),
            ObjectAnimator.ofFloat(endBtn, View.TRANSLATION_X, 0),
            ObjectAnimator.ofFloat(cancelBtn, View.ALPHA, 0)//,
            //ObjectAnimator.ofFloat(bottomButtons, View.ALPHA, 1)
    );
    set.setStartDelay(200);
    set.setDuration(300);
    set.setInterpolator(CubicBezierInterpolator.DEFAULT);
    set.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            cancelBtn.setVisibility(View.GONE);
            endBtn.setEnabled(true);
            retryAnim = null;
        }
    });
    retryAnim = set;
    set.start();
}
 
Example 6
Source File: ViewUtil.java    From VinylMusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
private static Animator createColorAnimator(Object target, String propertyName, @ColorInt int startColor, @ColorInt int endColor) {
    ObjectAnimator animator;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        animator = ObjectAnimator.ofArgb(target, propertyName, startColor, endColor);
    } else {
        animator = ObjectAnimator.ofInt(target, propertyName, startColor, endColor);
        animator.setEvaluator(new ArgbEvaluator());
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        animator.setInterpolator(new PathInterpolator(0.4f, 0f, 1f, 1f));
    }
    animator.setDuration(VINYL_MUSIC_PLAYER_ANIM_TIME);
    return animator;
}
 
Example 7
Source File: ViewUtil.java    From RetroMusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
private static Animator createColorAnimator(Object target, String propertyName, @ColorInt int startColor, @ColorInt int endColor) {
    ObjectAnimator animator;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        animator = ObjectAnimator.ofArgb(target, propertyName, startColor, endColor);
    } else {
        animator = ObjectAnimator.ofInt(target, propertyName, startColor, endColor);
        animator.setEvaluator(new ArgbEvaluator());
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        animator.setInterpolator(new PathInterpolator(0.4f, 0f, 1f, 1f));
    }
    animator.setDuration(PHONOGRAPH_ANIM_TIME);
    return animator;
}
 
Example 8
Source File: ViewUtils.java    From MaterialStepperView with MIT License 5 votes vote down vote up
static ObjectAnimator createArgbAnimator(View view, String propertyName, int startColor, int endColor) {
	if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
		return ObjectAnimator.ofObject(view, propertyName, new TypeEvaluator() {
			@Override
			public Object evaluate(float fraction, Object startValue, Object endValue) {
				int startInt = (Integer) startValue;
				int startA = (startInt >> 24) & 0xff;
				int startR = (startInt >> 16) & 0xff;
				int startG = (startInt >> 8) & 0xff;
				int startB = startInt & 0xff;

				int endInt = (Integer) endValue;
				int endA = (endInt >> 24) & 0xff;
				int endR = (endInt >> 16) & 0xff;
				int endG = (endInt >> 8) & 0xff;
				int endB = endInt & 0xff;

				return (startA + (int)(fraction * (endA - startA))) << 24 |
						(startR + (int)(fraction * (endR - startR))) << 16 |
						(startG + (int)(fraction * (endG - startG))) << 8 |
						(startB + (int)(fraction * (endB - startB)));
			}
		}, startColor, endColor);
	} else {
		return ObjectAnimator.ofArgb(view, propertyName, startColor, endColor);
	}
}
 
Example 9
Source File: VoIPActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private void showRetry() {
    if (retryAnim != null)
        retryAnim.cancel();
    endBtn.setEnabled(false);
    retrying = true;
    cancelBtn.setVisibility(View.VISIBLE);
    cancelBtn.setAlpha(0);
    AnimatorSet set = new AnimatorSet();
    ObjectAnimator colorAnim;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        colorAnim = ObjectAnimator.ofArgb(endBtnBg, "color", 0xFFe61e44, 0xFF45bc4d);
    } else {
        colorAnim = ObjectAnimator.ofInt(endBtnBg, "color", 0xFFe61e44, 0xFF45bc4d);
        colorAnim.setEvaluator(new ArgbEvaluator());
    }
    set.playTogether(
            ObjectAnimator.ofFloat(cancelBtn, View.ALPHA, 0, 1),
            ObjectAnimator.ofFloat(endBtn, View.TRANSLATION_X, 0, content.getWidth() / 2 - AndroidUtilities.dp(52) - endBtn.getWidth() / 2),
            colorAnim,
            ObjectAnimator.ofFloat(endBtnIcon, View.ROTATION, 0, -135)//,
            //ObjectAnimator.ofFloat(spkToggle, View.ALPHA, 0),
            //ObjectAnimator.ofFloat(micToggle, View.ALPHA, 0),
            //ObjectAnimator.ofFloat(chatBtn, View.ALPHA, 0)
    );
    set.setStartDelay(200);
    set.setDuration(300);
    set.setInterpolator(CubicBezierInterpolator.DEFAULT);
    set.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            //bottomButtons.setVisibility(View.GONE);
            retryAnim = null;
            endBtn.setEnabled(true);
        }
    });
    retryAnim = set;
    set.start();
}
 
Example 10
Source File: VoIPActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private void showRetry() {
    if (retryAnim != null)
        retryAnim.cancel();
    endBtn.setEnabled(false);
    retrying = true;
    cancelBtn.setVisibility(View.VISIBLE);
    cancelBtn.setAlpha(0);
    AnimatorSet set = new AnimatorSet();
    ObjectAnimator colorAnim;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        colorAnim = ObjectAnimator.ofArgb(endBtnBg, "color", 0xFFe61e44, 0xFF45bc4d);
    } else {
        colorAnim = ObjectAnimator.ofInt(endBtnBg, "color", 0xFFe61e44, 0xFF45bc4d);
        colorAnim.setEvaluator(new ArgbEvaluator());
    }
    set.playTogether(
            ObjectAnimator.ofFloat(cancelBtn, View.ALPHA, 0, 1),
            ObjectAnimator.ofFloat(endBtn, View.TRANSLATION_X, 0, content.getWidth() / 2 - AndroidUtilities.dp(52) - endBtn.getWidth() / 2),
            colorAnim,
            ObjectAnimator.ofFloat(endBtnIcon, View.ROTATION, 0, -135)//,
            //ObjectAnimator.ofFloat(spkToggle, View.ALPHA, 0),
            //ObjectAnimator.ofFloat(micToggle, View.ALPHA, 0),
            //ObjectAnimator.ofFloat(chatBtn, View.ALPHA, 0)
    );
    set.setStartDelay(200);
    set.setDuration(300);
    set.setInterpolator(CubicBezierInterpolator.DEFAULT);
    set.addListener(new AnimatorListenerAdapter() {
        @Override
        public void onAnimationEnd(Animator animation) {
            //bottomButtons.setVisibility(View.GONE);
            retryAnim = null;
            endBtn.setEnabled(true);
        }
    });
    retryAnim = set;
    set.start();
}
 
Example 11
Source File: VoIPActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private void hideRetry(){
    if(retryAnim!=null)
        retryAnim.cancel();
    retrying=false;
    //bottomButtons.setVisibility(View.VISIBLE);
    ObjectAnimator colorAnim;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        colorAnim = ObjectAnimator.ofArgb(endBtnBg, "color", 0xFF45bc4d, 0xFFe61e44);
    } else {
        colorAnim = ObjectAnimator.ofInt(endBtnBg, "color", 0xFF45bc4d, 0xFFe61e44);
        colorAnim.setEvaluator(new ArgbEvaluator());
    }
    AnimatorSet set=new AnimatorSet();
    set.playTogether(
            colorAnim,
            ObjectAnimator.ofFloat(endBtnIcon, "rotation", -135, 0),
            ObjectAnimator.ofFloat(endBtn, "translationX", 0),
            ObjectAnimator.ofFloat(cancelBtn, "alpha", 0)//,
            //ObjectAnimator.ofFloat(bottomButtons, "alpha", 1)
    );
    set.setStartDelay(200);
    set.setDuration(300);
    set.setInterpolator(CubicBezierInterpolator.DEFAULT);
    set.addListener(new AnimatorListenerAdapter(){
        @Override
        public void onAnimationEnd(Animator animation){
            cancelBtn.setVisibility(View.GONE);
            endBtn.setEnabled(true);
retryAnim=null;
        }
    });
    retryAnim=set;
    set.start();
}
 
Example 12
Source File: VoIPActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private void showRetry(){
      if(retryAnim!=null)
          retryAnim.cancel();
      endBtn.setEnabled(false);
      retrying=true;
      cancelBtn.setVisibility(View.VISIBLE);
      cancelBtn.setAlpha(0);
      AnimatorSet set=new AnimatorSet();
      ObjectAnimator colorAnim;
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
          colorAnim = ObjectAnimator.ofArgb(endBtnBg, "color", 0xFFe61e44, 0xFF45bc4d);
      } else {
          colorAnim = ObjectAnimator.ofInt(endBtnBg, "color", 0xFFe61e44, 0xFF45bc4d);
          colorAnim.setEvaluator(new ArgbEvaluator());
      }
      set.playTogether(
              ObjectAnimator.ofFloat(cancelBtn, "alpha", 0, 1),
              ObjectAnimator.ofFloat(endBtn, "translationX", 0, content.getWidth()/2-AndroidUtilities.dp(52)-endBtn.getWidth()/2),
              colorAnim,
              ObjectAnimator.ofFloat(endBtnIcon, "rotation", 0, -135)//,
              //ObjectAnimator.ofFloat(spkToggle, "alpha", 0),
              //ObjectAnimator.ofFloat(micToggle, "alpha", 0),
              //ObjectAnimator.ofFloat(chatBtn, "alpha", 0)
      );
      set.setStartDelay(200);
      set.setDuration(300);
      set.setInterpolator(CubicBezierInterpolator.DEFAULT);
      set.addListener(new AnimatorListenerAdapter(){
          @Override
          public void onAnimationEnd(Animator animation){
              //bottomButtons.setVisibility(View.GONE);
              retryAnim=null;
              endBtn.setEnabled(true);
          }
      });
retryAnim=set;
      set.start();
  }
 
Example 13
Source File: ViewUtil.java    From Music-Player with GNU General Public License v3.0 5 votes vote down vote up
private static Animator createColorAnimator(Object target, String propertyName, @ColorInt int startColor, @ColorInt int endColor) {
    ObjectAnimator animator;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        animator = ObjectAnimator.ofArgb(target, propertyName, startColor, endColor);
    } else {
        animator = ObjectAnimator.ofInt(target, propertyName, startColor, endColor);
        animator.setEvaluator(new ArgbEvaluator());
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        animator.setInterpolator(new PathInterpolator(0.4f, 0f, 1f, 1f));
    }
    animator.setDuration(MUSIC_ANIM_TIME);
    return animator;
}
 
Example 14
Source File: VoIPActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private void hideRetry(){
    if(retryAnim!=null)
        retryAnim.cancel();
    retrying=false;
    //bottomButtons.setVisibility(View.VISIBLE);
    ObjectAnimator colorAnim;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        colorAnim = ObjectAnimator.ofArgb(endBtnBg, "color", 0xFF45bc4d, 0xFFe61e44);
    } else {
        colorAnim = ObjectAnimator.ofInt(endBtnBg, "color", 0xFF45bc4d, 0xFFe61e44);
        colorAnim.setEvaluator(new ArgbEvaluator());
    }
    AnimatorSet set=new AnimatorSet();
    set.playTogether(
            colorAnim,
            ObjectAnimator.ofFloat(endBtnIcon, "rotation", -135, 0),
            ObjectAnimator.ofFloat(endBtn, "translationX", 0),
            ObjectAnimator.ofFloat(cancelBtn, "alpha", 0)//,
            //ObjectAnimator.ofFloat(bottomButtons, "alpha", 1)
    );
    set.setStartDelay(200);
    set.setDuration(300);
    set.setInterpolator(CubicBezierInterpolator.DEFAULT);
    set.addListener(new AnimatorListenerAdapter(){
        @Override
        public void onAnimationEnd(Animator animation){
            cancelBtn.setVisibility(View.GONE);
            endBtn.setEnabled(true);
retryAnim=null;
        }
    });
    retryAnim=set;
    set.start();
}
 
Example 15
Source File: Recolor.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues,
        TransitionValues endValues) {
    if (startValues == null || endValues == null) {
        return null;
    }
    final View view = endValues.view;
    Drawable startBackground = (Drawable) startValues.values.get(PROPNAME_BACKGROUND);
    Drawable endBackground = (Drawable) endValues.values.get(PROPNAME_BACKGROUND);
    boolean changed = false;
    if (startBackground instanceof ColorDrawable && endBackground instanceof ColorDrawable) {
        ColorDrawable startColor = (ColorDrawable) startBackground;
        ColorDrawable endColor = (ColorDrawable) endBackground;
        if (startColor.getColor() != endColor.getColor()) {
            endColor.setColor(startColor.getColor());
            changed = true;
            return ObjectAnimator.ofArgb(endBackground, "color", startColor.getColor(),
                    endColor.getColor());
        }
    }
    if (view instanceof TextView) {
        TextView textView = (TextView) view;
        int start = (Integer) startValues.values.get(PROPNAME_TEXT_COLOR);
        int end = (Integer) endValues.values.get(PROPNAME_TEXT_COLOR);
        if (start != end) {
            textView.setTextColor(end);
            changed = true;
            return ObjectAnimator.ofArgb(textView, "textColor", start, end);
        }
    }
    return null;
}
 
Example 16
Source File: VerticalStepperItemView.java    From ShareBox with Apache License 2.0 4 votes vote down vote up
/**
 * Set up the state of this stepper item
 *
 * @param state The state of this stepper item
 */
@SuppressLint("NewApi")
public synchronized void setState(int state) {
	// Change point background
	if (mPointColorAnimator != null) mPointColorAnimator.cancel();
	if (state != STATE_NORMAL && mState == STATE_NORMAL) {
		mPointColorAnimator = ObjectAnimator
				.ofArgb(mPointBackground, "backgroundColor", mNormalColor, mActivatedColor);
		mPointColorAnimator.setDuration(mAnimationDuration);
		mPointColorAnimator.start();
	} else if (state == STATE_NORMAL && mState != STATE_NORMAL) {
		mPointColorAnimator = ObjectAnimator
				.ofArgb(mPointBackground, "backgroundColor", mActivatedColor, mNormalColor);
		mPointColorAnimator.setDuration(mAnimationDuration);
		mPointColorAnimator.start();
	} else {
		mPointBackground.setBackgroundColor(state == STATE_NORMAL ? mNormalColor : mActivatedColor);
	}

	// Change point state
	if (state == STATE_DONE && mState != STATE_DONE) {
		mDoneIconView.animate().alpha(1f).setDuration(mAnimationDuration).start();
		mPointNumber.animate().alpha(0f).setDuration(mAnimationDuration).start();
	} else if (state != STATE_DONE && mState == STATE_DONE) {
		mDoneIconView.animate().alpha(0f).setDuration(mAnimationDuration).start();
		mPointNumber.animate().alpha(1f).setDuration(mAnimationDuration).start();
	} else {
		mDoneIconView.setAlpha(state == STATE_DONE ? 1f : 0f);
		mPointNumber.setAlpha(state == STATE_DONE ? 0f : 1f);
	}

	// Set title style
	int lastTitleTextColor = mTitleText.getCurrentTextColor();
	if (mTitleColorAnimator != null) mTitleColorAnimator.cancel();
	mTitleText.setTextAppearance(getContext(), state == STATE_DONE ?
			R.style.TextAppearance_Widget_Stepper_Done : (
					state == STATE_NORMAL ?
							R.style.TextAppearance_Widget_Stepper_Normal :
							R.style.TextAppearance_Widget_Stepper_Selected
			));

	// Update error state
	if (mErrorText != null) {
		mTitleColorAnimator = ObjectAnimator
				.ofArgb(mTitleText, "textColor",
						lastTitleTextColor, mErrorColor);
		mTitleColorAnimator.setDuration(mAnimationDuration);
		mTitleColorAnimator.start();
		if (mSummaryColorAnimator != null) mSummaryColorAnimator.cancel();
		mSummaryColorAnimator = ObjectAnimator
				.ofArgb(mSummaryText, "textColor",
						mSummaryText.getCurrentTextColor(), mErrorColor);
		mSummaryColorAnimator.setDuration(mAnimationDuration);
		mSummaryColorAnimator.start();

		if (mErrorIconView.getAlpha() < 1F) {
			if (mPointAnimator != null) mPointAnimator.cancel();
			mPointAnimator = mPointFrame.animate().alpha(0F).setDuration(mAnimationDuration);
			mPointAnimator.start();
			mErrorIconView.setScaleX(0.6F);
			mErrorIconView.setScaleY(0.6F);
			if (mErrorIconAnimator != null) mErrorIconAnimator.cancel();
			mErrorIconAnimator = mErrorIconView.animate().scaleX(1F).scaleY(1F)
					.alpha(1F).setDuration(mAnimationDuration).setInterpolator(new OvershootInterpolator());
			mErrorIconAnimator.start();
		}
	} else {
		if (mSummaryColorAnimator != null) mSummaryColorAnimator.cancel();
		mSummaryColorAnimator = ObjectAnimator
				.ofArgb(mSummaryText, "textColor",
						mSummaryText.getCurrentTextColor(), mLineColor);
		mSummaryColorAnimator.setDuration(mAnimationDuration);
		mSummaryColorAnimator.start();

		if (mPointFrame.getAlpha() < 1F) {
			mPointFrame.setScaleX(0.6F);
			mPointFrame.setScaleY(0.6F);
			if (mPointAnimator != null) mPointAnimator.cancel();
			mPointAnimator = mPointFrame.animate().scaleX(1F).scaleY(1F).alpha(1F).setDuration(mAnimationDuration);
			mPointAnimator.start();
			if (mErrorIconAnimator != null) mErrorIconAnimator.cancel();
			mErrorIconAnimator = mErrorIconView.animate().alpha(0F).setDuration(mAnimationDuration);
			mErrorIconAnimator.start();
		}
	}

	// Set the visibility of views
	mSummaryText.setVisibility(state != STATE_SELECTED && !TextUtils.isEmpty(mSummary) ? View.VISIBLE : View.GONE);
	mCustomView.setVisibility(state == STATE_SELECTED ? View.VISIBLE : View.GONE);

	mState = state;

	updateMarginBottom();
}
 
Example 17
Source File: MorphDialogToFab.java    From android-proguards with Apache License 2.0 4 votes vote down vote up
@Override
public Animator createAnimator(final ViewGroup sceneRoot,
                               TransitionValues startValues,
                               TransitionValues endValues) {
    Animator changeBounds = super.createAnimator(sceneRoot, startValues, endValues);
    if (startValues == null || endValues == null || changeBounds == null) {
        return null;
    }

    Integer startColor = (Integer) startValues.values.get(PROPERTY_COLOR);
    Integer startCornerRadius = (Integer) startValues.values.get(PROPERTY_CORNER_RADIUS);
    Integer endColor = (Integer) endValues.values.get(PROPERTY_COLOR);
    Integer endCornerRadius = (Integer) endValues.values.get(PROPERTY_CORNER_RADIUS);

    if (startColor == null || startCornerRadius == null || endColor == null ||
            endCornerRadius == null) {
        return null;
    }

    MorphDrawable background = new MorphDrawable(startColor, startCornerRadius);
    endValues.view.setBackground(background);

    Animator color = ObjectAnimator.ofArgb(background, background.COLOR, endColor);
    Animator corners = ObjectAnimator.ofFloat(background, background.CORNER_RADIUS,
            endCornerRadius);

    // hide child views (offset down & fade out)
    if (endValues.view instanceof ViewGroup) {
        ViewGroup vg = (ViewGroup) endValues.view;
        for (int i = 0; i < vg.getChildCount(); i++) {
            View v = vg.getChildAt(i);
            v.animate()
                    .alpha(0f)
                    .translationY(v.getHeight() / 3)
                    .setStartDelay(0L)
                    .setDuration(50L)
                    .setInterpolator(getFastOutLinearInInterpolator(vg.getContext()))
                    .start();
        }
    }

    AnimatorSet transition = new AnimatorSet();
    transition.playTogether(changeBounds, corners, color);
    transition.setDuration(300);
    transition.setInterpolator(getFastOutSlowInInterpolator(sceneRoot.getContext()));
    return transition;
}
 
Example 18
Source File: MorphTransform.java    From android-proguards with Apache License 2.0 4 votes vote down vote up
@Override
public Animator createAnimator(final ViewGroup sceneRoot,
                               final TransitionValues startValues,
                               final TransitionValues endValues) {
    final Animator changeBounds = super.createAnimator(sceneRoot, startValues, endValues);
    if (changeBounds == null) return null;

    TimeInterpolator interpolator = getInterpolator();
    if (interpolator == null) {
        interpolator = AnimUtils.getFastOutSlowInInterpolator(sceneRoot.getContext());
    }

    final MorphDrawable background = new MorphDrawable(startColor, startCornerRadius);
    endValues.view.setBackground(background);

    final Animator color = ObjectAnimator.ofArgb(background, MorphDrawable.COLOR, endColor);
    final Animator corners =
            ObjectAnimator.ofFloat(background, MorphDrawable.CORNER_RADIUS, endCornerRadius);

    // ease in the dialog's child views (fade in & staggered slide up)
    if (endValues.view instanceof ViewGroup) {
        final ViewGroup vg = (ViewGroup) endValues.view;
        final long duration = getDuration() / 2;
        float offset = vg.getHeight() / 3;
        for (int i = 0; i < vg.getChildCount(); i++) {
            View v = vg.getChildAt(i);
            v.setTranslationY(offset);
            v.setAlpha(0f);
            v.animate()
                    .alpha(1f)
                    .translationY(0f)
                    .setDuration(duration)
                    .setStartDelay(duration)
                    .setInterpolator(interpolator);
            offset *= 1.8f;
        }
    }

    final AnimatorSet transition = new AnimatorSet();
    transition.playTogether(changeBounds, corners, color);
    transition.setDuration(getDuration());
    transition.setInterpolator(interpolator);
    return transition;
}
 
Example 19
Source File: ObjectAnimatorCompatLollipop.java    From MaterialProgressBar with Apache License 2.0 4 votes vote down vote up
@NonNull
public static ObjectAnimator ofArgb(@Nullable Object target, @NonNull String propertyName,
                                    int... values) {
    return ObjectAnimator.ofArgb(target, propertyName, values);
}
 
Example 20
Source File: ObjectAnimatorCompatLollipop.java    From MaterialProgressBar with Apache License 2.0 4 votes vote down vote up
@NonNull
public static <T> ObjectAnimator ofArgb(@Nullable T target,
                                        @NonNull Property<T, Integer> property, int... values) {
    return ObjectAnimator.ofArgb(target, property, values);
}