use of android.view.animation.OvershootInterpolator in project KJFrameForAndroid by kymjs.
the class KJAnimations method openAnimation.
/**
* 打开的动画
*
* @param relativeLayout
* 子菜单容器
* @param background
* 子菜单背景
* @param menu
* 菜单按钮
* @param durationMillis
* 动画时间
*/
public static void openAnimation(RelativeLayout relativeLayout, ImageView menu, long durationMillis) {
relativeLayout.setVisibility(View.VISIBLE);
for (int i = 1; i < relativeLayout.getChildCount(); i++) {
ImageView imageView = null;
if (relativeLayout.getChildAt(i) instanceof ImageView) {
imageView = (ImageView) relativeLayout.getChildAt(i);
} else {
continue;
}
AnimationSet set = new AnimationSet(true);
set.addAnimation(getRotateAnimation(-360, 0, durationMillis));
set.addAnimation(getAlphaAnimation(0.5f, 1.0f, durationMillis));
set.addAnimation(getTranslateAnimation(menu.getLeft() - imageView.getLeft(), 0, menu.getTop() - imageView.getTop(), 0, durationMillis));
set.setFillAfter(true);
set.setDuration(durationMillis);
set.setStartOffset((i * 100) / (-1 + relativeLayout.getChildCount()));
set.setInterpolator(new OvershootInterpolator(1f));
imageView.startAnimation(set);
}
}
use of android.view.animation.OvershootInterpolator in project Bitocle by mthli.
the class DefaultAnimationHandler method animateMenuOpening.
@Override
public void animateMenuOpening(Point center) {
super.animateMenuOpening(center);
setAnimating(true);
Animator lastAnimation = null;
for (int i = 0; i < menu.getSubActionItems().size(); i++) {
menu.getSubActionItems().get(i).view.setScaleX(0);
menu.getSubActionItems().get(i).view.setScaleY(0);
menu.getSubActionItems().get(i).view.setAlpha(0);
PropertyValuesHolder pvhX = PropertyValuesHolder.ofFloat(View.TRANSLATION_X, menu.getSubActionItems().get(i).x - center.x + menu.getSubActionItems().get(i).width / 2);
PropertyValuesHolder pvhY = PropertyValuesHolder.ofFloat(View.TRANSLATION_Y, menu.getSubActionItems().get(i).y - center.y + menu.getSubActionItems().get(i).height / 2);
PropertyValuesHolder pvhR = PropertyValuesHolder.ofFloat(View.ROTATION, 720);
PropertyValuesHolder pvhsX = PropertyValuesHolder.ofFloat(View.SCALE_X, 1);
PropertyValuesHolder pvhsY = PropertyValuesHolder.ofFloat(View.SCALE_Y, 1);
PropertyValuesHolder pvhA = PropertyValuesHolder.ofFloat(View.ALPHA, 1);
final ObjectAnimator animation = ObjectAnimator.ofPropertyValuesHolder(menu.getSubActionItems().get(i).view, pvhX, pvhY, pvhR, pvhsX, pvhsY, pvhA);
animation.setDuration(DURATION);
animation.setInterpolator(new OvershootInterpolator(0.9f));
animation.addListener(new SubActionItemAnimationListener(menu.getSubActionItems().get(i), ActionType.OPENING));
if (i == 0) {
lastAnimation = animation;
}
// Put a slight lag between each of the menu items to make it asymmetric
animation.setStartDelay((menu.getSubActionItems().size() - i) * LAG_BETWEEN_ITEMS);
animation.start();
}
if (lastAnimation != null) {
lastAnimation.addListener(new LastAnimationListener());
}
}
use of android.view.animation.OvershootInterpolator in project FlyRefresh by race604.
the class SampleItemAnimator method animateAddImpl.
@Override
protected void animateAddImpl(final RecyclerView.ViewHolder holder) {
View target = holder.itemView;
View icon = target.findViewById(R.id.icon);
Animator swing = ObjectAnimator.ofFloat(icon, "rotationX", 45, 0);
swing.setInterpolator(new OvershootInterpolator(5));
View right = holder.itemView.findViewById(R.id.right);
Animator rotateIn = ObjectAnimator.ofFloat(right, "rotationY", 90, 0);
rotateIn.setInterpolator(new DecelerateInterpolator());
AnimatorSet animator = new AnimatorSet();
animator.setDuration(getAddDuration());
animator.playTogether(swing, rotateIn);
animator.start();
}
use of android.view.animation.OvershootInterpolator in project muzei by romannurik.
the class MuzeiActivity method updateUiMode.
private void updateUiMode() {
// TODO: this should really just use fragment transactions and transitions
int newUiMode = UI_MODE_INTRO;
if (mWallpaperActive) {
newUiMode = UI_MODE_TUTORIAL;
if (mSeenTutorial) {
newUiMode = UI_MODE_ART_DETAIL;
}
}
if (mUiMode == newUiMode) {
return;
}
// Crossfade between main containers
final View oldContainerView = getMainContainerForUiMode(mUiMode);
final View newContainerView = getMainContainerForUiMode(newUiMode);
if (oldContainerView != null) {
oldContainerView.animate().alpha(0).setDuration(1000).withEndAction(new Runnable() {
@Override
public void run() {
oldContainerView.setVisibility(View.GONE);
}
});
}
if (newContainerView != null) {
if (newContainerView.getAlpha() == 1) {
newContainerView.setAlpha(0);
}
newContainerView.setVisibility(View.VISIBLE);
newContainerView.animate().alpha(1).setDuration(1000).withEndAction(null);
}
// Special work
if (newUiMode == UI_MODE_INTRO) {
FirebaseAnalytics.getInstance(this).logEvent(FirebaseAnalytics.Event.TUTORIAL_BEGIN, null);
final View activateButton = findViewById(R.id.activate_muzei_button);
activateButton.setAlpha(0);
final AnimatedMuzeiLogoFragment logoFragment = (AnimatedMuzeiLogoFragment) getFragmentManager().findFragmentById(R.id.animated_logo_fragment);
logoFragment.reset();
logoFragment.setOnFillStartedCallback(new Runnable() {
@Override
public void run() {
activateButton.animate().alpha(1f).setDuration(500);
}
});
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
logoFragment.start();
}
}, 1000);
}
if (mUiMode == UI_MODE_INTRO || newUiMode == UI_MODE_INTRO) {
FragmentManager fm = getSupportFragmentManager();
Fragment demoFragment = fm.findFragmentById(R.id.demo_view_container);
if (newUiMode == UI_MODE_INTRO && demoFragment == null) {
fm.beginTransaction().add(R.id.demo_view_container, MuzeiRendererFragment.createInstance(true, true)).commit();
} else if (newUiMode != UI_MODE_INTRO && demoFragment != null) {
fm.beginTransaction().remove(demoFragment).commit();
}
}
if (newUiMode == UI_MODE_TUTORIAL) {
float animateDistance = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 100, getResources().getDisplayMetrics());
View mainTextView = findViewById(R.id.tutorial_main_text);
mainTextView.setAlpha(0);
mainTextView.setTranslationY(-animateDistance / 5);
View subTextView = findViewById(R.id.tutorial_sub_text);
subTextView.setAlpha(0);
subTextView.setTranslationY(-animateDistance / 5);
final View affordanceView = findViewById(R.id.tutorial_icon_affordance);
affordanceView.setAlpha(0);
affordanceView.setTranslationY(animateDistance);
View iconTextView = findViewById(R.id.tutorial_icon_text);
iconTextView.setAlpha(0);
iconTextView.setTranslationY(animateDistance);
AnimatorSet set = new AnimatorSet();
set.setStartDelay(500);
set.setDuration(250);
set.playTogether(ObjectAnimator.ofFloat(mainTextView, View.ALPHA, 1f), ObjectAnimator.ofFloat(subTextView, View.ALPHA, 1f));
set.start();
set = new AnimatorSet();
set.setStartDelay(2000);
// Bug in older versions where set.setInterpolator didn't work
Interpolator interpolator = new OvershootInterpolator();
ObjectAnimator a1 = ObjectAnimator.ofFloat(affordanceView, View.TRANSLATION_Y, 0);
ObjectAnimator a2 = ObjectAnimator.ofFloat(iconTextView, View.TRANSLATION_Y, 0);
ObjectAnimator a3 = ObjectAnimator.ofFloat(mainTextView, View.TRANSLATION_Y, 0);
ObjectAnimator a4 = ObjectAnimator.ofFloat(subTextView, View.TRANSLATION_Y, 0);
a1.setInterpolator(interpolator);
a2.setInterpolator(interpolator);
a3.setInterpolator(interpolator);
a4.setInterpolator(interpolator);
set.setDuration(500).playTogether(ObjectAnimator.ofFloat(affordanceView, View.ALPHA, 1f), ObjectAnimator.ofFloat(iconTextView, View.ALPHA, 1f), a1, a2, a3, a4);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
set.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
ImageView emanateView = (ImageView) findViewById(R.id.tutorial_icon_emanate);
AnimatedVectorDrawable avd = (AnimatedVectorDrawable) getResources().getDrawable(R.drawable.avd_tutorial_icon_emanate, getTheme());
emanateView.setImageDrawable(avd);
avd.start();
}
});
}
set.start();
}
if (newUiMode == UI_MODE_ART_DETAIL) {
FirebaseAnalytics.getInstance(this).logEvent(FirebaseAnalytics.Event.TUTORIAL_COMPLETE, null);
}
mPanScaleProxyView.setVisibility(newUiMode == UI_MODE_ART_DETAIL ? View.VISIBLE : View.GONE);
mUiMode = newUiMode;
maybeUpdateArtDetailOpenedClosed();
}
use of android.view.animation.OvershootInterpolator in project muzei by romannurik.
the class AnimatedMuzeiLogoFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.animated_logo_fragment, container, false);
mSubtitleView = rootView.findViewById(R.id.logo_subtitle);
mLogoView = (AnimatedMuzeiLogoView) rootView.findViewById(R.id.animated_logo);
mLogoView.setOnStateChangeListener(new AnimatedMuzeiLogoView.OnStateChangeListener() {
@Override
public void onStateChange(int state) {
if (state == AnimatedMuzeiLogoView.STATE_FILL_STARTED) {
mSubtitleView.setAlpha(0);
mSubtitleView.setVisibility(View.VISIBLE);
mSubtitleView.setTranslationY(-mSubtitleView.getHeight());
// Bug in older versions where set.setInterpolator didn't work
AnimatorSet set = new AnimatorSet();
Interpolator interpolator = new OvershootInterpolator();
ObjectAnimator a1 = ObjectAnimator.ofFloat(mLogoView, View.TRANSLATION_Y, 0);
ObjectAnimator a2 = ObjectAnimator.ofFloat(mSubtitleView, View.TRANSLATION_Y, 0);
ObjectAnimator a3 = ObjectAnimator.ofFloat(mSubtitleView, View.ALPHA, 1);
a1.setInterpolator(interpolator);
a2.setInterpolator(interpolator);
set.setDuration(500).playTogether(a1, a2, a3);
set.start();
if (mOnFillStartedCallback != null) {
mOnFillStartedCallback.run();
}
}
}
});
reset();
return rootView;
}
Aggregations