use of android.view.animation.Interpolator in project sbt-android by scala-android.
the class FabDialogMorphSetup method setupSharedEelementTransitions.
/**
* Configure the shared element transitions for morphin from a fab <-> dialog. We need to do
* this in code rather than declaratively as we need to supply the color to transition from/to
* and the dialog corner radius which is dynamically supplied depending upon where this screen
* is launched from.
*/
public static void setupSharedEelementTransitions(@NonNull Activity activity, @Nullable View target, int dialogCornerRadius) {
if (!activity.getIntent().hasExtra(EXTRA_SHARED_ELEMENT_START_COLOR))
return;
int startCornerRadius = activity.getIntent().getIntExtra(EXTRA_SHARED_ELEMENT_START_CORNER_RADIUS, -1);
ArcMotion arcMotion = new ArcMotion();
arcMotion.setMinimumHorizontalAngle(50f);
arcMotion.setMinimumVerticalAngle(50f);
int color = activity.getIntent().getIntExtra(EXTRA_SHARED_ELEMENT_START_COLOR, Color.TRANSPARENT);
Interpolator easeInOut = AnimationUtils.loadInterpolator(activity, android.R.interpolator.fast_out_slow_in);
MorphFabToDialog sharedEnter = new MorphFabToDialog(color, dialogCornerRadius, startCornerRadius);
sharedEnter.setPathMotion(arcMotion);
sharedEnter.setInterpolator(easeInOut);
MorphDialogToFab sharedReturn = new MorphDialogToFab(color, startCornerRadius);
sharedReturn.setPathMotion(arcMotion);
sharedReturn.setInterpolator(easeInOut);
if (target != null) {
sharedEnter.addTarget(target);
sharedReturn.addTarget(target);
}
activity.getWindow().setSharedElementEnterTransition(sharedEnter);
activity.getWindow().setSharedElementReturnTransition(sharedReturn);
}
use of android.view.animation.Interpolator in project iosched by google.
the class AppBarLayout method onLayout.
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
super.onLayout(changed, l, t, r, b);
invalidateScrollRanges();
mHaveChildWithInterpolator = false;
for (int i = 0, z = getChildCount(); i < z; i++) {
final View child = getChildAt(i);
final LayoutParams childLp = (LayoutParams) child.getLayoutParams();
final Interpolator interpolator = childLp.getScrollInterpolator();
if (interpolator != null) {
mHaveChildWithInterpolator = true;
break;
}
}
updateCollapsible();
}
use of android.view.animation.Interpolator in project platform_packages_apps_Settings by BlissRoms.
the class PreviewPagerAdapter method setVisibility.
private void setVisibility(final View view, final int visibility, boolean animate) {
final float alpha = (visibility == View.VISIBLE ? 1.0f : 0.0f);
if (!animate) {
view.setAlpha(alpha);
view.setVisibility(visibility);
} else {
final Interpolator interpolator = (visibility == View.VISIBLE ? FADE_IN_INTERPOLATOR : FADE_OUT_INTERPOLATOR);
if (visibility == View.VISIBLE) {
// Fade in animation.
view.animate().alpha(alpha).setInterpolator(FADE_IN_INTERPOLATOR).setDuration(CROSS_FADE_DURATION_MS).setListener(new PreviewFrameAnimatorListener()).withStartAction(new Runnable() {
@Override
public void run() {
view.setVisibility(visibility);
}
});
} else {
// Fade out animation.
view.animate().alpha(alpha).setInterpolator(FADE_OUT_INTERPOLATOR).setDuration(CROSS_FADE_DURATION_MS).setListener(new PreviewFrameAnimatorListener()).withEndAction(new Runnable() {
@Override
public void run() {
view.setVisibility(visibility);
}
});
}
}
}
use of android.view.animation.Interpolator in project Osmand by osmandapp.
the class BusyIndicator method updateStatus.
/**
* @param status - 0 invisible
* 1
*/
public void updateStatus(int status) {
if (this.status != status) {
this.status = status;
final Drawable drawable;
if (this.status == STATUS_BLACK) {
drawable = ctx.getResources().getDrawable(R.drawable.progress_grey);
} else if (this.status == STATUS_ORANGE) {
drawable = ctx.getResources().getDrawable(R.drawable.progress_orange);
} else if (this.status == STATUS_GREEN) {
drawable = ctx.getResources().getDrawable(R.drawable.progress_green);
} else {
drawable = null;
}
final RotateAnimation animation;
if (drawable != null) {
animation = new RotateAnimation(0, 360, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);
animation.setRepeatCount(Animation.INFINITE);
final int cycles = 12;
animation.setInterpolator(new Interpolator() {
@Override
public float getInterpolation(float input) {
return ((int) (input * cycles)) / (float) cycles;
}
});
animation.setDuration(1200);
animation.setStartTime(RotateAnimation.START_ON_FIRST_FRAME);
animation.setStartOffset(0);
} else {
animation = null;
}
uiHandler.post(new Runnable() {
@Override
public void run() {
bar.setVisibility(drawable != null ? View.VISIBLE : View.INVISIBLE);
if (bar.getAnimation() != null) {
bar.clearAnimation();
}
if (drawable != null) {
bar.setBackgroundDrawable(drawable);
bar.startAnimation(animation);
}
}
});
}
}
use of android.view.animation.Interpolator in project butter-android by butterproject.
the class BurtterCollapsingToolbarLayout method setScrimsShown.
@Override
public void setScrimsShown(final boolean shown, final boolean animate) {
super.setScrimsShown(shown, animate);
if (scrimsAreShown != shown) {
findToolbar();
if (toolbar != null) {
if (animator != null) {
animator.cancel();
}
if (animate) {
animator = ValueAnimator.ofFloat(0, 1);
animator.setDuration(getScrimAnimationDuration());
Interpolator interpolator = shown ? new FastOutLinearInInterpolator() : new LinearOutSlowInInterpolator();
animator.setInterpolator(interpolator);
final ArgbEvaluator evaluator = new ArgbEvaluator();
animator.addUpdateListener(new AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float fraction = animation.getAnimatedFraction();
int color;
if (shown) {
color = (int) evaluator.evaluate(fraction, TEXT_COLOR_TRANSPARENT, TEXT_COLOR);
} else {
color = (int) evaluator.evaluate(fraction, TEXT_COLOR, TEXT_COLOR_TRANSPARENT);
}
toolbar.setTitleTextColor(color);
}
});
animator.start();
} else {
toolbar.setTitleTextColor(shown ? TEXT_COLOR : TEXT_COLOR_TRANSPARENT);
}
}
scrimsAreShown = shown;
}
}
Aggregations