@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, MorphDrawable.COLOR, endColor);
Animator corners = ObjectAnimator.ofFloat(background, MorphDrawable.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(AnimationUtils.loadInterpolator(vg.getContext(), android.R.interpolator.fast_out_linear_in))
.start();
}
}
AnimatorSet transition = new AnimatorSet();
transition.playTogether(changeBounds, corners, color);
transition.setInterpolator(AnimationUtils.loadInterpolator(sceneRoot.getContext(), android.R.interpolator.fast_out_slow_in));
transition.setDuration(300);
return transition;
}
java类android.animation.AnimatorSet的实例源码
MorphDialogToFab.java 文件源码
项目:Morphing-Material-Dialogs
阅读 22
收藏 0
点赞 0
评论 0
Workspace.java 文件源码
项目:FlickLauncher
阅读 32
收藏 0
点赞 0
评论 0
/**
* Sets the current workspace {@link State}, returning an animation transitioning the workspace
* to that new state.
*/
public Animator setStateWithAnimation(State toState, boolean animated,
HashMap<View, Integer> layerViews) {
// Create the animation to the new state
AnimatorSet workspaceAnim = mStateTransitionAnimation.getAnimationToState(mState,
toState, animated, layerViews);
boolean shouldNotifyWidgetChange = !mState.shouldUpdateWidget
&& toState.shouldUpdateWidget;
// Update the current state
mState = toState;
updateAccessibilityFlags();
if (shouldNotifyWidgetChange) {
mLauncher.notifyWidgetProvidersChanged();
}
if (mOnStateChangeListener != null) {
mOnStateChangeListener.prepareStateChange(toState, animated ? workspaceAnim : null);
}
return workspaceAnim;
}
CoverFlowView.java 文件源码
项目:Hotspot-master-devp
阅读 38
收藏 0
点赞 0
评论 0
/**
* 对 bitmap 进行伪 3d 变换
*
* @param child
* @param position
* @param offset
*/
private void makeChildTransfromer(View child, int position, float offset) {
child.layout(0, 0, child.getMeasuredWidth(), child.getMeasuredHeight());
float scale = 0;
float scaleX = 0;
scale = 1 - Math.abs(offset) * 0.25f;
scaleX = 1 - Math.abs(offset) * 0.15f;
// 延x轴移动的距离应该根据center图片决定
float translateY = 0;
final int originalChildHeight = (int) (mChildHeight - mChildHeight
* reflectHeightFraction - reflectGap);
final float originalChildHeightScale = (float) originalChildHeight / child.getHeight();
final float childHeightScale = originalChildHeightScale * scale;
final float childWidthScale = originalChildHeightScale * scaleX;
final int centerChildHeight = (int) (child.getHeight() * originalChildHeightScale);
topSpace = (mHeight-centerChildHeight)/2;
// float baseDis = dip2px(getContext(),24);
baseDis = centerChildHeight/4.9f;
translateY = (mHeight-centerChildHeight)/2- baseDis *offset*-1;
//根据offset 算出透明度
float alpha = 254 - Math.abs(offset) * STANDARD_ALPHA;
child.setAlpha(0);
if (alpha < 0) {
alpha = 0;
} else if (alpha > 254) {
alpha = 254;
}
child.setAlpha(alpha / 254.0f);
ObjectAnimator anim1 = ObjectAnimator.ofFloat(child, "scaleX", 1.0f, childWidthScale);
ObjectAnimator anim2 = ObjectAnimator.ofFloat(child, "scaleY", 1.0f, childHeightScale);
AnimatorSet animSet = new AnimatorSet();
animSet.setDuration(0);
//两个动画同时执行
animSet.playTogether(anim1, anim2);
child.setPivotX(child.getWidth()/2);
child.setPivotY(child.getHeight() / 2);
//显示的调用invalidate
child.invalidate();
animSet.setTarget(child);
animSet.start();
child.setTranslationX(mChildTranslateX);
child.setTranslationY(translateY);
}
AppMenu.java 文件源码
项目:chromium-for-android-56-debug-video
阅读 24
收藏 0
点赞 0
评论 0
private void runMenuItemEnterAnimations() {
mMenuItemEnterAnimator = new AnimatorSet();
AnimatorSet.Builder builder = null;
ViewGroup list = mPopup.getListView();
for (int i = 0; i < list.getChildCount(); i++) {
View view = list.getChildAt(i);
Object animatorObject = view.getTag(R.id.menu_item_enter_anim_id);
if (animatorObject != null) {
if (builder == null) {
builder = mMenuItemEnterAnimator.play((Animator) animatorObject);
} else {
builder.with((Animator) animatorObject);
}
}
}
mMenuItemEnterAnimator.addListener(mAnimationHistogramRecorder);
mMenuItemEnterAnimator.start();
}
UserKeepAdapter.java 文件源码
项目:topnews
阅读 19
收藏 0
点赞 0
评论 0
/**
* 初始化动画操作
*/
private void initAnimator( ViewHolder holder){
ObjectAnimator mItem = ObjectAnimator.ofFloat(holder.itemView, "translationX",0f, -60f);
ObjectAnimator scaleX = ObjectAnimator.ofFloat(holder.mImage, "scaleX",1f, 0f);
ObjectAnimator scaleY = ObjectAnimator.ofFloat(holder.mImage, "scaleY",1f, 0f);
AnimatorSet animSet = new AnimatorSet();
animSet.play(mItem).with(scaleX).with(scaleY);
animSet.setDuration(0);
animSet.start();
}
GiftAnimationLayout.java 文件源码
项目:LiveGiftView
阅读 20
收藏 0
点赞 0
评论 0
/**
* 开始播放连击动画
*/
public AnimatorSet startNumberComboAnimation() {
if (onAnimationListener != null) {
onAnimationListener.onGiftAnimationCombo(mComboCurrentCount);
}
if (mAnimation == null) {
return mDefaultAnimation.giftNumberComboAnimation(this, holder, mComboCurrentCount);
}
return mAnimation.giftNumberComboAnimation(this, holder, mComboCurrentCount);
}
CardStackAdapter.java 文件源码
项目:VirtualHook
阅读 20
收藏 0
点赞 0
评论 0
/**
* Plays together all animations passed in as parameter. Once animation is
* completed, r.run() is executed. If parameter isReset is set to true,
* {@link #mSelectedCardPosition} is set to {@link #INVALID_CARD_POSITION}
*
* @param animations
* @param r
* @param isReset
*/
private void startAnimations(List<Animator> animations, final Runnable r, final boolean isReset) {
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(animations);
animatorSet.setDuration(ANIM_DURATION);
animatorSet.setInterpolator(new DecelerateInterpolator(DECELERATION_FACTOR));
animatorSet.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
if (r != null)
r.run();
setScreenTouchable(true);
if (isReset)
mSelectedCardPosition = INVALID_CARD_POSITION;
}
});
animatorSet.start();
}
WaveHelper.java 文件源码
项目:WaveView-RN
阅读 20
收藏 0
点赞 0
评论 0
private void initAnimation() {
List<Animator> animators = new ArrayList<>();
// horizontal animation.
// wave waves infinitely.
ObjectAnimator waveShiftAnim = ObjectAnimator.ofFloat(
mWaveView, "waveShiftRatio", 0f, 1f);
waveShiftAnim.setRepeatCount(ValueAnimator.INFINITE);
waveShiftAnim.setDuration(1000);
waveShiftAnim.setInterpolator(new LinearInterpolator());
animators.add(waveShiftAnim);
// vertical animation.
// water level increases from 0 to center of WaveView
ObjectAnimator waterLevelAnim = ObjectAnimator.ofFloat(
mWaveView, "waterLevelRatio", 0f, 0.5f);
waterLevelAnim.setDuration(1000);
waterLevelAnim.setInterpolator(new DecelerateInterpolator());
animators.add(waterLevelAnim);
// amplitude animation.
// wave grows big then grows small, repeatedly
ObjectAnimator amplitudeAnim = ObjectAnimator.ofFloat(
mWaveView, "amplitudeRatio", 0.0001f, 0.05f);
amplitudeAnim.setRepeatCount(ValueAnimator.INFINITE);
amplitudeAnim.setRepeatMode(ValueAnimator.REVERSE);
amplitudeAnim.setDuration(5000);
amplitudeAnim.setInterpolator(new LinearInterpolator());
animators.add(amplitudeAnim);
mAnimatorSet = new AnimatorSet();
mAnimatorSet.playTogether(animators);
}
FlatPlayerFragment.java 文件源码
项目:Orin
阅读 18
收藏 0
点赞 0
评论 0
public AnimatorSet createDefaultColorChangeAnimatorSet(int newColor) {
Animator backgroundAnimator = ViewUtil.createBackgroundColorTransition(fragment.playbackControlsFragment.getView(), fragment.lastColor, newColor);
Animator statusBarAnimator = ViewUtil.createBackgroundColorTransition(fragment.playerStatusBar, fragment.lastColor, newColor);
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(backgroundAnimator, statusBarAnimator);
if (!ATHUtil.isWindowBackgroundDark(fragment.getActivity())) {
int adjustedLastColor = ColorUtil.isColorLight(fragment.lastColor) ? ColorUtil.darkenColor(fragment.lastColor) : fragment.lastColor;
int adjustedNewColor = ColorUtil.isColorLight(newColor) ? ColorUtil.darkenColor(newColor) : newColor;
Animator subHeaderAnimator = ViewUtil.createTextColorTransition(fragment.playerQueueSubHeader, adjustedLastColor, adjustedNewColor);
animatorSet.play(subHeaderAnimator);
}
animatorSet.setDuration(ViewUtil.PHONOGRAPH_ANIM_TIME);
return animatorSet;
}
AnimatorSetProxy.java 文件源码
项目:PlusGram
阅读 21
收藏 0
点赞 0
评论 0
public AnimatorSetProxy() {
if (View10.NEED_PROXY) {
animatorSet = new AnimatorSet10();
} else {
animatorSet = new AnimatorSet();
}
}