本文整理汇总了Java中com.facebook.imagepipeline.listener.RequestListener类的典型用法代码示例。如果您正苦于以下问题:Java RequestListener类的具体用法?Java RequestListener怎么用?Java RequestListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RequestListener类属于com.facebook.imagepipeline.listener包,在下文中一共展示了RequestListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ImagePipeline
import com.facebook.imagepipeline.listener.RequestListener; //导入依赖的package包/类
public ImagePipeline(
ProducerSequenceFactory producerSequenceFactory,
Set<RequestListener> requestListeners,
Supplier<Boolean> isPrefetchEnabledSupplier,
MemoryCache<CacheKey, CloseableImage> bitmapMemoryCache,
MemoryCache<CacheKey, PooledByteBuffer> encodedMemoryCache,
BufferedDiskCache mainBufferedDiskCache,
BufferedDiskCache smallImageBufferedDiskCache,
CacheKeyFactory cacheKeyFactory,
ThreadHandoffProducerQueue threadHandoffProducerQueue,
Supplier<Boolean> suppressBitmapPrefetchingSupplier) {
mIdCounter = new AtomicLong();
mProducerSequenceFactory = producerSequenceFactory;
mRequestListener = new ForwardingRequestListener(requestListeners);
mIsPrefetchEnabledSupplier = isPrefetchEnabledSupplier;
mBitmapMemoryCache = bitmapMemoryCache;
mEncodedMemoryCache = encodedMemoryCache;
mMainBufferedDiskCache = mainBufferedDiskCache;
mSmallImageBufferedDiskCache = smallImageBufferedDiskCache;
mCacheKeyFactory = cacheKeyFactory;
mThreadHandoffProducerQueue = threadHandoffProducerQueue;
mSuppressBitmapPrefetchingSupplier = suppressBitmapPrefetchingSupplier;
}
示例2: getDefaultConfigBuilder
import com.facebook.imagepipeline.listener.RequestListener; //导入依赖的package包/类
/**
* Get the default Fresco configuration builder.
* Allows adding of configuration options in addition to the default values.
*
* @return {@link ImagePipelineConfig.Builder} that has been initialized with default values
*/
public static ImagePipelineConfig.Builder getDefaultConfigBuilder(ReactContext context) {
HashSet<RequestListener> requestListeners = new HashSet<>();
requestListeners.add(new SystraceRequestListener());
OkHttpClient client = OkHttpClientProvider.createClient();
// make sure to forward cookies for any requests via the okHttpClient
// so that image requests to endpoints that use cookies still work
CookieJarContainer container = (CookieJarContainer) client.cookieJar();
ForwardingCookieHandler handler = new ForwardingCookieHandler(context);
container.setCookieJar(new JavaNetCookieJar(handler));
return OkHttpImagePipelineConfigFactory
.newBuilder(context.getApplicationContext(), client)
.setNetworkFetcher(new ReactOkHttpNetworkFetcher(client))
.setDownsampleEnabled(false)
.setRequestListeners(requestListeners);
}
示例3: getDefaultConfig
import com.facebook.imagepipeline.listener.RequestListener; //导入依赖的package包/类
private static ImagePipelineConfig getDefaultConfig(
Context context,
@Nullable RequestListener listener,
@Nullable DiskCacheConfig diskCacheConfig) {
HashSet<RequestListener> requestListeners = new HashSet<>();
requestListeners.add(new SystraceRequestListener());
if (listener != null) {
requestListeners.add(listener);
}
OkHttpClient okHttpClient = OkHttpClientProvider.getOkHttpClient();
ImagePipelineConfig.Builder builder =
OkHttpImagePipelineConfigFactory.newBuilder(context.getApplicationContext(), okHttpClient);
builder
.setDownsampleEnabled(false)
.setRequestListeners(requestListeners);
if (diskCacheConfig != null) {
builder.setMainDiskCacheConfig(diskCacheConfig);
}
return builder.build();
}
示例4: create
import com.facebook.imagepipeline.listener.RequestListener; //导入依赖的package包/类
public static <T> DataSource<CloseableReference<T>> create(
Producer<CloseableReference<T>> producer,
SettableProducerContext settableProducerContext,
RequestListener listener) {
return new CloseableProducerToDataSourceAdapter<T>(
producer, settableProducerContext, listener);
}
示例5: AbstractProducerToDataSourceAdapter
import com.facebook.imagepipeline.listener.RequestListener; //导入依赖的package包/类
protected AbstractProducerToDataSourceAdapter(
Producer<T> producer,
SettableProducerContext settableProducerContext,
RequestListener requestListener) {
mSettableProducerContext = settableProducerContext;
mRequestListener = requestListener;
mRequestListener.onRequestStart(
settableProducerContext.getImageRequest(),
mSettableProducerContext.getCallerContext(),
mSettableProducerContext.getId(),
mSettableProducerContext.isPrefetch());
producer.produceResults(createConsumer(), settableProducerContext);
}
示例6: create
import com.facebook.imagepipeline.listener.RequestListener; //导入依赖的package包/类
public static <T> DataSource<T> create(
Producer<T> producer,
SettableProducerContext settableProducerContext,
RequestListener listener) {
return new ProducerToDataSourceAdapter<T>(
producer,
settableProducerContext,
listener);
}
示例7: submitFetchRequest
import com.facebook.imagepipeline.listener.RequestListener; //导入依赖的package包/类
private <T> DataSource<CloseableReference<T>> submitFetchRequest(
Producer<CloseableReference<T>> producerSequence,
ImageRequest imageRequest,
ImageRequest.RequestLevel lowestPermittedRequestLevelOnSubmit,
Object callerContext) {
final RequestListener requestListener = getRequestListenerForRequest(imageRequest);
try {
ImageRequest.RequestLevel lowestPermittedRequestLevel =
ImageRequest.RequestLevel.getMax(
imageRequest.getLowestPermittedRequestLevel(),
lowestPermittedRequestLevelOnSubmit);
SettableProducerContext settableProducerContext = new SettableProducerContext(
imageRequest,
generateUniqueFutureId(),
requestListener,
callerContext,
lowestPermittedRequestLevel,
/* isPrefetch */ false,
imageRequest.getProgressiveRenderingEnabled() ||
imageRequest.getMediaVariations() != null ||
!UriUtil.isNetworkUri(imageRequest.getSourceUri()),
imageRequest.getPriority());
return CloseableProducerToDataSourceAdapter.create(
producerSequence,
settableProducerContext,
requestListener);
} catch (Exception exception) {
return DataSources.immediateFailedDataSource(exception);
}
}
示例8: submitPrefetchRequest
import com.facebook.imagepipeline.listener.RequestListener; //导入依赖的package包/类
private DataSource<Void> submitPrefetchRequest(
Producer<Void> producerSequence,
ImageRequest imageRequest,
ImageRequest.RequestLevel lowestPermittedRequestLevelOnSubmit,
Object callerContext,
Priority priority) {
final RequestListener requestListener = getRequestListenerForRequest(imageRequest);
try {
ImageRequest.RequestLevel lowestPermittedRequestLevel =
ImageRequest.RequestLevel.getMax(
imageRequest.getLowestPermittedRequestLevel(),
lowestPermittedRequestLevelOnSubmit);
SettableProducerContext settableProducerContext = new SettableProducerContext(
imageRequest,
generateUniqueFutureId(),
requestListener,
callerContext,
lowestPermittedRequestLevel,
/* isPrefetch */ true,
/* isIntermediateResultExpected */ false,
priority);
return ProducerToDataSourceAdapter.create(
producerSequence,
settableProducerContext,
requestListener);
} catch (Exception exception) {
return DataSources.immediateFailedDataSource(exception);
}
}
示例9: setUp
import com.facebook.imagepipeline.listener.RequestListener; //导入依赖的package包/类
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mRequestListener1 = mock(RequestListener.class);
mRequestListener2 = mock(RequestListener.class);
mRequestListener3 = mock(RequestListener.class);
when(mRequestListener1.requiresExtraMap(mRequestId)).thenReturn(false);
when(mRequestListener2.requiresExtraMap(mRequestId)).thenReturn(false);
when(mRequestListener3.requiresExtraMap(mRequestId)).thenReturn(false);
mListenerManager = new ForwardingRequestListener(
Sets.newHashSet(mRequestListener1, mRequestListener2, mRequestListener3));
}
示例10: setUp
import com.facebook.imagepipeline.listener.RequestListener; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
mPrefetchEnabledSupplier = mock(Supplier.class);
mSuppressBitmapPrefetchingSupplier = mock(Supplier.class);
when(mPrefetchEnabledSupplier.get()).thenReturn(true);
when(mSuppressBitmapPrefetchingSupplier.get()).thenReturn(false);
mRequestListener1 = mock(RequestListener.class);
mRequestListener2 = mock(RequestListener.class);
mBitmapMemoryCache = mock(MemoryCache.class);
mEncodedMemoryCache = mock(MemoryCache.class);
mMainDiskStorageCache = mock(BufferedDiskCache.class);
mSmallImageDiskStorageCache = mock(BufferedDiskCache.class);
mThreadHandoffProducerQueue= mock(ThreadHandoffProducerQueue.class);
mImagePipeline = new ImagePipeline(
mProducerSequenceFactory,
Sets.newHashSet(mRequestListener1, mRequestListener2),
mPrefetchEnabledSupplier,
mBitmapMemoryCache,
mEncodedMemoryCache,
mMainDiskStorageCache,
mSmallImageDiskStorageCache,
mCacheKeyFactory,
mThreadHandoffProducerQueue,
mSuppressBitmapPrefetchingSupplier);
when(mImageRequest.getProgressiveRenderingEnabled()).thenReturn(true);
when(mImageRequest.getPriority()).thenReturn(Priority.HIGH);
when(mImageRequest.getLowestPermittedRequestLevel())
.thenReturn(ImageRequest.RequestLevel.FULL_FETCH);
}
示例11: testLocalRequestListenerIsCalled
import com.facebook.imagepipeline.listener.RequestListener; //导入依赖的package包/类
@Test
public void testLocalRequestListenerIsCalled() {
RequestListener localRequestListner = mock(RequestListener.class);
when(mImageRequest.getRequestListener()).thenReturn(localRequestListner);
Producer<CloseableReference<CloseableImage>> bitmapCacheSequence = mock(Producer.class);
when(mProducerSequenceFactory.getDecodedImageProducerSequence(mImageRequest))
.thenReturn(bitmapCacheSequence);
mImagePipeline.fetchImageFromBitmapCache(mImageRequest, mCallerContext);
verify(localRequestListner).onRequestStart(mImageRequest, mCallerContext, "0", false);
verify(mRequestListener1).onRequestStart(mImageRequest, mCallerContext, "0", false);
verify(mRequestListener2).onRequestStart(mImageRequest, mCallerContext, "0", false);
}
示例12: onCreate
import com.facebook.imagepipeline.listener.RequestListener; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
FLog.setMinimumLoggingLevel(FLog.VERBOSE);
Set<RequestListener> listeners = new HashSet<>();
listeners.add(new RequestLoggingListener());
ImagePipelineConfig config = ImagePipelineConfig.newBuilder(this)
.setRequestListeners(listeners)
.build();
Fresco.initialize(this, config);
}
示例13: onCreate
import com.facebook.imagepipeline.listener.RequestListener; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
Set<RequestListener> requestListeners = new HashSet<>();
requestListeners.add(new RequestLoggingListener());
ImagePipelineConfig config = ImagePipelineConfig.newBuilder(this)
// other setters
.setRequestListeners(requestListeners)
.build();
Fresco.initialize(this, config);
FLog.setMinimumLoggingLevel(FLog.VERBOSE);
}
示例14: getDefaultConfig
import com.facebook.imagepipeline.listener.RequestListener; //导入依赖的package包/类
private static ImagePipelineConfig getDefaultConfig(Context context) {
HashSet<RequestListener> requestListeners = new HashSet<>();
requestListeners.add(new SystraceRequestListener());
return OkHttpImagePipelineConfigFactory
.newBuilder(context.getApplicationContext(), OkHttpClientProvider.getOkHttpClient())
.setDownsampleEnabled(false)
.setRequestListeners(requestListeners)
.build();
}
示例15: initialize
import com.facebook.imagepipeline.listener.RequestListener; //导入依赖的package包/类
private void initialize() {
mApplication = this;
mContext = this.getApplicationContext();
mResources = this.getResources();
Builder builder = Logcat.newBuilder();
builder.logCatLogLevel(Logcat.SHOW_VERBOSE_LOG);
// builder.logCatLogLevel(Logcat.NOT_SHOW_LOG);
// Logcat.initialize(this, builder.build());
Logcat.initialize(this);
if (IS_DEBUG_ACTIVITYLIFE) {
mActivityLifecycle = new MyActivityLifecycle();
this.registerActivityLifecycleCallbacks(mActivityLifecycle);
}
//
Set<RequestListener> requestListeners = new HashSet<>();
requestListeners.add(new RequestLoggingListener());
ImagePipelineConfig config = ImagePipelineConfig.newBuilder(this)
// other setters
.setRequestListeners(requestListeners)
//配置图片磁盘缓存
.setMainDiskCacheConfig(DiskCacheConfig.newBuilder(this)
.setBaseDirectoryName("image") //父目录下的文件夹名
.setBaseDirectoryPath(StorageUtils.getAppCacheFile(this)) //保存父目录
.build())
.build();
Fresco.initialize(this, config);
FLog.setMinimumLoggingLevel(FLog.DEBUG);
try {
CrashHandler crashHandler = CrashHandler.getInstance();
crashHandler.init(this, Config.CARSH_LOG_PATH);
} catch (Exception e) {
e.printStackTrace();
}
}