use of android.animation.ArgbEvaluator in project iosched by google.
the class SessionDetailFragment method displayTrackColor.
/**
* Update the header box background color & status bar color depending upon which track this
* session belongs to.
* <p>
* Note this requires both the {@link SessionDetailQueryEnum#SESSIONS} &
* {@link SessionDetailQueryEnum#TAG_METADATA) queries to have returned.
*/
private void displayTrackColor(SessionDetailModel data) {
if (data.isSessionTrackColorAvailable()) {
int trackColor = data.getSessionTrackColor();
if (trackColor == Color.TRANSPARENT) {
trackColor = UIUtils.getThemeColor(getContext(), R.attr.colorPrimary, R.color.theme_primary);
}
final Drawable background = mHeaderBox.getBackground();
if (background instanceof ColorDrawable && ((ColorDrawable) background).getColor() == trackColor) {
return;
}
// Animate the color change to make the transition smoother
final ObjectAnimator color = ObjectAnimator.ofInt(mHeaderBox, UIUtils.BACKGROUND_COLOR, trackColor);
color.setEvaluator(new ArgbEvaluator());
if (mHasEnterTransition) {
color.setStartDelay(200L);
}
color.setDuration(300L);
color.start();
if (mCollapsingToolbar.getFitsSystemWindows() && mPhotoViewContainer.getVisibility() == View.VISIBLE) {
// immersive+photo
mCollapsingToolbar.setStatusBarScrimColor(trackColor);
} else {
UIUtils.adjustAndSetStatusBarColor(getActivity(), trackColor);
}
}
}
use of android.animation.ArgbEvaluator in project iosched by google.
the class SessionDetailFragment method returnTransitionStarted.
private void returnTransitionStarted() {
// Fade the header bar for a smoother transition.
final ObjectAnimator color = ObjectAnimator.ofInt(mHeaderBox, UIUtils.BACKGROUND_COLOR, ContextCompat.getColor(getContext(), R.color.background));
color.setEvaluator(new ArgbEvaluator());
color.setDuration(200L);
color.start();
// Also fade out the toolbar and FAB
mToolbar.animate().alpha(0f).setDuration(200L).start();
mAddScheduleFab.hide();
}
use of android.animation.ArgbEvaluator in project material-sheet-fab by gowong.
the class MaterialSheetAnimation method startColorAnim.
protected void startColorAnim(final View view, final int startColor, final int endColor, long duration, Interpolator interpolator, final AnimationListener listener) {
// Setup animation
ValueAnimator anim = ValueAnimator.ofObject(new ArgbEvaluator(), startColor, endColor);
anim.setDuration(duration);
anim.setInterpolator(interpolator);
// Add listeners
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationStart(Animator animation) {
if (listener != null) {
listener.onStart();
}
}
@Override
public void onAnimationEnd(Animator animation) {
if (listener != null) {
listener.onEnd();
}
}
});
anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animator) {
// Update background color
Integer color = (Integer) animator.getAnimatedValue();
// https://code.google.com/p/android/issues/detail?id=77843
if (isSupportCardView) {
// Use setCardBackground() method if it is available
if (setCardBackgroundColor != null) {
try {
setCardBackgroundColor.invoke(sheet, color);
} catch (Exception e) {
// Ignore exceptions since there's no other way set a support CardView's
// background color
}
}
} else // Set background color for all other views
{
view.setBackgroundColor(color);
}
}
});
// Start animation
anim.start();
}
use of android.animation.ArgbEvaluator in project DiscreteScrollView by yarolegovich.
the class GalleryActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_gallery);
evaluator = new ArgbEvaluator();
currentOverlayColor = ContextCompat.getColor(this, R.color.galleryCurrentItemOverlay);
overlayColor = ContextCompat.getColor(this, R.color.galleryItemOverlay);
Gallery gallery = Gallery.get();
List<Image> data = gallery.getData();
DiscreteScrollView itemPicker = (DiscreteScrollView) findViewById(R.id.item_picker);
itemPicker.setAdapter(new GalleryAdapter(data));
itemPicker.setScrollListener(this);
itemPicker.setOnItemChangedListener(this);
itemPicker.scrollToPosition(1);
findViewById(R.id.home).setOnClickListener(this);
findViewById(R.id.fab_share).setOnClickListener(this);
}
use of android.animation.ArgbEvaluator in project MaterialLibrary by DeveloperPaul123.
the class CircularTextView method initialize.
/**
* Initialize the view.
*/
private void initialize(Context context, AttributeSet attrs) {
if (isInEditMode()) {
text = "A";
colors = new int[3];
colors[0] = ColorGenerator.getRandomMaterialColor();
colors[1] = ColorGenerator.getRandomMaterialColor();
colors[2] = ColorGenerator.getRandomMaterialColor();
} else {
colors = new int[ColorGenerator.MATERIAL_COLORS_600.length];
for (int i = 0; i < ColorGenerator.MATERIAL_COLORS_600.length; i++) {
colors[i] = Color.parseColor(ColorGenerator.MATERIAL_COLORS_600[i]);
}
}
mTextSize = getDimension(R.dimen.circular_text_size);
maxTextSize = getDimension(R.dimen.circular_text_size);
mSize = getDimension(R.dimen.circular_text_view_size);
cx = mSize / 2;
cy = cx;
mPadding = getDimension(R.dimen.circular_text_view_padding);
oneDp = getDimension(R.dimen.circular_text_view_one_dp);
textPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
textPaint.setTextSize(mTextSize);
textPaint.setColor(getResources().getColor(android.R.color.white));
textPaint.setAntiAlias(true);
textPaint.setStrokeCap(Paint.Cap.ROUND);
textPaint.setStrokeWidth(1);
textPaint.setTextAlign(Paint.Align.CENTER);
checkMarkPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
checkMarkPaint.setStrokeWidth(2 * oneDp);
checkMarkPaint.setStyle(Paint.Style.STROKE);
checkMarkPaint.setColor(getResources().getColor(android.R.color.white));
checkMarkPaint.setStrokeCap(Paint.Cap.ROUND);
checkMarkPaint.setAntiAlias(true);
mColor = colors[new Random().nextInt(colors.length)];
mSecondColor = getResources().getColor(R.color.circular_text_view_second_color);
backgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
backgroundPaint.setColor(mColor);
backgroundPaint.setAntiAlias(true);
backgroundPaint.setStrokeCap(Paint.Cap.ROUND);
textAnimator = ObjectAnimator.ofFloat(this, "mTextSize", 0.0f, maxTextSize);
textAnimator.setDuration(400);
evaluator = new ArgbEvaluator();
isBackShowing = false;
gestureDetector = new GestureDetector(getContext(), new GestureListener());
}
Aggregations