List of usage examples for android.support.v4.graphics ColorUtils blendARGB
@ColorInt public static int blendARGB(@ColorInt int color1, @ColorInt int color2, @FloatRange(from = 0.0, to = 1.0) float ratio)
From source file:com.tr4android.support.extension.drawable.ColorTransitionDrawable.java
public void setColorRatio(float ratio) { mColorRatio = Math.max(0f, Math.min(ratio, 1f)); mColor = ColorUtils.blendARGB(mColorStart, mColorEnd, mColorRatio); invalidateSelf();//from w w w .j a v a 2s. com }
From source file:ru.ifmo.android_2016.irc.drawee.DraweeTextView.java
@SuppressWarnings("deprecation") public void setMessage(MessageText message) { setBackgroundColor(Color.TRANSPARENT); TypedValue typedValue = new TypedValue(); Resources.Theme theme = getContext().getTheme(); theme.resolveAttribute(R.attr.background, typedValue, true); int color = typedValue.data; if (message.isMentioned()) { setBackgroundColor(ColorUtils.blendARGB(color, Color.RED, 0.6f)); }// w ww . j av a2 s . c o m if (message.isWhisper()) { setBackgroundColor(ColorUtils.blendARGB(color, Color.GREEN, 0.6f)); } if (message.isTwitchNotify()) { setBackgroundColor(ColorUtils.blendARGB(color, getResources().getColor(R.color.colorTwitch), 0.6f)); setText(message.getText()); } else { setText(message.getSpanned()); } this.msg = message; }
From source file:com.github.pockethub.android.ui.WelcomeActivity.java
/** * Update background color depending on scroll position * @param position/*w w w. j a v a 2 s. c om*/ * @param positionOffset * @param positionOffsetPixels */ @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { super.onPageScrolled(position, positionOffset, positionOffsetPixels); @ColorInt int color; @ColorInt int accentsColor; if (positionOffsetPixels >= 0) { color = ColorUtils.blendARGB(getBackgroundColor(position + 1), getBackgroundColor(position), (1 - positionOffset)); accentsColor = ColorUtils.blendARGB(getAccentsColor(position + 1), getAccentsColor(position), (1 - positionOffset)); } else { color = ColorUtils.blendARGB(getBackgroundColor(position), getBackgroundColor(position + 1), (1 - positionOffset)); accentsColor = ColorUtils.blendARGB(getAccentsColor(position), getAccentsColor(position + 1), (1 - positionOffset)); } setBackgroundColor(color); skipBtn.setTextColor(accentsColor); nextBtn.setColorFilter(accentsColor); divider.setBackgroundColor(accentsColor); dotPageIndicator.setSelectedDotColor(accentsColor); }
From source file:com.zhi.android.modules.welcome.WelcomeFragment.java
@Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { if (positionOffset == 0f) { if (position == mAdapter.getCount() - 1) { getActivity().finish();/* ww w. j a v a2 s . c om*/ return; } } // retain background color final int color1 = mAdapter.getPageBackgroundColor(position); final int color2 = mAdapter.getPageBackgroundColor(position + 1); mBackgroundView.setBackgroundColor(ColorUtils.blendARGB(color1, color2, positionOffset)); if (position == mPager.getAdapter().getCount() - 2) { mPager.setAlpha(1f - positionOffset); } final View curWarmView = mPager.findViewWithTag(WelcomePageFragment.warmViewTag(position)); if (curWarmView != null) { WelcomePageFragment.onPageWarm(curWarmView, positionOffset); } final View nextWarmView = mPager.findViewWithTag(WelcomePageFragment.warmViewTag(position + 1)); if (nextWarmView != null) { WelcomePageFragment.onPageWarm(nextWarmView, positionOffset - 1.0f); } }
From source file:com.artemchep.horario.ui.activities.SubjectActivity.java
@SuppressLint("NewApi") private void bind(@NonNull SubjectInfo subject) { mCollapsingToolbar.setTitle(subject.name); int color = subject.color; color |= 0xFF000000; // ignore alpha bits final boolean isColorDark = ColorUtil.isColorDark(color); if (Device.hasLollipopApi()) { int statusBarColor = ColorUtils.blendARGB(color, Color.BLACK, 0.4f); getWindow().setStatusBarColor(statusBarColor); }/* www .jav a2 s . c o m*/ Drawable overflowIcon; if (isColorDark) { mToolbar.setNavigationIcon(R.drawable.ic_keyboard_backspace_white_24dp); mCollapsingToolbar.setExpandedTitleColor(Color.WHITE); mCollapsingToolbar.setCollapsedTitleTextColor(Color.WHITE); overflowIcon = ContextCompat.getDrawable(this, R.drawable.ic_dots_vertical_white_24dp); if (mSmartTabLayout != null) { mSmartTabLayout.setDefaultTabTextColor(Color.WHITE); mSmartTabLayout.setSelectedIndicatorColors(Color.WHITE); } } else { mToolbar.setNavigationIcon(R.drawable.ic_keyboard_backspace_black_24dp); mCollapsingToolbar.setExpandedTitleColor(Color.BLACK); mCollapsingToolbar.setCollapsedTitleTextColor(Color.BLACK); overflowIcon = ContextCompat.getDrawable(this, R.drawable.ic_dots_vertical_black_24dp); if (mSmartTabLayout != null) { mSmartTabLayout.setDefaultTabTextColor(Color.BLACK); mSmartTabLayout.setSelectedIndicatorColors(Color.BLACK); } } mCollapsingToolbar.setContentScrimColor(color); if (mBackdropToolbar != null) { mBackdropToolbar.setBackgroundColor(color); } else mAppBar.setBackgroundColor(color); mToolbar.setOverflowIcon(overflowIcon); mSmartTabLayout.setViewPager(mViewPager); }
From source file:com.artemchep.horario.ui.fragments.details.TeacherDetailsFragment.java
@Override protected void updateAll() { super.updateAll(); Teacher model = getModel();//from w w w . j a v a2 s . com // Make color a little bit lighter on dark backgrounds // and darker on light ones. int textAccentColor = model != null ? model.color : Palette.GREY; if (ColorUtil.isColorDark(textAccentColor) == mIsDarkTheme) { int filter = mIsDarkTheme ? Color.WHITE : Color.BLACK; textAccentColor = ColorUtils.blendARGB(textAccentColor, filter, 0.5f); } mEmailButton.setTextColor(textAccentColor); mPhoneButton.setTextColor(textAccentColor); }
From source file:com.lovejjfg.demo.TouchCircleView.java
private void setupAnimations() { mObjectAnimatorAngle = ObjectAnimator.ofFloat(this, mAngleProperty, mCurrentGlobalAngle, 360f); mObjectAnimatorAngle.setInterpolator(ANGLE_INTERPOLATOR); mObjectAnimatorAngle.setDuration(ANGLE_ANIMATOR_DURATION); mObjectAnimatorAngle.setRepeatMode(ValueAnimator.RESTART); mObjectAnimatorAngle.setRepeatCount(ValueAnimator.INFINITE); mObjectAnimatorAngle.addListener(new AnimatorListenerAdapter() { @Override/*from w w w . j av a2s .c o m*/ public void onAnimationRepeat(Animator animation) { mObjectAnimatorAngle.setFloatValues(360f); } }); mObjectAnimatorSweep = ObjectAnimator.ofFloat(this, mSweepProperty, mCurrentSweepAngle, 360f - MIN_SWEEP_ANGLE * 2); mObjectAnimatorSweep.setInterpolator(SWEEP_INTERPOLATOR); mObjectAnimatorSweep.setDuration(SWEEP_ANIMATOR_DURATION); mObjectAnimatorSweep.setRepeatMode(ValueAnimator.RESTART); mObjectAnimatorSweep.setRepeatCount(ValueAnimator.INFINITE); mObjectAnimatorSweep.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationRepeat(Animator animation) { mObjectAnimatorSweep.setFloatValues(360f - MIN_SWEEP_ANGLE * 2); toggleAppearingMode(); } }); fractionAnimator = ValueAnimator.ofInt(0, ALPHA_FULL); fractionAnimator.setInterpolator(ANGLE_INTERPOLATOR); fractionAnimator.setDuration(FRACTION_DURATION); fractionAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { fraction = animation.getAnimatedFraction(); mHookPaint.setAlpha((Integer) animation.getAnimatedValue()); invalidate(); } }); fractionAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mRunning = false; postDelayed(idleAction, 0); } }); translateAnimator = ValueAnimator.ofFloat(0, 100); translateAnimator.setInterpolator(ANGLE_INTERPOLATOR); translateAnimator.setDuration(200); translateAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { private float tranlateFraction; @Override public void onAnimationUpdate(ValueAnimator animation) { Float animatedValue = (Float) animation.getAnimatedValue(); updateState(STATE_TRANSLATE_PATH, false); tranlateFraction = animation.getAnimatedFraction(); if (!isBack) { mixPaint.setColor(ColorUtils.blendARGB(Color.RED, Color.GREEN, tranlateFraction)); mCurrentRadius = (int) (outCirRadius + tranlateFraction * (secondRadius - outCirRadius)); } else { mixPaint.setColor(ColorUtils.blendARGB(Color.GREEN, Color.RED, tranlateFraction)); mCurrentRadius = (int) (secondRadius - tranlateFraction * (secondRadius - outCirRadius)); } mCurrentPaint = mixPaint; resetPoints(secondRectf.centerX(), animatedValue); invalidate(); } }); translateAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { updateState(isBack ? STATE_DRAW_ARROW : abortReset ? STATE_DRAW_BACK : STATE_DRAW_CIRCLE, abortReset); updateRectF(); invalidate(); } }); }