@RequiresApi(11) public ChartAnimator(AnimatorUpdateListener listener) { mListener = listener; }
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP) private class OutlineProvider extends ViewOutlineProvider { @Override public void getOutline(View view, Outline outline) { Rect bounds = new Rect(); mBorderRect.roundOut(bounds); outline.setRoundRect(bounds, bounds.width() / 2.0f); } }
@RequiresApi(11) private ObjectAnimator yAnimator(int duration, EasingFunction easing) { ObjectAnimator animatorY = ObjectAnimator.ofFloat(this, "phaseY", 0f, 1f); animatorY.setInterpolator(easing); animatorY.setDuration(duration); return animatorY; }
@RequiresApi(11) private ObjectAnimator xAnimator(int duration, EasingFunction easing) { ObjectAnimator animatorX = ObjectAnimator.ofFloat(this, "phaseX", 0f, 1f); animatorX.setInterpolator(easing); animatorX.setDuration(duration); return animatorX; }
/** * Animates values along the X axis, in a linear fashion. * * @param durationMillis animation duration */ @RequiresApi(11) public void animateX(int durationMillis) { animateX(durationMillis, Easing.Linear); }
/** * Animates the rendering of the chart on the x-axis with the specified * animation time. If animate(...) is called, no further calling of * invalidate() is necessary to refresh the chart. ANIMATIONS ONLY WORK FOR * API LEVEL 11 (Android 3.0.x) AND HIGHER. * * @param durationMillis */ @RequiresApi(11) public void animateX(int durationMillis) { mAnimator.animateX(durationMillis); }
/** * Animates values along both the X and Y axes, in a linear fashion. * * @param durationMillisX animation duration along the X axis * @param durationMillisY animation duration along the Y axis */ @RequiresApi(11) public void animateXY(int durationMillisX, int durationMillisY) { animateXY(durationMillisX, durationMillisY, Easing.Linear, Easing.Linear); }
/** * Animates values along the Y axis, in a linear fashion. * * @param durationMillis animation duration */ @RequiresApi(11) public void animateY(int durationMillis) { animateY(durationMillis, Easing.Linear); }
/** * Animates the rendering of the chart on the y-axis with the specified * animation time. If animate(...) is called, no further calling of * invalidate() is necessary to refresh the chart. ANIMATIONS ONLY WORK FOR * API LEVEL 11 (Android 3.0.x) AND HIGHER. * * @param durationMillis */ @RequiresApi(11) public void animateY(int durationMillis) { mAnimator.animateY(durationMillis); }
/** * Animates the rendering of the chart on the x-axis with the specified * animation time. If animate(...) is called, no further calling of * invalidate() is necessary to refresh the chart. ANIMATIONS ONLY WORK FOR * API LEVEL 11 (Android 3.0.x) AND HIGHER. * * @param durationMillis * @param easing a custom easing function to be used on the animation phase */ @RequiresApi(11) public void animateX(int durationMillis, EasingFunction easing) { mAnimator.animateX(durationMillis, easing); }
/** * Animates the drawing / rendering of the chart on both x- and y-axis with * the specified animation time. If animate(...) is called, no further * calling of invalidate() is necessary to refresh the chart. ANIMATIONS * ONLY WORK FOR API LEVEL 11 (Android 3.0.x) AND HIGHER. * * @param durationMillisX * @param durationMillisY */ @RequiresApi(11) public void animateXY(int durationMillisX, int durationMillisY) { mAnimator.animateXY(durationMillisX, durationMillisY); }
/** * Animates the rendering of the chart on the y-axis with the specified * animation time. If animate(...) is called, no further calling of * invalidate() is necessary to refresh the chart. ANIMATIONS ONLY WORK FOR * API LEVEL 11 (Android 3.0.x) AND HIGHER. * * @param durationMillis * @param easing a custom easing function to be used on the animation phase */ @RequiresApi(11) public void animateY(int durationMillis, EasingFunction easing) { mAnimator.animateY(durationMillis, easing); }
/** * Animates the drawing / rendering of the chart on both x- and y-axis with * the specified animation time. If animate(...) is called, no further * calling of invalidate() is necessary to refresh the chart. ANIMATIONS * ONLY WORK FOR API LEVEL 11 (Android 3.0.x) AND HIGHER. * * @param durationMillisX * @param durationMillisY * @param easing a custom easing function to be used on the animation phase */ @RequiresApi(11) public void animateXY(int durationMillisX, int durationMillisY, EasingFunction easing) { mAnimator.animateXY(durationMillisX, durationMillisY, easing); }
/** * Animates the drawing / rendering of the chart on both x- and y-axis with * the specified animation time. If animate(...) is called, no further * calling of invalidate() is necessary to refresh the chart. ANIMATIONS * ONLY WORK FOR API LEVEL 11 (Android 3.0.x) AND HIGHER. * * @param durationMillisX * @param durationMillisY * @param easingX a custom easing function to be used on the animation phase * @param easingY a custom easing function to be used on the animation phase */ @RequiresApi(11) public void animateXY(int durationMillisX, int durationMillisY, EasingFunction easingX, EasingFunction easingY) { mAnimator.animateXY(durationMillisX, durationMillisY, easingX, easingY); }
/** * Animates values along the Y axis. * * @param durationMillis animation duration * @param easing EasingFunction */ @RequiresApi(11) public void animateY(int durationMillis, EasingFunction easing) { ObjectAnimator animatorY = yAnimator(durationMillis, easing); animatorY.addUpdateListener(mListener); animatorY.start(); }
/** * Animates values along the X axis. * * @param durationMillis animation duration * @param easing EasingFunction */ @RequiresApi(11) public void animateX(int durationMillis, EasingFunction easing) { ObjectAnimator animatorX = xAnimator(durationMillis, easing); animatorX.addUpdateListener(mListener); animatorX.start(); }
@RequiresApi(28) private static Bitmap decodeResourceP(Context context, final Request request) throws IOException { ImageDecoder.Source imageSource = ImageDecoder.createSource(context.getResources(), request.resourceId); return decodeImageSource(imageSource, request); }
@RequiresApi(28) @SuppressLint("Override") private static Bitmap decodeStreamP(Request request, BufferedSource bufferedSource) throws IOException { ImageDecoder.Source imageSource = ImageDecoder.createSource(ByteBuffer.wrap(bufferedSource.readByteArray())); return decodeImageSource(imageSource, request); }
/** * Animates values along both the X and Y axes. * * @param durationMillisX animation duration along the X axis * @param durationMillisY animation duration along the Y axis * @param easing EasingFunction for both axes */ @RequiresApi(11) public void animateXY(int durationMillisX, int durationMillisY, EasingFunction easing) { ObjectAnimator xAnimator = xAnimator(durationMillisX, easing); ObjectAnimator yAnimator = yAnimator(durationMillisY, easing); if (durationMillisX > durationMillisY) { xAnimator.addUpdateListener(mListener); } else { yAnimator.addUpdateListener(mListener); } xAnimator.start(); yAnimator.start(); }
@RequiresApi(Build.VERSION_CODES.LOLLIPOP) private static int getNativeFileDescriptor(FileDescriptor fileDescriptor, boolean closeOriginalDescriptor) throws GifIOException, ErrnoException { try { final int nativeFileDescriptor = createTempNativeFileDescriptor(); Os.dup2(fileDescriptor, nativeFileDescriptor); return nativeFileDescriptor; } finally { if (closeOriginalDescriptor) { Os.close(fileDescriptor); } } }