/** * 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(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"); } }
/** * 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.ICE_CREAM_SANDWICH) protected InputStream getContactPhotoStream(Uri uri) { ContentResolver res = context.getContentResolver(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { return ContactsContract.Contacts.openContactPhotoInputStream(res, uri, true); } else { return ContactsContract.Contacts.openContactPhotoInputStream(res, uri); } }
@TargetApi(19) @Override public void useImmersiveMode (boolean use) { if (!use || getVersion() < Build.VERSION_CODES.KITKAT) return; View view = getWindow().getDecorView(); try { Method m = View.class.getMethod("setSystemUiVisibility", int.class); int code = View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; m.invoke(view, code); } catch (Exception e) { log("AndroidApplication", "Can't set immersive mode", e); } }
@TargetApi(19) @Override public void useImmersiveMode (boolean use) { if (!use || getVersion() < Build.VERSION_CODES.KITKAT) return; View view = getWindow().getDecorView(); try { Method m = View.class.getMethod("setSystemUiVisibility", int.class); int code = View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; m.invoke(view, code); } catch (Exception e) { log("AndroidApplication", "Can't set immersive mode", e); } }
@TargetApi(Build.VERSION_CODES.KITKAT) @Synthetic static boolean isLowMemoryDevice(ActivityManager activityManager) { // Explicitly check with an if statement, on some devices both parts of boolean expressions // can be evaluated even if we'd normally expect a short circuit. //noinspection SimplifiableIfStatement if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { return activityManager.isLowRamDevice(); } else { return true; } }
@TargetApi(19) @Override public void useImmersiveMode (boolean use) { if (!use || getVersion() < Build.VERSION_CODES.KITKAT) return; try { View view = this.graphics.getView(); Method m = View.class.getMethod("setSystemUiVisibility", int.class); int code = View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; m.invoke(view, code); } catch (Exception e) { log("AndroidApplication", "Failed to setup immersive mode, a throwable has occurred.", e); } }
@TargetApi(19) @Override public void useImmersiveMode (boolean use) { if (!use || getVersion() < Build.VERSION_CODES.KITKAT) return; try { View view = this.graphics.getView(); Method m = View.class.getMethod("setSystemUiVisibility", int.class); int code = View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; m.invoke(view, code); } catch (Exception e) { log("AndroidApplication", "Failed to setup immersive mode, a throwable has occurred.", e); } }
/** * Returns true if the fragment is a descendant of our parent. */ @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) private boolean isDescendant(@NonNull Fragment fragment) { Fragment root = getParentFragment(); Fragment parentFragment; while ((parentFragment = fragment.getParentFragment()) != null) { if (parentFragment.equals(root)) { return true; } fragment = fragment.getParentFragment(); } return false; }
@TargetApi(11) void ensureProcessorRunningLocked(boolean reportStarted) { if (mCurProcessor == null) { mCurProcessor = new CommandProcessor(); if (mCompatWorkEnqueuer != null && reportStarted) { mCompatWorkEnqueuer.serviceProcessingStarted(); } if (DEBUG) Log.d(TAG, "Starting processor: " + mCurProcessor); mCurProcessor.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } }
@TargetApi(Build.VERSION_CODES.GINGERBREAD) @SuppressWarnings("unused") @Override public void onCreate() { if (Constants.Config.DEVELOPER_MODE && Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) { StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().penaltyDialog().build()); StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyDeath().build()); } super.onCreate(); initImageLoader(getApplicationContext()); }