List of usage examples for android.animation ValueAnimator setCurrentFraction
public void setCurrentFraction(float fraction)
From source file:com.android.deskclock.AnimatorUtils.java
public static void setAnimatedFraction(ValueAnimator animator, float fraction) { if (Utils.isLMR1OrLater()) { animator.setCurrentFraction(fraction); return;/* w ww. j a v a2s . c om*/ } if (sTryAnimateValue) { // try to set the animated fraction directly so that it isn't affected by the // internal animator scale or time (b/17938711) try { if (sAnimateValue == null) { sAnimateValue = ValueAnimator.class.getDeclaredMethod("animateValue", float.class); sAnimateValue.setAccessible(true); } sAnimateValue.invoke(animator, fraction); return; } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { // something went wrong, don't try that again LogUtils.e("Unable to use animateValue directly", e); sTryAnimateValue = false; } } // if that doesn't work then just fall back to setting the current play time animator.setCurrentPlayTime(Math.round(fraction * animator.getDuration())); }
From source file:com.android.clear.reminder.AnimatorUtils.java
public static void setAnimatedFraction(ValueAnimator animator, float fraction) { if (Utils.isLMR1OrLater()) { animator.setCurrentFraction(fraction); return;// www. j a v a2 s. co m } if (sTryAnimateValue) { // try to set the animated fraction directly so that it isn't affected by the // internal animator scale or time (b/17938711) try { if (sAnimateValue == null) { sAnimateValue = ValueAnimator.class.getDeclaredMethod("animateValue", float.class); sAnimateValue.setAccessible(true); } sAnimateValue.invoke(animator, fraction); return; } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { // something went wrong, don't try that again L.e("Unable to use animateValue directly", e); sTryAnimateValue = false; } } // if that doesn't work then just fall back to setting the current play time animator.setCurrentPlayTime(Math.round(fraction * animator.getDuration())); }