Add InterpolatorUtils

This commit is contained in:
seven332 committed 2015-05-07 14:22:57 +08:00
1 parent a20565f1b2
commit 95a724e5d4
4 files changed
+36 -12

No files matched your search

@@ -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;
@@ -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();
}
@@ -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);
@@ -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(