Skip to content

Commit

Permalink
Added downsampleEnabled to LocalFetchProducer to return memory backed…
Browse files Browse the repository at this point in the history
… encoded images when not downsampling
  • Loading branch information
lukkm authored and tyronen committed Jul 20, 2015
1 parent e6a8436 commit 189a962
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public static BranchOnSeparateImagesProducer newBranchOnSeparateImagesProducer(
}

public DataFetchProducer newDataFetchProducer() {
return new DataFetchProducer(mPooledByteBufferFactory);
return new DataFetchProducer(mPooledByteBufferFactory, mDownsampleEnabled);
}

public DecodeProducer newDecodeProducer(Producer<EncodedImage> nextProducer) {
Expand Down Expand Up @@ -179,13 +179,15 @@ public LocalAssetFetchProducer newLocalAssetFetchProducer() {
return new LocalAssetFetchProducer(
mExecutorSupplier.forLocalStorageRead(),
mPooledByteBufferFactory,
mDownsampleEnabled,
mAssetManager);
}

public LocalContentUriFetchProducer newContentUriFetchProducer() {
return new LocalContentUriFetchProducer(
mExecutorSupplier.forLocalStorageRead(),
mPooledByteBufferFactory,
mDownsampleEnabled,
mContentResolver);
}

Expand All @@ -198,13 +200,15 @@ public LocalExifThumbnailProducer newLocalExifThumbnailProducer() {
public LocalFileFetchProducer newLocalFileFetchProducer() {
return new LocalFileFetchProducer(
mExecutorSupplier.forLocalStorageRead(),
mPooledByteBufferFactory);
mPooledByteBufferFactory,
mDownsampleEnabled);
}

public LocalResourceFetchProducer newLocalResourceFetchProducer() {
return new LocalResourceFetchProducer(
mExecutorSupplier.forLocalStorageRead(),
mPooledByteBufferFactory,
mDownsampleEnabled,
mResources);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ public class DataFetchProducer extends LocalFetchProducer {
private static final String PRODUCER_NAME = "DataFetchProducer";

public DataFetchProducer(
PooledByteBufferFactory pooledByteBufferFactory) {
super(CallerThreadExecutor.getInstance(), pooledByteBufferFactory);
PooledByteBufferFactory pooledByteBufferFactory,
boolean downsampleEnabled) {
super(CallerThreadExecutor.getInstance(), pooledByteBufferFactory, downsampleEnabled);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ public class LocalAssetFetchProducer extends LocalFetchProducer {
public LocalAssetFetchProducer(
Executor executor,
PooledByteBufferFactory pooledByteBufferFactory,
boolean downsampleEnabled,
AssetManager assetManager) {
super(executor, pooledByteBufferFactory);
super(executor, pooledByteBufferFactory, downsampleEnabled);
mAssetManager = assetManager;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ public class LocalContentUriFetchProducer extends LocalFetchProducer {
public LocalContentUriFetchProducer(
Executor executor,
PooledByteBufferFactory pooledByteBufferFactory,
boolean downsampleEnabled,
ContentResolver contentResolver) {
super(executor, pooledByteBufferFactory);
super(executor, pooledByteBufferFactory, downsampleEnabled);
mContentResolver = contentResolver;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,15 @@ public abstract class LocalFetchProducer implements Producer<EncodedImage> {

private final Executor mExecutor;
private final PooledByteBufferFactory mPooledByteBufferFactory;
private final boolean mDownsampleEnabled;

protected LocalFetchProducer(
Executor executor,
PooledByteBufferFactory pooledByteBufferFactory) {
PooledByteBufferFactory pooledByteBufferFactory,
boolean downsampleEnabled) {
mExecutor = executor;
mPooledByteBufferFactory = pooledByteBufferFactory;
mDownsampleEnabled = downsampleEnabled;
}

@Override
Expand All @@ -53,7 +56,7 @@ public void produceResults(
protected EncodedImage getResult() throws Exception {
EncodedImage encodedImage = getEncodedImage(imageRequest);
encodedImage.parseMetaData();
if (EncodedImage.isMetaDataAvailable(encodedImage)) {
if (mDownsampleEnabled && EncodedImage.isMetaDataAvailable(encodedImage)) {
encodedImage.setSampleSize(
DownsampleUtil.determineSampleSize(imageRequest, encodedImage));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ public class LocalFileFetchProducer extends LocalFetchProducer {

public LocalFileFetchProducer(
Executor executor,
PooledByteBufferFactory pooledByteBufferFactory) {
super(executor, pooledByteBufferFactory);
PooledByteBufferFactory pooledByteBufferFactory,
boolean downsampleEnabled) {
super(executor, pooledByteBufferFactory, downsampleEnabled);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ public class LocalResourceFetchProducer extends LocalFetchProducer {
public LocalResourceFetchProducer(
Executor executor,
PooledByteBufferFactory pooledByteBufferFactory,
boolean downsampleEnabled,
Resources resources) {
super(executor, pooledByteBufferFactory);
super(executor, pooledByteBufferFactory, downsampleEnabled);
mResources = resources;
}

Expand Down

0 comments on commit 189a962

Please sign in to comment.