Skip to content
Snippets Groups Projects
Commit 0f56bafa authored by John Carlson's avatar John Carlson
Browse files

Use library for Morph transitions

parent af54c85c
No related branches found
No related tags found
No related merge requests found
Pipeline #
Loading
Loading
@@ -116,6 +116,7 @@ dependencies {
compile 'com.github.Commit451:Jounce:1.0.1'
compile 'com.github.Commit451:EasyCallback:2.1.1'
compile 'com.github.Commit451:ForegroundViews:2.2.1'
compile 'com.github.Commit451:MorphTransitions:2.0.0'
compile 'me.zhanghai.android.materialprogressbar:library:1.1.7'
compile 'com.github.Jawnnypoo:PhysicsLayout:2.1.0'
compile 'com.alexgwyn.recyclerviewsquire:recyclerviewsquire:0.0.5'
Loading
Loading
package com.commit451.gitlab.activity;
 
import android.annotation.TargetApi;
import android.app.Activity;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.transition.ArcMotion;
import android.view.View;
import android.view.animation.AnimationUtils;
import android.view.animation.Interpolator;
 
import com.commit451.easel.Easel;
import com.commit451.gitlab.R;
import com.commit451.gitlab.transition.MorphDialogToFab;
import com.commit451.gitlab.transition.MorphFabToDialog;
import com.commit451.morphtransitions.FabTransform;
 
/**
* Activity that morphs from a FAB. Make sure the view you want to morph has the view id R.id.mRoot and
Loading
Loading
@@ -21,43 +12,11 @@ import com.commit451.gitlab.transition.MorphFabToDialog;
*/
public class MorphActivity extends BaseActivity {
 
protected void morph(View root) {
if (root == null) {
throw new IllegalStateException("Cannot pass an empty view");
}
if (Build.VERSION.SDK_INT >= 21) {
int fabColor = Easel.getThemeAttrColor(this, R.attr.colorAccent);
int dialogColor = Easel.getThemeAttrColor(this, android.R.attr.windowBackground);
setupSharedElementTransitionsFab(this, root,
fabColor,
dialogColor,
getResources().getDimensionPixelSize(R.dimen.dialog_corners));
}
}
@TargetApi(21)
public void setupSharedElementTransitionsFab(@NonNull Activity activity,
@Nullable View target,
int fabColor,
int dialogColor,
int dialogCornerRadius) {
ArcMotion arcMotion = new ArcMotion();
arcMotion.setMinimumHorizontalAngle(50f);
arcMotion.setMinimumVerticalAngle(50f);
Interpolator easeInOut = AnimationUtils.loadInterpolator(activity, android.R.interpolator.fast_out_slow_in);
MorphFabToDialog sharedEnter = new MorphFabToDialog(fabColor, dialogColor, dialogCornerRadius);
sharedEnter.setPathMotion(arcMotion);
sharedEnter.setInterpolator(easeInOut);
MorphDialogToFab sharedReturn = new MorphDialogToFab(dialogColor, fabColor);
sharedReturn.setPathMotion(arcMotion);
sharedReturn.setInterpolator(easeInOut);
if (target != null) {
sharedEnter.addTarget(target);
sharedReturn.addTarget(target);
}
activity.getWindow().setSharedElementEnterTransition(sharedEnter);
activity.getWindow().setSharedElementReturnTransition(sharedReturn);
FabTransform.setup(this, root);
}
 
@Override
Loading
Loading
Loading
Loading
@@ -6,11 +6,13 @@ import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.support.annotation.DrawableRes;
import android.support.annotation.Nullable;
import android.support.v4.app.ActivityOptionsCompat;
import android.view.View;
import android.widget.ImageView;
 
import com.commit451.easel.Easel;
import com.commit451.gitlab.App;
import com.commit451.gitlab.R;
import com.commit451.gitlab.activity.AboutActivity;
Loading
Loading
@@ -49,6 +51,7 @@ import com.commit451.gitlab.model.api.Project;
import com.commit451.gitlab.model.api.RepositoryCommit;
import com.commit451.gitlab.model.api.UserBasic;
import com.commit451.gitlab.util.IntentUtil;
import com.commit451.morphtransitions.FabTransform;
 
import timber.log.Timber;
 
Loading
Loading
@@ -101,6 +104,7 @@ public class Navigator {
throw new IllegalArgumentException("You need to define start activity " + startingActivity);
}
}
public static void navigateToProjects(Activity activity) {
activity.startActivity(ProjectsActivity.newIntent(activity));
}
Loading
Loading
@@ -191,25 +195,26 @@ public class Navigator {
 
public static void navigateToAddProjectMember(Activity activity, View fab, long projectId) {
Intent intent = AddUserActivity.newIntent(activity, projectId);
startMorphActivity(activity, fab, intent);
startMorphActivity(activity, fab, R.drawable.ic_add_24dp, intent);
}
 
public static void navigateToAddGroupMember(Activity activity, View fab, Group group) {
Intent intent = AddUserActivity.newIntent(activity, group);
startMorphActivity(activity, fab, intent);
startMorphActivity(activity, fab, R.drawable.ic_add_24dp, intent);
}
 
public static void navigateToEditIssue(Activity activity, View fab, Project project, Issue issue) {
navigateToAddIssue(activity, fab, project, issue);
Intent intent = AddIssueActivity.newIntent(activity, project, issue);
activity.startActivity(intent);
}
 
public static void navigateToAddIssue(Activity activity, View fab, Project project) {
navigateToAddIssue(activity, fab, project, null);
navigateToAddIssue(activity, fab, R.drawable.ic_add_24dp, project, null);
}
 
private static void navigateToAddIssue(Activity activity, View fab, Project project, Issue issue) {
private static void navigateToAddIssue(Activity activity, View fab, @DrawableRes int drawable, Project project, Issue issue) {
Intent intent = AddIssueActivity.newIntent(activity, project, issue);
startMorphActivity(activity, fab, intent);
startMorphActivity(activity, fab, drawable, intent);
}
 
public static void navigateToAddLabels(Activity activity, Project project, int requestCode) {
Loading
Loading
@@ -224,12 +229,12 @@ public class Navigator {
 
public static void navigateToAddMilestone(Activity activity, View fab, Project project) {
Intent intent = AddMilestoneActivity.newIntent(activity, project.getId());
startMorphActivity(activity, fab, intent);
startMorphActivity(activity, fab, R.drawable.ic_add_24dp, intent);
}
 
public static void navigateToEditMilestone(Activity activity, View fab, Project project, Milestone milestone) {
Intent intent = AddMilestoneActivity.newIntent(activity, project.getId(), milestone);
startMorphActivity(activity, fab, intent);
startMorphActivity(activity, fab, R.drawable.ic_edit_24dp, intent);
}
 
public static void navigateToBuild(Activity activity, Project project, com.commit451.gitlab.model.api.Build build) {
Loading
Loading
@@ -243,8 +248,10 @@ public class Navigator {
activity.overridePendingTransition(R.anim.fade_in, R.anim.do_nothing);
}
 
private static void startMorphActivity(Activity activity, View fab, Intent intent) {
private static void startMorphActivity(Activity activity, View fab, @DrawableRes int drawableRes, Intent intent) {
if (Build.VERSION.SDK_INT >= 21 && fab != null) {
FabTransform.addExtras(intent, Easel.getThemeAttrColor(activity, R.attr.colorAccent),
drawableRes);
ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation
(activity, fab, activity.getString(R.string.transition_morph));
activity.startActivity(intent, options.toBundle());
Loading
Loading
@@ -265,8 +272,9 @@ public class Navigator {
 
/**
* Like {@link #navigateToUrl(Activity, Uri, Account)} but we already know it is the same server
*
* @param context context
* @param uri uri
* @param uri uri
*/
public static void navigateToUrl(Context context, Uri uri) {
Timber.d("navigateToUrl: %s", uri);
Loading
Loading
package com.commit451.gitlab.transition;
import android.animation.Animator;
import android.animation.TimeInterpolator;
import android.annotation.TargetApi;
import android.support.v4.util.ArrayMap;
import android.support.v4.view.animation.FastOutSlowInInterpolator;
import android.transition.Transition;
import android.util.Property;
import android.view.animation.Interpolator;
import java.util.ArrayList;
/**
* Utility methods for working with animations.
*/
public class AnimUtils {
private AnimUtils() { }
private static Interpolator gusterpolator;
public static Interpolator getMaterialInterpolator() {
if (gusterpolator == null) {
synchronized (AnimUtils.class) {
if (gusterpolator == null) {
gusterpolator = new FastOutSlowInInterpolator();
}
}
}
return gusterpolator;
}
/**
* Linear interpolate between a and b with parameter t.
*/
public static float lerp(float a, float b, float t) {
return a + (b - a) * t;
}
/**
* An implementation of {@link android.util.Property} to be used specifically with fields of
* type
* <code>float</code>. This type-specific subclass enables performance benefit by allowing
* calls to a {@link #set(Object, Float) set()} function that takes the primitive
* <code>float</code> type and avoids autoboxing and other overhead associated with the
* <code>Float</code> class.
*
* @param <T> The class on which the Property is declared.
**/
public static abstract class FloatProperty<T> extends Property<T, Float> {
public FloatProperty(String name) {
super(Float.class, name);
}
/**
* A type-specific override of the {@link #set(Object, Float)} that is faster when dealing
* with fields of type <code>float</code>.
*/
public abstract void setValue(T object, float value);
@Override
final public void set(T object, Float value) {
setValue(object, value);
}
}
/**
* An implementation of {@link android.util.Property} to be used specifically with fields of
* type
* <code>int</code>. This type-specific subclass enables performance benefit by allowing
* calls to a {@link #set(Object, Integer) set()} function that takes the primitive
* <code>int</code> type and avoids autoboxing and other overhead associated with the
* <code>Integer</code> class.
*
* @param <T> The class on which the Property is declared.
*/
public static abstract class IntProperty<T> extends Property<T, Integer> {
public IntProperty(String name) {
super(Integer.class, name);
}
/**
* A type-specific override of the {@link #set(Object, Integer)} that is faster when dealing
* with fields of type <code>int</code>.
*/
public abstract void setValue(T object, int value);
@Override
final public void set(T object, Integer value) {
setValue(object, value.intValue());
}
}
/**
* https://halfthought.wordpress.com/2014/11/07/reveal-transition/
* <p/>
* Interrupting Activity transitions can yield an OperationNotSupportedException when the
* transition tries to pause the animator. Yikes! We can fix this by wrapping the Animator:
*/
public static class NoPauseAnimator extends Animator {
private final Animator mAnimator;
private final ArrayMap<AnimatorListener, AnimatorListener> mListeners =
new ArrayMap<>();
public NoPauseAnimator(Animator animator) {
mAnimator = animator;
}
@Override
public void addListener(AnimatorListener listener) {
AnimatorListener wrapper = new AnimatorListenerWrapper(this, listener);
if (!mListeners.containsKey(listener)) {
mListeners.put(listener, wrapper);
mAnimator.addListener(wrapper);
}
}
@Override
public void cancel() {
mAnimator.cancel();
}
@Override
public void end() {
mAnimator.end();
}
@Override
public long getDuration() {
return mAnimator.getDuration();
}
@TargetApi(18)
@Override
public TimeInterpolator getInterpolator() {
return mAnimator.getInterpolator();
}
@Override
public void setInterpolator(TimeInterpolator timeInterpolator) {
mAnimator.setInterpolator(timeInterpolator);
}
@Override
public ArrayList<AnimatorListener> getListeners() {
return new ArrayList<AnimatorListener>(mListeners.keySet());
}
@Override
public long getStartDelay() {
return mAnimator.getStartDelay();
}
@Override
public void setStartDelay(long delayMS) {
mAnimator.setStartDelay(delayMS);
}
@TargetApi(19)
@Override
public boolean isPaused() {
return mAnimator.isPaused();
}
@Override
public boolean isRunning() {
return mAnimator.isRunning();
}
@Override
public boolean isStarted() {
return mAnimator.isStarted();
}
/* We don't want to override pause or resume methods because we don't want them
* to affect mAnimator.
public void pause();
public void resume();
public void addPauseListener(AnimatorPauseListener listener);
public void removePauseListener(AnimatorPauseListener listener);
*/
@Override
public void removeAllListeners() {
mListeners.clear();
mAnimator.removeAllListeners();
}
@Override
public void removeListener(AnimatorListener listener) {
AnimatorListener wrapper = mListeners.get(listener);
if (wrapper != null) {
mListeners.remove(listener);
mAnimator.removeListener(wrapper);
}
}
@Override
public Animator setDuration(long durationMS) {
mAnimator.setDuration(durationMS);
return this;
}
@Override
public void setTarget(Object target) {
mAnimator.setTarget(target);
}
@Override
public void setupEndValues() {
mAnimator.setupEndValues();
}
@Override
public void setupStartValues() {
mAnimator.setupStartValues();
}
@Override
public void start() {
mAnimator.start();
}
}
static class AnimatorListenerWrapper implements Animator.AnimatorListener {
private final Animator mAnimator;
private final Animator.AnimatorListener mListener;
public AnimatorListenerWrapper(Animator animator, Animator.AnimatorListener listener) {
mAnimator = animator;
mListener = listener;
}
@Override
public void onAnimationStart(Animator animator) {
mListener.onAnimationStart(mAnimator);
}
@Override
public void onAnimationEnd(Animator animator) {
mListener.onAnimationEnd(mAnimator);
}
@Override
public void onAnimationCancel(Animator animator) {
mListener.onAnimationCancel(mAnimator);
}
@Override
public void onAnimationRepeat(Animator animator) {
mListener.onAnimationRepeat(mAnimator);
}
}
@TargetApi(19)
public static class TransitionListenerAdapter implements Transition.TransitionListener {
@Override
public void onTransitionStart(Transition transition) {
}
@Override
public void onTransitionEnd(Transition transition) {
}
@Override
public void onTransitionCancel(Transition transition) {
}
@Override
public void onTransitionPause(Transition transition) {
}
@Override
public void onTransitionResume(Transition transition) {
}
}
}
package com.commit451.gitlab.transition;
import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.graphics.Color;
import android.support.annotation.ColorInt;
import android.transition.ChangeBounds;
import android.transition.TransitionValues;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AnimationUtils;
import com.commit451.gitlab.R;
/**
* A transition that morphs a rectangle into a circle, changing it's background color.
*/
public class MorphDialogToFab extends ChangeBounds {
private static final String PROPERTY_START_COLOR = "plaid:rectMorph:startcolor";
private static final String PROPERTY_END_COLOR = "plaid:rectMorph:endcolor";
private static final String PROPERTY_CORNER_RADIUS = "plaid:rectMorph:cornerRadius";
private static final String[] TRANSITION_PROPERTIES = {
PROPERTY_START_COLOR,
PROPERTY_CORNER_RADIUS
};
private @ColorInt
int endColor = Color.TRANSPARENT;
private @ColorInt
int startColor = Color.TRANSPARENT;
public MorphDialogToFab(@ColorInt int startColor, @ColorInt int endColor) {
super();
setStartColor(startColor);
setEndColor(endColor);
}
public MorphDialogToFab(Context context, AttributeSet attrs) {
super(context, attrs);
}
public void setEndColor(@ColorInt int endColor) {
this.endColor = endColor;
}
public void setStartColor(@ColorInt int startColor) {
this.startColor = startColor;
}
@Override
public String[] getTransitionProperties() {
return TRANSITION_PROPERTIES;
}
@Override
public void captureStartValues(TransitionValues transitionValues) {
super.captureStartValues(transitionValues);
final View view = transitionValues.view;
if (view.getWidth() <= 0 || view.getHeight() <= 0) {
return;
}
transitionValues.values.put(PROPERTY_START_COLOR, startColor);
transitionValues.values.put(PROPERTY_END_COLOR, endColor);
transitionValues.values.put(PROPERTY_CORNER_RADIUS, view.getResources()
.getDimensionPixelSize(R.dimen.dialog_corners));
}
@Override
public void captureEndValues(TransitionValues transitionValues) {
super.captureEndValues(transitionValues);
final View view = transitionValues.view;
if (view.getWidth() <= 0 || view.getHeight() <= 0) {
return;
}
transitionValues.values.put(PROPERTY_START_COLOR, startColor);
transitionValues.values.put(PROPERTY_END_COLOR, endColor);
transitionValues.values.put(PROPERTY_CORNER_RADIUS, view.getHeight() / 2);
}
@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_START_COLOR);
Integer startCornerRadius = (Integer) startValues.values.get(PROPERTY_CORNER_RADIUS);
Integer endColor = (Integer) endValues.values.get(PROPERTY_END_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_fast 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.setDuration(300);
transition.setInterpolator(AnimUtils.getMaterialInterpolator());
return transition;
}
}
\ No newline at end of file
package com.commit451.gitlab.transition;
/*
* Copyright 2015 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Outline;
import android.graphics.Paint;
import android.graphics.drawable.Drawable;
import android.support.annotation.ColorInt;
import android.support.annotation.NonNull;
import android.util.Property;
/**
* A drawable that can morph size, shape (via it's corner radius) and color. Specifically this is
* useful for animating between a FAB and a dialog.
*/
public class MorphDrawable extends Drawable {
private float cornerRadius;
public static final Property<MorphDrawable, Float> CORNER_RADIUS = new AnimUtils
.FloatProperty<MorphDrawable>("cornerRadius") {
@Override
public void setValue(MorphDrawable morphDrawable, float value) {
morphDrawable.setCornerRadius(value);
}
@Override
public Float get(MorphDrawable morphDrawable) {
return morphDrawable.getCornerRadius();
}
};
private Paint paint;
public static final Property<MorphDrawable, Integer> COLOR = new AnimUtils
.IntProperty<MorphDrawable>("color") {
@Override
public void setValue(MorphDrawable morphDrawable, int value) {
morphDrawable.setColor(value);
}
@Override
public Integer get(MorphDrawable morphDrawable) {
return morphDrawable.getColor();
}
};
public MorphDrawable(@ColorInt int color, float cornerRadius) {
this.cornerRadius = cornerRadius;
paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setColor(color);
}
public float getCornerRadius() {
return cornerRadius;
}
public void setCornerRadius(float cornerRadius) {
this.cornerRadius = cornerRadius;
invalidateSelf();
}
public int getColor() {
return paint.getColor();
}
public void setColor(int color) {
paint.setColor(color);
invalidateSelf();
}
@Override
public void draw(Canvas canvas) {
canvas.drawRoundRect(getBounds().left, getBounds().top, getBounds().right, getBounds()
.bottom, cornerRadius, cornerRadius, paint);
}
@Override
public void getOutline(@NonNull Outline outline) {
outline.setRoundRect(getBounds(), cornerRadius);
}
@Override
public void setAlpha(int alpha) {
paint.setAlpha(alpha);
invalidateSelf();
}
@Override
public void setColorFilter(ColorFilter cf) {
paint.setColorFilter(cf);
invalidateSelf();
}
@Override
public int getOpacity() {
return paint.getAlpha();
}
}
\ No newline at end of file
package com.commit451.gitlab.transition;
/*
* Copyright 2015 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Color;
import android.support.annotation.ColorInt;
import android.transition.ChangeBounds;
import android.transition.TransitionValues;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AnimationUtils;
/**
* A transition that morphs a circle into a rectangle, changing it's background color.
*/
@TargetApi(21)
public class MorphFabToDialog extends ChangeBounds {
private static final String PROPERTY_COLOR = "property_color";
private static final String PROPERTY_CORNER_RADIUS = "property_corner_radius";
private static final String[] TRANSITION_PROPERTIES = {
PROPERTY_COLOR,
PROPERTY_CORNER_RADIUS
};
private
@ColorInt
int startColor = Color.TRANSPARENT;
@ColorInt
int endColor = Color.WHITE;
private int endCornerRadius;
public MorphFabToDialog(@ColorInt int startColor, @ColorInt int endColor, int endCornerRadius) {
super();
setStartColor(startColor);
setEndColor(endColor);
setEndCornerRadius(endCornerRadius);
}
public MorphFabToDialog(Context context, AttributeSet attrs) {
super(context, attrs);
}
public void setStartColor(@ColorInt int startColor) {
this.startColor = startColor;
}
public void setEndColor(@ColorInt int endColor) {
this.endColor = endColor;
}
public void setEndCornerRadius(int endCornerRadius) {
this.endCornerRadius = endCornerRadius;
}
@Override
public String[] getTransitionProperties() {
return TRANSITION_PROPERTIES;
}
@Override
public void captureStartValues(TransitionValues transitionValues) {
super.captureStartValues(transitionValues);
final View view = transitionValues.view;
if (view.getWidth() <= 0 || view.getHeight() <= 0) {
return;
}
transitionValues.values.put(PROPERTY_COLOR, startColor);
transitionValues.values.put(PROPERTY_CORNER_RADIUS, view.getHeight() / 2);
}
@Override
public void captureEndValues(TransitionValues transitionValues) {
super.captureEndValues(transitionValues);
final View view = transitionValues.view;
if (view.getWidth() <= 0 || view.getHeight() <= 0) {
return;
}
transitionValues.values.put(PROPERTY_COLOR, endColor);
transitionValues.values.put(PROPERTY_CORNER_RADIUS, endCornerRadius);
}
@Override
public Animator createAnimator(final ViewGroup sceneRoot,
TransitionValues startValues,
final 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, background.COLOR, endColor);
Animator corners = ObjectAnimator.ofFloat(background, background.CORNER_RADIUS,
endCornerRadius);
// ease in the dialog's child views (slide up & fade_fast in)
if (endValues.view instanceof ViewGroup) {
ViewGroup vg = (ViewGroup) endValues.view;
float offset = vg.getHeight() / 3;
for (int i = 0; i < vg.getChildCount(); i++) {
View v = vg.getChildAt(i);
v.setTranslationY(offset);
v.setAlpha(0f);
v.animate()
.alpha(1f)
.translationY(0f)
.setDuration(150)
.setStartDelay(150)
.setInterpolator(AnimationUtils.loadInterpolator(vg.getContext(),
android.R.interpolator.fast_out_slow_in));
offset *= 1.8f;
}
}
AnimatorSet transition = new AnimatorSet();
transition.playTogether(changeBounds, corners, color);
transition.setDuration(300);
transition.setInterpolator(AnimationUtils.loadInterpolator(sceneRoot.getContext(),
android.R.interpolator.fast_out_slow_in));
return transition;
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment