public static PlatformDecoder buildPlatformDecoder()

in imagepipeline/src/main/java/com/facebook/imagepipeline/platform/PlatformDecoderFactory.java [30:66]


  public static PlatformDecoder buildPlatformDecoder(
      PoolFactory poolFactory, boolean gingerbreadDecoderEnabled, boolean useDecodeBufferHelper) {

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
      return new OreoDecoder(
          poolFactory.getBitmapPool(), createPool(poolFactory, useDecodeBufferHelper));
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP
        || !NativeCodeSetup.getUseNativeCode()) {
      return new ArtDecoder(
          poolFactory.getBitmapPool(), createPool(poolFactory, useDecodeBufferHelper));
    } else {
      try {
        if (gingerbreadDecoderEnabled && Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
          Class<?> clazz =
              Class.forName("com.facebook.imagepipeline.platform.GingerbreadPurgeableDecoder");
          return (PlatformDecoder) clazz.getConstructor().newInstance();
        } else {
          Class<?> clazz =
              Class.forName("com.facebook.imagepipeline.platform.KitKatPurgeableDecoder");
          return (PlatformDecoder)
              clazz
                  .getConstructor(FlexByteArrayPool.class)
                  .newInstance(poolFactory.getFlexByteArrayPool());
        }
      } catch (ClassNotFoundException e) {
        throw new RuntimeException("Wrong Native code setup, reflection failed.", e);
      } catch (IllegalAccessException e) {
        throw new RuntimeException("Wrong Native code setup, reflection failed.", e);
      } catch (NoSuchMethodException e) {
        throw new RuntimeException("Wrong Native code setup, reflection failed.", e);
      } catch (InvocationTargetException e) {
        throw new RuntimeException("Wrong Native code setup, reflection failed.", e);
      } catch (InstantiationException e) {
        throw new RuntimeException("Wrong Native code setup, reflection failed.", e);
      }
    }
  }