diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryListScene.java b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryListScene.java index 28fc7df29..89f9ab751 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryListScene.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryListScene.java @@ -25,19 +25,18 @@ import android.os.Bundle; import android.os.Parcelable; import android.support.annotation.NonNull; import android.support.annotation.Nullable; -import android.support.v4.view.animation.FastOutLinearInInterpolator; import android.support.v7.widget.RecyclerView; import android.util.SparseArray; import android.view.View; import android.view.ViewGroup; import android.view.ViewTreeObserver; -import android.view.animation.Interpolator; import com.hippo.animation.SimpleAnimatorListener; import com.hippo.drawable.AddDeleteDrawable; import com.hippo.effect.ViewTransition; import com.hippo.ehviewer.R; import com.hippo.ehviewer.ui.ContentActivity; +import com.hippo.util.InterpolatorUtils; import com.hippo.ehviewer.widget.ContentLayout; import com.hippo.ehviewer.widget.OffsetLayout; import com.hippo.ehviewer.widget.SearchBar; @@ -66,8 +65,6 @@ public class GalleryListScene extends Scene implements SearchBar.Helper, private final static int FAB_STATE_NORMAL = 0; private final static int FAB_STATE_SEARCH = 1; - private final static Interpolator FAST_OUT_LINEAR_IN_INTERPOLATOR = new FastOutLinearInInterpolator(); - private ContentActivity mActivity; private Resources mResources; private SearchDatabase mSearchDatabase; @@ -210,7 +207,7 @@ public class GalleryListScene extends Scene implements SearchBar.Helper, PropertyValuesHolder scaleYPvh = PropertyValuesHolder.ofFloat("scaleY", 1f, 0f); ObjectAnimator oa = ObjectAnimator.ofPropertyValuesHolder(mCornerFab, scaleXPvh, scaleYPvh); oa.setDuration(ANIMATE_TIME / 2); - oa.setInterpolator(FAST_OUT_LINEAR_IN_INTERPOLATOR); + oa.setInterpolator(InterpolatorUtils.SLOW_FAST_INTERPOLATOR); oa.setRepeatCount(1); oa.setRepeatMode(ValueAnimator.REVERSE); final Drawable finalDrawable = drawable; diff --git a/app/src/main/java/com/hippo/util/InterpolatorUtils.java b/app/src/main/java/com/hippo/util/InterpolatorUtils.java new file mode 100644 index 000000000..f08a0b6c3 --- /dev/null +++ b/app/src/main/java/com/hippo/util/InterpolatorUtils.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2015 Hippo Seven + * + * 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 + * 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. + */ + +package com.hippo.util; + +import android.support.v4.view.animation.FastOutLinearInInterpolator; +import android.support.v4.view.animation.FastOutSlowInInterpolator; +import android.support.v4.view.animation.LinearOutSlowInInterpolator; +import android.view.animation.Interpolator; + +public final class InterpolatorUtils { + + public static final Interpolator FAST_SLOW_INTERPOLATOR = new LinearOutSlowInInterpolator(); + public static final Interpolator SLOW_FAST_INTERPOLATOR = new FastOutLinearInInterpolator(); + public static final Interpolator SLOW_FAST_SLOW_INTERPOLATOR = new FastOutSlowInInterpolator(); +} diff --git a/app/src/main/java/com/hippo/widget/CheckTextView.java b/app/src/main/java/com/hippo/widget/CheckTextView.java index 92171dede..5982c2493 100644 --- a/app/src/main/java/com/hippo/widget/CheckTextView.java +++ b/app/src/main/java/com/hippo/widget/CheckTextView.java @@ -30,6 +30,7 @@ import android.view.View; import android.view.View.OnClickListener; import android.widget.TextView; +import com.hippo.util.InterpolatorUtils; import com.hippo.util.MathUtils; public class CheckTextView extends TextView implements OnClickListener, Hotspotable { @@ -133,9 +134,11 @@ public class CheckTextView extends TextView implements OnClickListener, Hotspota if (mChecked) { radiusAnim = ObjectAnimator.ofFloat(this, "radius", 0f, mMaxRadius); + radiusAnim.setInterpolator(InterpolatorUtils.FAST_SLOW_INTERPOLATOR); } else { radiusAnim = ObjectAnimator.ofFloat(this, "radius", mMaxRadius, 0f); + radiusAnim.setInterpolator(InterpolatorUtils.SLOW_FAST_INTERPOLATOR); } radiusAnim.setDuration(ANIMATION_DURATION); // TODO decide duration according to mMaxRadius radiusAnim.addListener(mAnimatorListener); diff --git a/app/src/main/java/com/hippo/widget/FabLayout.java b/app/src/main/java/com/hippo/widget/FabLayout.java index 6192fc1ed..e5a2c7672 100644 --- a/app/src/main/java/com/hippo/widget/FabLayout.java +++ b/app/src/main/java/com/hippo/widget/FabLayout.java @@ -23,8 +23,6 @@ import android.os.Build; import android.os.Bundle; import android.os.Parcelable; import android.support.annotation.NonNull; -import android.support.v4.view.animation.FastOutLinearInInterpolator; -import android.support.v4.view.animation.LinearOutSlowInInterpolator; import android.util.AttributeSet; import android.view.View; import android.view.ViewGroup; @@ -32,12 +30,10 @@ import android.view.animation.Interpolator; import com.hippo.animation.SimpleAnimatorListener; import com.hippo.ehviewer.R; +import com.hippo.util.InterpolatorUtils; public class FabLayout extends ViewGroup implements View.OnClickListener { - private final static Interpolator LINEAR_OUT_SLOW_IN_INTERPOLATOR = new LinearOutSlowInInterpolator(); - private final static Interpolator FAST_OUT_LINEAR_IN_INTERPOLATOR = new FastOutLinearInInterpolator(); - private static long ANIMATE_TIME = 300l; private static final String STATE_KEY_SUPER = "super"; @@ -276,14 +272,14 @@ public class FabLayout extends ViewGroup implements View.OnClickListener { endTranslationY = 0f; startAlpha = 0f; endAlpha = 1f; - interpolator = LINEAR_OUT_SLOW_IN_INTERPOLATOR; + interpolator = InterpolatorUtils.FAST_SLOW_INTERPOLATOR; } else { startTranslationY = 0f; endTranslationY = mMainFabCenterY - (child.getTop() + (child.getHeight() / 2)); startAlpha = 1f; endAlpha = 0f; - interpolator = FAST_OUT_LINEAR_IN_INTERPOLATOR; + interpolator = InterpolatorUtils.SLOW_FAST_INTERPOLATOR; } PropertyValuesHolder translationYPvh = PropertyValuesHolder.ofFloat(