Skip to content

Commit

Permalink
Don't build factories on the wrong platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
tyronen committed Jul 20, 2015
1 parent edee9cc commit 1b1103a
Showing 1 changed file with 23 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import android.app.ActivityManager;
import android.content.Context;
import android.graphics.Rect;
import android.os.Build;

import com.facebook.cache.disk.DiskCacheConfig;
import com.facebook.common.internal.Preconditions;
Expand Down Expand Up @@ -158,18 +159,8 @@ public Boolean get() {
builder.mExecutorSupplier == null ?
new DefaultExecutorSupplier(decodeThreads) : builder.mExecutorSupplier;

GingerbreadBitmapFactory factoryGingerbread = new GingerbreadBitmapFactory();
DalvikBitmapFactory factoryICS = new DalvikBitmapFactory(
new EmptyJpegGenerator(mPoolFactory.getPooledByteBufferFactory()),
mPoolFactory.getFlexByteArrayPool(),
isDownsampleEnabled());
ArtBitmapFactory factoryLollipop =
new ArtBitmapFactory(mPoolFactory.getBitmapPool(), decodeThreads, isDownsampleEnabled());
mPlatformBitmapFactory =
new PlatformBitmapFactory(
factoryGingerbread,
factoryICS,
factoryLollipop);
buildPlatformBitmapFactory(mPoolFactory, decodeThreads, mDownsampleEnabled);

AnimatedDrawableBackendProvider animatedDrawableBackendProvider =
new AnimatedDrawableBackendProvider() {
Expand All @@ -189,6 +180,27 @@ public AnimatedDrawableBackend get(AnimatedImageResult imageResult, Rect bounds)

}

private static PlatformBitmapFactory buildPlatformBitmapFactory(
PoolFactory poolFactory,
int decodeThreads,
boolean downsampleEnabled) {
GingerbreadBitmapFactory factoryGingerbread =
Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB ?
new GingerbreadBitmapFactory() : null;
DalvikBitmapFactory factoryICS = new DalvikBitmapFactory(
new EmptyJpegGenerator(poolFactory.getPooledByteBufferFactory()),
poolFactory.getFlexByteArrayPool(),
downsampleEnabled);
ArtBitmapFactory factoryLollipop =
Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ?
new ArtBitmapFactory(poolFactory.getBitmapPool(), decodeThreads, downsampleEnabled) :
null;
return new PlatformBitmapFactory(
factoryGingerbread,
factoryICS,
factoryLollipop);
}

private static DiskCacheConfig getDefaultMainDiskCacheConfig(final Context context) {
return DiskCacheConfig.newBuilder()
.setBaseDirectoryPathSupplier(
Expand Down

0 comments on commit 1b1103a

Please sign in to comment.