/** * Sets the drawable to be used to fill the area below the line. * * @param drawable */ @TargetApi(18) public void setFillDrawable(Drawable drawable) { this.mFillDrawable = drawable; }
@TargetApi(11) private void copyOptions11(Options srcOptions, Options destOptions) { destOptions.inBitmap = srcOptions.inBitmap; destOptions.inMutable = srcOptions.inMutable; }
@TargetApi(10) private void copyOptions10(Options srcOptions, Options destOptions) { destOptions.inPreferQualityOverSpeed = srcOptions.inPreferQualityOverSpeed; }
@TargetApi(Build.VERSION_CODES.O) private static void assertNotHardwareConfig(Bitmap.Config config) { // Avoid short circuiting on sdk int since it breaks on some versions of Android. if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) { return; } if (config == Bitmap.Config.HARDWARE) { throw new IllegalArgumentException("Cannot create a mutable Bitmap with config: " + config + ". Consider setting Downsampler#ALLOW_HARDWARE_CONFIG to false in your RequestOptions" + " and/or in GlideBuilder.setDefaultRequestOptions"); } }
@TargetApi(Build.VERSION_CODES.HONEYCOMB) private static boolean isLargeHeap(Context context) { return (context.getApplicationInfo().flags & ApplicationInfo.FLAG_LARGE_HEAP) != 0; }
/** * Returns the current time in either millis or nanos depending on the api level to be used with * {@link #getElapsedMillis(long)}. */ @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) public static long getLogTime() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { return SystemClock.elapsedRealtimeNanos(); } else { return SystemClock.uptimeMillis(); } }
@TargetApi(Build.VERSION_CODES.KITKAT) private static void maybeSetPreMultiplied(Bitmap bitmap) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { bitmap.setPremultiplied(true); } }
@Nullable @TargetApi(Build.VERSION_CODES.KITKAT) private static String getBitmapString(Bitmap bitmap) { if (bitmap == null) { return null; } String sizeString = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT ? " (" + bitmap.getAllocationByteCount() + ")" : ""; return "[" + bitmap.getWidth() + "x" + bitmap.getHeight() + "] " + bitmap.getConfig() + sizeString; }
@Nullable @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) private Fragment getParentFragmentUsingHint() { final Fragment fragment; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { fragment = getParentFragment(); } else { fragment = null; } return fragment != null ? fragment : parentFragmentHint; }
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) private static void assertNotDestroyed(@NonNull Activity activity) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && activity.isDestroyed()) { throw new IllegalArgumentException("You cannot start a load for a destroyed activity"); } }
@TargetApi(M) private boolean hasStoragePermission() { if (SDK_INT < M) { return true; } // Once true, this won't change for the life of the process so we can cache it. if (writeExternalStorageGranted) { return true; } writeExternalStorageGranted = context.checkSelfPermission(WRITE_EXTERNAL_STORAGE) == PERMISSION_GRANTED; return writeExternalStorageGranted; }
@TargetApi(Build.VERSION_CODES.O) private static Set<Bitmap.Config> getDefaultAllowedConfigs() { Set<Bitmap.Config> configs = new HashSet<>(Arrays.asList(Bitmap.Config.values())); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { // GIFs, among other types, end up with a native Bitmap config that doesn't map to a java // config and is treated as null in java code. On KitKat+ these Bitmaps can be reconfigured // and are suitable for re-use. configs.add(null); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { configs.remove(Bitmap.Config.HARDWARE); } return Collections.unmodifiableSet(configs); }
@TargetApi(16) private static void postOnAnimationJellyBean(View view, Runnable runnable) { view.postOnAnimation(runnable); } }
@TargetApi(Build.VERSION_CODES.FROYO) private InputStream getVideoThumbnailStream(String filePath) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) { Bitmap bitmap = ThumbnailUtils .createVideoThumbnail(filePath, MediaStore.Images.Thumbnails.FULL_SCREEN_KIND); if (bitmap != null) { ByteArrayOutputStream bos = new ByteArrayOutputStream(); bitmap.compress(CompressFormat.PNG, 0, bos); return new ByteArrayInputStream(bos.toByteArray()); } } return null; }
@TargetApi(Build.VERSION_CODES.HONEYCOMB) private static int getLargeMemoryClass(ActivityManager am) { return am.getLargeMemoryClass(); }
@TargetApi(23) private static void configureEditModeLogoV23(Resources resources, ImageView logo) { logo.setImageDrawable(resources.getDrawable(R.drawable.exo_edit_mode_logo, null)); logo.setBackgroundColor(resources.getColor(R.color.exo_edit_mode_background_color, null)); }
@TargetApi(Build.VERSION_CODES.N_MR1) public static void disablePostShortcut(@NonNull Context context) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N_MR1) return; ShortcutManager shortcutManager = context.getSystemService(ShortcutManager.class); shortcutManager.disableShortcuts(DYNAMIC_SHORTCUT_IDS); }
@TargetApi(Build.VERSION_CODES.N_MR1) public static void reportPostUsed(@NonNull Context context) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N_MR1) return; ShortcutManager shortcutManager = context.getSystemService(ShortcutManager.class); shortcutManager.reportShortcutUsed(POST_SHORTCUT_ID); }
@TargetApi(Build.VERSION_CODES.N_MR1) public static void reportSearchUsed(@NonNull Context context) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N_MR1) return; ShortcutManager shortcutManager = context.getSystemService(ShortcutManager.class); shortcutManager.reportShortcutUsed(SEARCH_SHORTCUT_ID); }
@TargetApi(23) private static int getMaxSupportedInstancesV23(CodecCapabilities capabilities) { return capabilities.getMaxSupportedInstances(); } }