static HardwareConfigState getInstance() { if (instance == null) { synchronized (HardwareConfigState.class) { if (instance == null) { instance = new HardwareConfigState(); } } } return instance; }
@TargetApi(Build.VERSION_CODES.O) @SuppressWarnings("deprecation") boolean setHardwareConfigIfAllowed( int targetWidth, int targetHeight, BitmapFactory.Options optionsWithScaling, DecodeFormat decodeFormat, boolean isHardwareConfigAllowed, boolean isExifOrientationRequired) { if (!isHardwareConfigAllowed || Build.VERSION.SDK_INT < Build.VERSION_CODES.O || isExifOrientationRequired) { return false; } boolean result = targetWidth >= MIN_HARDWARE_DIMENSION && targetHeight >= MIN_HARDWARE_DIMENSION // Make sure to call isFdSizeBelowHardwareLimit last because it has side affects. && isFdSizeBelowHardwareLimit(); if (result) { optionsWithScaling.inPreferredConfig = Bitmap.Config.HARDWARE; optionsWithScaling.inMutable = false; } return result; }
int targetHeight) { if (hardwareConfigState.setHardwareConfigIfAllowed( targetWidth, targetHeight,
throws IOException { if (hardwareConfigState.setHardwareConfigIfAllowed( targetWidth, targetHeight,
static HardwareConfigState getInstance() { if (instance == null) { synchronized (HardwareConfigState.class) { if (instance == null) { instance = new HardwareConfigState(); } } } return instance; }
@TargetApi(Build.VERSION_CODES.O) @SuppressWarnings("deprecation") boolean setHardwareConfigIfAllowed( int targetWidth, int targetHeight, BitmapFactory.Options optionsWithScaling, DecodeFormat decodeFormat, boolean isHardwareConfigAllowed, boolean isExifOrientationRequired) { if (!isHardwareConfigAllowed || Build.VERSION.SDK_INT < Build.VERSION_CODES.O || decodeFormat == DecodeFormat.PREFER_ARGB_8888_DISALLOW_HARDWARE || isExifOrientationRequired) { return false; } boolean result = targetWidth >= MIN_HARDWARE_DIMENSION && targetHeight >= MIN_HARDWARE_DIMENSION // Make sure to call isFdSizeBelowHardwareLimit last because it has side affects. && isFdSizeBelowHardwareLimit(); if (result) { optionsWithScaling.inPreferredConfig = Bitmap.Config.HARDWARE; optionsWithScaling.inMutable = false; } return result; }