diff options
Diffstat (limited to 'src/com/android/tv/ui/ViewUtils.java')
-rw-r--r-- | src/com/android/tv/ui/ViewUtils.java | 53 |
1 files changed, 25 insertions, 28 deletions
diff --git a/src/com/android/tv/ui/ViewUtils.java b/src/com/android/tv/ui/ViewUtils.java index ac181752..f64a70b2 100644 --- a/src/com/android/tv/ui/ViewUtils.java +++ b/src/com/android/tv/ui/ViewUtils.java @@ -21,13 +21,10 @@ import android.animation.ValueAnimator; import android.util.Log; import android.view.View; import android.view.ViewGroup.LayoutParams; - import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -/** - * A class that includes convenience methods for view classes. - */ +/** A class that includes convenience methods for view classes. */ public class ViewUtils { private static final String TAG = "ViewUtils"; @@ -40,49 +37,49 @@ public class ViewUtils { try { method = View.class.getDeclaredMethod("setTransitionAlpha", Float.TYPE); method.invoke(v, alpha); - } catch (NoSuchMethodException|IllegalAccessException|IllegalArgumentException - |InvocationTargetException e) { + } catch (NoSuchMethodException + | IllegalAccessException + | IllegalArgumentException + | InvocationTargetException e) { Log.e(TAG, "Fail to call View.setTransitionAlpha", e); } } /** * Creates an animator in view's height + * * @param target the {@link view} animator performs on. */ public static Animator createHeightAnimator( final View target, int initialHeight, int targetHeight) { ValueAnimator animator = ValueAnimator.ofInt(initialHeight, targetHeight); - animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { - @Override - public void onAnimationUpdate(ValueAnimator animation) { - int value = (Integer) animation.getAnimatedValue(); - if (value == 0) { - if (target.getVisibility() != View.GONE) { - target.setVisibility(View.GONE); + animator.addUpdateListener( + new ValueAnimator.AnimatorUpdateListener() { + @Override + public void onAnimationUpdate(ValueAnimator animation) { + int value = (Integer) animation.getAnimatedValue(); + if (value == 0) { + if (target.getVisibility() != View.GONE) { + target.setVisibility(View.GONE); + } + } else { + if (target.getVisibility() != View.VISIBLE) { + target.setVisibility(View.VISIBLE); + } + setLayoutHeight(target, value); + } } - } else { - if (target.getVisibility() != View.VISIBLE) { - target.setVisibility(View.VISIBLE); - } - setLayoutHeight(target, value); - } - } - }); + }); return animator; } - /** - * Gets view's layout height. - */ + /** Gets view's layout height. */ public static int getLayoutHeight(View view) { LayoutParams layoutParams = view.getLayoutParams(); return layoutParams.height; } - /** - * Sets view's layout height. - */ + /** Sets view's layout height. */ public static void setLayoutHeight(View view, int height) { LayoutParams layoutParams = view.getLayoutParams(); if (height != layoutParams.height) { @@ -90,4 +87,4 @@ public class ViewUtils { view.setLayoutParams(layoutParams); } } -}
\ No newline at end of file +} |