com.facebook.imagepipeline.common.Priority Java Examples
The following examples show how to use
com.facebook.imagepipeline.common.Priority.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ImagePipelineTest.java From fresco with MIT License | 6 votes |
@Test public void testFetchDecodedImage() { Producer<CloseableReference<CloseableImage>> decodedSequence = mock(Producer.class); when(mProducerSequenceFactory.getDecodedImageProducerSequence(mImageRequest)) .thenReturn(decodedSequence); DataSource<CloseableReference<CloseableImage>> dataSource = mImagePipeline.fetchDecodedImage(mImageRequest, mCallerContext); assertFalse(dataSource.isFinished()); verify(mRequestListener1).onRequestStart(mImageRequest, mCallerContext, "0", false); verify(mRequestListener2).onRequestStart(mImageRequest, mCallerContext, "0", false); ArgumentCaptor<ProducerContext> producerContextArgumentCaptor = ArgumentCaptor.forClass(ProducerContext.class); verify(decodedSequence) .produceResults(any(Consumer.class), producerContextArgumentCaptor.capture()); assertTrue(producerContextArgumentCaptor.getValue().isIntermediateResultExpected()); assertEquals(producerContextArgumentCaptor.getValue().getPriority(), Priority.HIGH); }
Example #2
Source File: PriorityStarvingThrottlingProducer.java From fresco with MIT License | 6 votes |
@Override public int compare(Item<T> o1, Item<T> o2) { Priority p1 = o1.producerContext.getPriority(); Priority p2 = o2.producerContext.getPriority(); if (p1 == p2) { // lower time wins in this case, so minimum value return Double.compare(o1.time, o2.time); } else { // priority ordering is via ordinals if (p1.ordinal() > p2.ordinal()) { // higher priority gets minimum value (pq is min-heap based) return -1; } else { return 1; } } }
Example #3
Source File: SettableProducerContext.java From fresco with MIT License | 6 votes |
public SettableProducerContext( ImageRequest imageRequest, String id, @Nullable String uiComponentId, ProducerListener2 producerListener, Object callerContext, ImageRequest.RequestLevel lowestPermittedRequestLevel, boolean isPrefetch, boolean isIntermediateResultExpected, Priority priority, ImagePipelineConfig imagePipelineConfig) { super( imageRequest, id, uiComponentId, producerListener, callerContext, lowestPermittedRequestLevel, isPrefetch, isIntermediateResultExpected, priority, imagePipelineConfig); }
Example #4
Source File: SettableProducerContext.java From fresco with MIT License | 6 votes |
public SettableProducerContext( ImageRequest imageRequest, String id, ProducerListener2 producerListener, Object callerContext, ImageRequest.RequestLevel lowestPermittedRequestLevel, boolean isPrefetch, boolean isIntermediateResultExpected, Priority priority, ImagePipelineConfig imagePipelineConfig) { super( imageRequest, id, producerListener, callerContext, lowestPermittedRequestLevel, isPrefetch, isIntermediateResultExpected, priority, imagePipelineConfig); }
Example #5
Source File: ImagePipeline.java From FanXin-based-HuanXin with GNU General Public License v2.0 | 6 votes |
private <T> DataSource<CloseableReference<T>> submitFetchRequest( Producer<CloseableReference<T>> producerSequence, ImageRequest imageRequest, Object callerContext) { SettableProducerContext settableProducerContext = new SettableProducerContext( imageRequest, generateUniqueFutureId(), mRequestListener, callerContext, /* isPrefetch */ false, imageRequest.getProgressiveRenderingEnabled() || !UriUtil.isNetworkUri(imageRequest.getSourceUri()), Priority.HIGH); return CloseableProducerToDataSourceAdapter.create( producerSequence, settableProducerContext, mRequestListener); }
Example #6
Source File: ImagePipeline.java From FanXin-based-HuanXin with GNU General Public License v2.0 | 6 votes |
private DataSource<Void> submitPrefetchRequest( Producer<Void> producerSequence, ImageRequest imageRequest, Object callerContext) { SettableProducerContext settableProducerContext = new SettableProducerContext( imageRequest, generateUniqueFutureId(), mRequestListener, callerContext, /* isPrefetch */ true, /* isIntermediateResultExpected */ false, Priority.LOW); return ProducerToDataSourceAdapter.create( producerSequence, settableProducerContext, mRequestListener); }
Example #7
Source File: SettableProducerContext.java From FanXin-based-HuanXin with GNU General Public License v2.0 | 6 votes |
/** * Set the priority of the request * @param priority */ public void setPriority(Priority priority) { List<ProducerContextCallbacks> callbacks = null; synchronized (this) { if (mPriority != priority) { mPriority = priority; callbacks = Lists.newArrayList(mCallbacks); } } if (callbacks != null) { for (ProducerContextCallbacks callback : callbacks) { callback.onPriorityChanged(); } } }
Example #8
Source File: BaseProducerContext.java From fresco with MIT License | 6 votes |
public BaseProducerContext( ImageRequest imageRequest, String id, ProducerListener2 producerListener, Object callerContext, ImageRequest.RequestLevel lowestPermittedRequestLevel, boolean isPrefetch, boolean isIntermediateResultExpected, Priority priority, ImagePipelineConfig imagePipelineConfig) { this( imageRequest, id, null, producerListener, callerContext, lowestPermittedRequestLevel, isPrefetch, isIntermediateResultExpected, priority, imagePipelineConfig); }
Example #9
Source File: ImagePipeline.java From fresco with MIT License | 6 votes |
private DataSource<Void> prefetchToBitmapCache( ImageRequest imageRequest, Object callerContext, Priority priority) { if (!mIsPrefetchEnabledSupplier.get()) { return DataSources.immediateFailedDataSource(PREFETCH_EXCEPTION); } try { final Boolean shouldDecodePrefetches = imageRequest.shouldDecodePrefetches(); final boolean skipBitmapCache = shouldDecodePrefetches != null ? !shouldDecodePrefetches // use imagerequest param if specified : mSuppressBitmapPrefetchingSupplier .get(); // otherwise fall back to pipeline's default Producer<Void> producerSequence = skipBitmapCache ? mProducerSequenceFactory.getEncodedImagePrefetchProducerSequence(imageRequest) : mProducerSequenceFactory.getDecodedImagePrefetchProducerSequence(imageRequest); return submitPrefetchRequest( producerSequence, imageRequest, ImageRequest.RequestLevel.FULL_FETCH, callerContext, priority); } catch (Exception exception) { return DataSources.immediateFailedDataSource(exception); } }
Example #10
Source File: ImagePipeline.java From fresco with MIT License | 6 votes |
/** * Submits a request for prefetching to the disk cache. * * <p>Beware that if your network fetcher doesn't support priorities prefetch requests may slow * down images which are immediately required on screen. * * @param imageRequest the request to submit * @param priority custom priority for the fetch * @return a DataSource that can safely be ignored. */ public DataSource<Void> prefetchToDiskCache( ImageRequest imageRequest, Object callerContext, Priority priority) { if (!mIsPrefetchEnabledSupplier.get()) { return DataSources.immediateFailedDataSource(PREFETCH_EXCEPTION); } try { Producer<Void> producerSequence = mProducerSequenceFactory.getEncodedImagePrefetchProducerSequence(imageRequest); return submitPrefetchRequest( producerSequence, imageRequest, ImageRequest.RequestLevel.FULL_FETCH, callerContext, priority); } catch (Exception exception) { return DataSources.immediateFailedDataSource(exception); } }
Example #11
Source File: ImagePipeline.java From fresco with MIT License | 6 votes |
/** * Submits a request for prefetching to the encoded cache. * * <p>Beware that if your network fetcher doesn't support priorities prefetch requests may slow * down images which are immediately required on screen. * * @param imageRequest the request to submit * @param priority custom priority for the fetch * @return a DataSource that can safely be ignored. */ public DataSource<Void> prefetchToEncodedCache( ImageRequest imageRequest, Object callerContext, Priority priority) { if (!mIsPrefetchEnabledSupplier.get()) { return DataSources.immediateFailedDataSource(PREFETCH_EXCEPTION); } try { Producer<Void> producerSequence = mProducerSequenceFactory.getEncodedImagePrefetchProducerSequence(imageRequest); return submitPrefetchRequest( producerSequence, imageRequest, ImageRequest.RequestLevel.FULL_FETCH, callerContext, priority); } catch (Exception exception) { return DataSources.immediateFailedDataSource(exception); } }
Example #12
Source File: ImageRequestTest.java From fresco with MIT License | 6 votes |
@Test public void testCreatingRequestFromExistingRequest() { ImageRequest original = ImageRequestBuilder.newBuilderWithSource(Uri.parse("http://frescolib.org/image.jpg")) .setCacheChoice(ImageRequest.CacheChoice.SMALL) .setImageDecodeOptions(new ImageDecodeOptionsBuilder().build()) .setLocalThumbnailPreviewsEnabled(true) .setLowestPermittedRequestLevel(ImageRequest.RequestLevel.DISK_CACHE) .setPostprocessor( new BasePostprocessor() { @Override public String getName() { return super.getName(); } }) .setProgressiveRenderingEnabled(true) .setRequestListener(new RequestLoggingListener()) .setResizeOptions(new ResizeOptions(20, 20)) .setRotationOptions(RotationOptions.forceRotation(RotationOptions.ROTATE_90)) .setRequestPriority(Priority.HIGH) .build(); ImageRequest copy = ImageRequestBuilder.fromRequest(original).build(); assertThat(copy).isEqualTo(original); }
Example #13
Source File: PriorityTest.java From fresco with MIT License | 6 votes |
@Test public void testGetHigherPriority() throws Exception { assertEquals(HIGH, Priority.getHigherPriority(null, HIGH)); assertEquals(HIGH, Priority.getHigherPriority(LOW, HIGH)); assertEquals(HIGH, Priority.getHigherPriority(MEDIUM, HIGH)); assertEquals(HIGH, Priority.getHigherPriority(HIGH, HIGH)); assertEquals(HIGH, Priority.getHigherPriority(HIGH, MEDIUM)); assertEquals(HIGH, Priority.getHigherPriority(HIGH, LOW)); assertEquals(HIGH, Priority.getHigherPriority(HIGH, null)); assertEquals(MEDIUM, Priority.getHigherPriority(null, MEDIUM)); assertEquals(MEDIUM, Priority.getHigherPriority(LOW, MEDIUM)); assertEquals(MEDIUM, Priority.getHigherPriority(MEDIUM, MEDIUM)); assertEquals(MEDIUM, Priority.getHigherPriority(MEDIUM, LOW)); assertEquals(MEDIUM, Priority.getHigherPriority(MEDIUM, null)); assertEquals(LOW, Priority.getHigherPriority(null, LOW)); assertEquals(LOW, Priority.getHigherPriority(LOW, LOW)); assertEquals(LOW, Priority.getHigherPriority(LOW, null)); assertEquals(null, Priority.getHigherPriority(null, null)); }
Example #14
Source File: ImagePipelineTest.java From fresco with MIT License | 6 votes |
@Test public void testGetFullFetchSupplier() { Supplier<DataSource<CloseableReference<CloseableImage>>> dataSourceSupplier = mImagePipeline.getDataSourceSupplier( mImageRequest, mCallerContext, ImageRequest.RequestLevel.FULL_FETCH); Producer<CloseableReference<CloseableImage>> decodedSequence = mock(Producer.class); when(mProducerSequenceFactory.getDecodedImageProducerSequence(mImageRequest)) .thenReturn(decodedSequence); DataSource<CloseableReference<CloseableImage>> dataSource = dataSourceSupplier.get(); assertFalse(dataSource.isFinished()); verify(mRequestListener1).onRequestStart(mImageRequest, mCallerContext, "0", false); verify(mRequestListener2).onRequestStart(mImageRequest, mCallerContext, "0", false); ArgumentCaptor<ProducerContext> producerContextArgumentCaptor = ArgumentCaptor.forClass(ProducerContext.class); verify(decodedSequence) .produceResults(any(Consumer.class), producerContextArgumentCaptor.capture()); assertTrue(producerContextArgumentCaptor.getValue().isIntermediateResultExpected()); assertEquals(producerContextArgumentCaptor.getValue().getPriority(), Priority.HIGH); }
Example #15
Source File: SettableProducerContext.java From FanXin-based-HuanXin with GNU General Public License v2.0 | 6 votes |
public SettableProducerContext( ImageRequest imageRequest, String id, ProducerListener producerListener, Object callerContext, boolean isPrefetch, boolean isIntermediateResultExpected, Priority priority) { mImageRequest = Preconditions.checkNotNull(imageRequest); mId = Preconditions.checkNotNull(id); mProducerListener = Preconditions.checkNotNull(producerListener); mCallerContext = callerContext; mIsPrefetch = isPrefetch; mIsIntermediateResultExpected = isIntermediateResultExpected; mPriority = priority; mIsCancelled = false; mCallbacks = Lists.newArrayList(); }
Example #16
Source File: ImagePipelineTest.java From fresco with MIT License | 6 votes |
@Test public void testFetchNetworkEncodedImage() { Producer<CloseableReference<PooledByteBuffer>> encodedSequence = mock(Producer.class); when(mProducerSequenceFactory.getEncodedImageProducerSequence(mImageRequest)) .thenReturn(encodedSequence); when(mImageRequest.getSourceUri()).thenReturn(Uri.parse("http://test")); DataSource<CloseableReference<PooledByteBuffer>> dataSource = mImagePipeline.fetchEncodedImage(mImageRequest, mCallerContext); assertFalse(dataSource.isFinished()); ArgumentCaptor<ImageRequest> argumentCaptor = ArgumentCaptor.forClass(ImageRequest.class); verify(mRequestListener1) .onRequestStart(argumentCaptor.capture(), eq(mCallerContext), eq("0"), eq(false)); ImageRequest capturedImageRequest = argumentCaptor.getValue(); assertSame(mImageRequest.getSourceUri(), capturedImageRequest.getSourceUri()); verify(mRequestListener2) .onRequestStart(argumentCaptor.capture(), eq(mCallerContext), eq("0"), eq(false)); capturedImageRequest = argumentCaptor.getValue(); assertSame(mImageRequest.getSourceUri(), capturedImageRequest.getSourceUri()); ArgumentCaptor<ProducerContext> producerContextArgumentCaptor = ArgumentCaptor.forClass(ProducerContext.class); verify(encodedSequence) .produceResults(any(Consumer.class), producerContextArgumentCaptor.capture()); assertTrue(producerContextArgumentCaptor.getValue().isIntermediateResultExpected()); assertEquals(producerContextArgumentCaptor.getValue().getPriority(), Priority.HIGH); }
Example #17
Source File: ImagePipelineTest.java From fresco with MIT License | 6 votes |
@Test public void testFetchLocalEncodedImage() { Producer<CloseableReference<PooledByteBuffer>> encodedSequence = mock(Producer.class); when(mProducerSequenceFactory.getEncodedImageProducerSequence(mImageRequest)) .thenReturn(encodedSequence); when(mImageRequest.getSourceUri()).thenReturn(Uri.parse("file:///local/file")); DataSource<CloseableReference<PooledByteBuffer>> dataSource = mImagePipeline.fetchEncodedImage(mImageRequest, mCallerContext); assertFalse(dataSource.isFinished()); ArgumentCaptor<ImageRequest> argumentCaptor = ArgumentCaptor.forClass(ImageRequest.class); verify(mRequestListener1) .onRequestStart(argumentCaptor.capture(), eq(mCallerContext), eq("0"), eq(false)); ImageRequest capturedImageRequest = argumentCaptor.getValue(); assertSame(mImageRequest.getSourceUri(), capturedImageRequest.getSourceUri()); verify(mRequestListener2) .onRequestStart(argumentCaptor.capture(), eq(mCallerContext), eq("0"), eq(false)); capturedImageRequest = argumentCaptor.getValue(); assertSame(mImageRequest.getSourceUri(), capturedImageRequest.getSourceUri()); ArgumentCaptor<ProducerContext> producerContextArgumentCaptor = ArgumentCaptor.forClass(ProducerContext.class); verify(encodedSequence) .produceResults(any(Consumer.class), producerContextArgumentCaptor.capture()); assertTrue(producerContextArgumentCaptor.getValue().isIntermediateResultExpected()); assertEquals(producerContextArgumentCaptor.getValue().getPriority(), Priority.HIGH); }
Example #18
Source File: ImagePipelineTest.java From fresco with MIT License | 6 votes |
@Test public void testPrefetchToBitmapCache() { Producer<Void> prefetchProducerSequence = mock(Producer.class); when(mProducerSequenceFactory.getDecodedImagePrefetchProducerSequence(mImageRequest)) .thenReturn(prefetchProducerSequence); DataSource<Void> dataSource = mImagePipeline.prefetchToBitmapCache(mImageRequest, mCallerContext); assertFalse(dataSource.isFinished()); verify(mRequestListener1).onRequestStart(mImageRequest, mCallerContext, "0", true); verify(mRequestListener2).onRequestStart(mImageRequest, mCallerContext, "0", true); ArgumentCaptor<ProducerContext> producerContextArgumentCaptor = ArgumentCaptor.forClass(ProducerContext.class); verify(prefetchProducerSequence) .produceResults(any(Consumer.class), producerContextArgumentCaptor.capture()); assertFalse(producerContextArgumentCaptor.getValue().isIntermediateResultExpected()); assertEquals(producerContextArgumentCaptor.getValue().getPriority(), Priority.MEDIUM); }
Example #19
Source File: ImagePipelineTest.java From fresco with MIT License | 6 votes |
@Test public void testPrefetchToEncodedCacheCustomPriority() { Producer<Void> prefetchProducerSequence = mock(Producer.class); when(mProducerSequenceFactory.getEncodedImagePrefetchProducerSequence(mImageRequest)) .thenReturn(prefetchProducerSequence); DataSource<Void> dataSource = mImagePipeline.prefetchToEncodedCache(mImageRequest, mCallerContext, Priority.MEDIUM); assertFalse(dataSource.isFinished()); verify(mRequestListener1).onRequestStart(mImageRequest, mCallerContext, "0", true); verify(mRequestListener2).onRequestStart(mImageRequest, mCallerContext, "0", true); ArgumentCaptor<ProducerContext> producerContextArgumentCaptor = ArgumentCaptor.forClass(ProducerContext.class); verify(prefetchProducerSequence) .produceResults(any(Consumer.class), producerContextArgumentCaptor.capture()); assertFalse(producerContextArgumentCaptor.getValue().isIntermediateResultExpected()); assertEquals(producerContextArgumentCaptor.getValue().getPriority(), Priority.MEDIUM); }
Example #20
Source File: ImagePipelineTest.java From fresco with MIT License | 6 votes |
@Test public void testPrefetchToEncodedCacheDefaultPriority() { Producer<Void> prefetchProducerSequence = mock(Producer.class); when(mProducerSequenceFactory.getEncodedImagePrefetchProducerSequence(mImageRequest)) .thenReturn(prefetchProducerSequence); DataSource<Void> dataSource = mImagePipeline.prefetchToEncodedCache(mImageRequest, mCallerContext); assertFalse(dataSource.isFinished()); verify(mRequestListener1).onRequestStart(mImageRequest, mCallerContext, "0", true); verify(mRequestListener2).onRequestStart(mImageRequest, mCallerContext, "0", true); ArgumentCaptor<ProducerContext> producerContextArgumentCaptor = ArgumentCaptor.forClass(ProducerContext.class); verify(prefetchProducerSequence) .produceResults(any(Consumer.class), producerContextArgumentCaptor.capture()); assertFalse(producerContextArgumentCaptor.getValue().isIntermediateResultExpected()); assertEquals(producerContextArgumentCaptor.getValue().getPriority(), Priority.MEDIUM); }
Example #21
Source File: ImagePipelineTest.java From fresco with MIT License | 6 votes |
@Test public void testGetBitmapCacheGetSupplier() { Supplier<DataSource<CloseableReference<CloseableImage>>> dataSourceSupplier = mImagePipeline.getDataSourceSupplier( mImageRequest, mCallerContext, ImageRequest.RequestLevel.BITMAP_MEMORY_CACHE); Producer<CloseableReference<CloseableImage>> bitmapCacheSequence = mock(Producer.class); when(mProducerSequenceFactory.getDecodedImageProducerSequence(mImageRequest)) .thenReturn(bitmapCacheSequence); dataSourceSupplier.get(); verify(mRequestListener1).onRequestStart(mImageRequest, mCallerContext, "0", false); verify(mRequestListener2).onRequestStart(mImageRequest, mCallerContext, "0", false); ArgumentCaptor<ProducerContext> producerContextArgumentCaptor = ArgumentCaptor.forClass(ProducerContext.class); verify(bitmapCacheSequence) .produceResults(any(Consumer.class), producerContextArgumentCaptor.capture()); assertTrue(producerContextArgumentCaptor.getValue().isIntermediateResultExpected()); assertEquals(producerContextArgumentCaptor.getValue().getPriority(), Priority.HIGH); }
Example #22
Source File: ImagePipelineTest.java From fresco with MIT License | 6 votes |
@Test public void testFetchFromBitmapCacheDueToImageRequest() { Producer<CloseableReference<CloseableImage>> bitmapCacheSequence = mock(Producer.class); when(mImageRequest.getLowestPermittedRequestLevel()) .thenReturn(ImageRequest.RequestLevel.BITMAP_MEMORY_CACHE); when(mProducerSequenceFactory.getDecodedImageProducerSequence(mImageRequest)) .thenReturn(bitmapCacheSequence); mImagePipeline.fetchDecodedImage(mImageRequest, mCallerContext); verify(mRequestListener1).onRequestStart(mImageRequest, mCallerContext, "0", false); verify(mRequestListener2).onRequestStart(mImageRequest, mCallerContext, "0", false); ArgumentCaptor<ProducerContext> producerContextArgumentCaptor = ArgumentCaptor.forClass(ProducerContext.class); verify(bitmapCacheSequence) .produceResults(any(Consumer.class), producerContextArgumentCaptor.capture()); assertTrue(producerContextArgumentCaptor.getValue().isIntermediateResultExpected()); assertEquals(producerContextArgumentCaptor.getValue().getPriority(), Priority.HIGH); assertEquals( producerContextArgumentCaptor.getValue().getLowestPermittedRequestLevel(), ImageRequest.RequestLevel.BITMAP_MEMORY_CACHE); }
Example #23
Source File: LocalVideoThumbnailProducerTest.java From fresco with MIT License | 6 votes |
@Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); mExecutor = new TestExecutorService(new FakeClock()); mLocalVideoThumbnailProducer = new LocalVideoThumbnailProducer( mExecutor, RuntimeEnvironment.application.getContentResolver()); mFile = new File(RuntimeEnvironment.application.getExternalFilesDir(null), TEST_FILENAME); mockStatic(ThumbnailUtils.class); mProducerContext = new SettableProducerContext( mImageRequest, mRequestId, mProducerListener, mock(Object.class), ImageRequest.RequestLevel.FULL_FETCH, false, false, Priority.MEDIUM, mConfig); when(mImageRequest.getSourceFile()).thenReturn(mFile); mLocalVideoUri = Uri.parse("file:///dancing_hotdog.mp4"); }
Example #24
Source File: SettableProducerContextTest.java From fresco with MIT License | 6 votes |
@Before public void setUp() { mSettableProducerContext = new SettableProducerContext( mImageRequest, mRequestId, mock(ProducerListener2.class), mock(Object.class), ImageRequest.RequestLevel.FULL_FETCH, false, true, Priority.MEDIUM, mConfig); mCallbacks1 = mock(ProducerContextCallbacks.class); mCallbacks2 = mock(ProducerContextCallbacks.class); }
Example #25
Source File: ImagePipelineTest.java From fresco with MIT License | 6 votes |
@Test public void testFetchFromBitmapCacheDueToMethodCall() { Producer<CloseableReference<CloseableImage>> bitmapCacheSequence = mock(Producer.class); when(mProducerSequenceFactory.getDecodedImageProducerSequence(mImageRequest)) .thenReturn(bitmapCacheSequence); mImagePipeline.fetchImageFromBitmapCache(mImageRequest, mCallerContext); verify(mRequestListener1).onRequestStart(mImageRequest, mCallerContext, "0", false); verify(mRequestListener2).onRequestStart(mImageRequest, mCallerContext, "0", false); ArgumentCaptor<ProducerContext> producerContextArgumentCaptor = ArgumentCaptor.forClass(ProducerContext.class); verify(bitmapCacheSequence) .produceResults(any(Consumer.class), producerContextArgumentCaptor.capture()); assertTrue(producerContextArgumentCaptor.getValue().isIntermediateResultExpected()); assertEquals(producerContextArgumentCaptor.getValue().getPriority(), Priority.HIGH); assertEquals( producerContextArgumentCaptor.getValue().getLowestPermittedRequestLevel(), ImageRequest.RequestLevel.BITMAP_MEMORY_CACHE); }
Example #26
Source File: QualifiedResourceFetchProducerTest.java From fresco with MIT License | 6 votes |
@Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); mExecutor = new TestExecutorService(new FakeClock()); mQualifiedResourceFetchProducer = new QualifiedResourceFetchProducer(mExecutor, mPooledByteBufferFactory, mContentResolver); mContentUri = UriUtil.getUriForQualifiedResource(PACKAGE_NAME, RESOURCE_ID); mProducerContext = new SettableProducerContext( mImageRequest, REQUEST_ID, mProducerListener, CALLER_CONTEXT, ImageRequest.RequestLevel.FULL_FETCH, false, true, Priority.MEDIUM, mConfig); when(mImageRequest.getSourceUri()).thenReturn(mContentUri); }
Example #27
Source File: MultiplexProducerTest.java From fresco with MIT License | 5 votes |
@Test public void testAddLowerPriorityDoesNotChangePriority() { mProducerContext1.setPriority(Priority.MEDIUM); mProducerContext2.setPriority(Priority.LOW); mMultiplexProducer.produceResults(mConsumer1, mProducerContext1); assertEquals(Priority.MEDIUM, mMultiplexedContext1.getPriority()); mMultiplexProducer.produceResults(mConsumer1, mProducerContext2); assertEquals(Priority.MEDIUM, mMultiplexedContext1.getPriority()); }
Example #28
Source File: ImagePipelineTest.java From fresco with MIT License | 5 votes |
private void verifyPrefetchToDiskCache( DataSource<Void> dataSource, Producer<Void> prefetchProducerSequence, Priority priority) { assertFalse(dataSource.isFinished()); verify(mRequestListener1).onRequestStart(mImageRequest, mCallerContext, "0", true); verify(mRequestListener2).onRequestStart(mImageRequest, mCallerContext, "0", true); ArgumentCaptor<ProducerContext> producerContextArgumentCaptor = ArgumentCaptor.forClass(ProducerContext.class); verify(prefetchProducerSequence) .produceResults(any(Consumer.class), producerContextArgumentCaptor.capture()); assertFalse(producerContextArgumentCaptor.getValue().isIntermediateResultExpected()); assertEquals(priority, producerContextArgumentCaptor.getValue().getPriority()); }
Example #29
Source File: MultiplexProducerTest.java From fresco with MIT License | 5 votes |
@Test public void testAddHigherPriorityIncreasesPriority() { mProducerContext1.setPriority(Priority.MEDIUM); mProducerContext2.setPriority(Priority.HIGH); mMultiplexProducer.produceResults(mConsumer1, mProducerContext1); assertEquals(Priority.MEDIUM, mMultiplexedContext1.getPriority()); mMultiplexProducer.produceResults(mConsumer1, mProducerContext2); assertEquals(Priority.HIGH, mMultiplexedContext1.getPriority()); }
Example #30
Source File: BaseProducerContext.java From fresco with MIT License | 5 votes |
public BaseProducerContext( ImageRequest imageRequest, String id, @Nullable String uiComponentId, ProducerListener2 producerListener, Object callerContext, ImageRequest.RequestLevel lowestPermittedRequestLevel, boolean isPrefetch, boolean isIntermediateResultExpected, Priority priority, ImagePipelineConfig imagePipelineConfig) { mImageRequest = imageRequest; mId = id; mExtras = new HashMap<>(); mExtras.put("id", mId); mExtras.put("uri_source", imageRequest == null ? "null-request" : imageRequest.getSourceUri()); mUiComponentId = uiComponentId; mProducerListener = producerListener; mCallerContext = callerContext; mLowestPermittedRequestLevel = lowestPermittedRequestLevel; mIsPrefetch = isPrefetch; mPriority = priority; mIsIntermediateResultExpected = isIntermediateResultExpected; mIsCancelled = false; mCallbacks = new ArrayList<>(); mImagePipelineConfig = imagePipelineConfig; }