本文整理汇总了Java中com.bumptech.glide.integration.okhttp3.OkHttpUrlLoader类的典型用法代码示例。如果您正苦于以下问题:Java OkHttpUrlLoader类的具体用法?Java OkHttpUrlLoader怎么用?Java OkHttpUrlLoader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OkHttpUrlLoader类属于com.bumptech.glide.integration.okhttp3包,在下文中一共展示了OkHttpUrlLoader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerComponents
import com.bumptech.glide.integration.okhttp3.OkHttpUrlLoader; //导入依赖的package包/类
@Override public void registerComponents(Context context, Glide glide) {
Stetho.initializeWithDefaults(context);
final Cache cache = new Cache(new File(context.getCacheDir(), "okhttp"), IMAGE_CACHE_SIZE);
HttpLoggingInterceptor logger = new HttpLoggingInterceptor();
// logger.setLevel(Level.BASIC);
OkHttpClient client = new OkHttpClient()
.newBuilder()
.cache(cache)
.addNetworkInterceptor(new StethoInterceptor())
.addInterceptor(logger)
.build();
glide.register(CachedGlideUrl.class, InputStream.class,
superFactory(new OkHttpUrlLoader.Factory(client), CachedGlideUrl.class));
glide.register(ForceLoadGlideUrl.class, InputStream.class,
superFactory(new OkHttpUrlLoader.Factory(client), ForceLoadGlideUrl.class));
}
示例2: registerComponents
import com.bumptech.glide.integration.okhttp3.OkHttpUrlLoader; //导入依赖的package包/类
@Override
public void registerComponents(Context context, Glide glide) {
final File cacheDir = new File(BaseApplication.get().getCacheDir(), "ToshiImageCache");
final Cache cache = new Cache(cacheDir, MAX_SIZE);
final OkHttpClient client =
new OkHttpClient().newBuilder()
.cache(cache)
.addInterceptor(new AppInfoUserAgentInterceptor())
.addInterceptor(new HttpLoggingInterceptor(new LoggingInterceptor()).setLevel(HttpLoggingInterceptor.Level.BODY))
.build();
glide.register(CachedGlideUrl.class, InputStream.class, superFactory(new OkHttpUrlLoader.Factory(client), CachedGlideUrl.class));
glide.register(ForceLoadGlideUrl.class, InputStream.class, superFactory(new OkHttpUrlLoader.Factory(client), ForceLoadGlideUrl.class));
}
示例3: registerComponents
import com.bumptech.glide.integration.okhttp3.OkHttpUrlLoader; //导入依赖的package包/类
@Override
public void registerComponents(Context context, Glide glide) {
//配置OkHttp
OkHttpClient mOkHttpClient = new OkHttpClient()
.newBuilder()
.connectTimeout(15, TimeUnit.SECONDS)
.readTimeout(15, TimeUnit.SECONDS)
.build();
//设置Glide请求为Okhttp
glide.register(GlideUrl.class, InputStream.class,
new OkHttpUrlLoader.Factory(mOkHttpClient));
//设置Glide的内存缓存和BitmapPool使用最多他们初始值的最大大小的一半
glide.setMemoryCategory(MemoryCategory.LOW);
}
示例4: onCreate
import com.bumptech.glide.integration.okhttp3.OkHttpUrlLoader; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
// Flog是自定义Log
if (BuildConfig.DEBUG) {
Flog.DebugTree tree = new Flog.DebugTree();
tree.setShowLine(false); // 是否打印类名和行号
Flog.plant(tree);
}
OkHttpClient okHttpClient = new OkHttpClient();
//配置Fresco
ImagePipelineConfig config = OkHttpImagePipelineConfigFactory
.newBuilder(this, okHttpClient)
.build();
Fresco.initialize(this, config);
Glide.get(this).register(GlideUrl.class, InputStream.class,
new OkHttpUrlLoader.Factory(okHttpClient));
}
示例5: getUserPhoto
import com.bumptech.glide.integration.okhttp3.OkHttpUrlLoader; //导入依赖的package包/类
public void getUserPhoto(Activity activity, String userID, ImageView view, int defaultResID, int maxSize, String lastModify) {
if (userID == null || userID.isEmpty()) {
return;
}
if (mFactory == null) {
mFactory = new OkHttpUrlLoader.Factory(mUserDataProvider.getOkHttpClient());
Glide.get(mActivity).register(GlideUrl.class, InputStream.class,
mFactory);
}
String url = mUserDataProvider.getUserPhotoUrl(userID);
if (url != null) {
if (view.getTag() == null) {
new GlidePhotoData(activity, view, defaultResID, lastModify, maxSize, mSubDomain, url);
} else {
new GlidePhotoData(activity, view, lastModify, maxSize, mSubDomain, url);
}
}
}
示例6: Factory
import com.bumptech.glide.integration.okhttp3.OkHttpUrlLoader; //导入依赖的package包/类
public Factory(Context context) {
okHttpFactory = new OkHttpUrlLoader.Factory(new OkHttpClient.Builder()
.connectTimeout(TIMEOUT, TimeUnit.MILLISECONDS)
.readTimeout(TIMEOUT, TimeUnit.MILLISECONDS)
.writeTimeout(TIMEOUT, TimeUnit.MILLISECONDS)
.build());
lastFMClient = new LastFMRestClient(LastFMRestClient.createDefaultOkHttpClientBuilder(context)
.connectTimeout(TIMEOUT, TimeUnit.MILLISECONDS)
.readTimeout(TIMEOUT, TimeUnit.MILLISECONDS)
.writeTimeout(TIMEOUT, TimeUnit.MILLISECONDS)
.build());
}
示例7: init
import com.bumptech.glide.integration.okhttp3.OkHttpUrlLoader; //导入依赖的package包/类
public static void init(Glide glide, OkHttpClient okHttpClient) {
OkHttpClient.Builder builder;
if (okHttpClient != null) {
builder = okHttpClient.newBuilder();
} else {
builder = new OkHttpClient.Builder();
}
builder.addNetworkInterceptor(createInterceptor(new DispatchingProgressListener()));
glide.getRegistry().replace(GlideUrl.class, InputStream.class,
new OkHttpUrlLoader.Factory(builder.build()));
}
示例8: registerComponents
import com.bumptech.glide.integration.okhttp3.OkHttpUrlLoader; //导入依赖的package包/类
@Override
public void registerComponents(Context context, Glide glide, Registry registry) {
HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BASIC);
OkHttpClient client = new OkHttpClient.Builder()
.readTimeout(30, TimeUnit.SECONDS)
.connectTimeout(30, TimeUnit.SECONDS)
.addInterceptor(loggingInterceptor)
.build();
registry.replace(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(client));
}
示例9: registerComponents
import com.bumptech.glide.integration.okhttp3.OkHttpUrlLoader; //导入依赖的package包/类
@Override
public void registerComponents(Context context, Glide glide) {
OkHttpClient client = new OkHttpClient
.Builder()
.addInterceptor(createInterceptor(new DispatchingProgressListener()))
.build();
glide.register(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(client));
}
示例10: init
import com.bumptech.glide.integration.okhttp3.OkHttpUrlLoader; //导入依赖的package包/类
public static void init(Glide glide, OkHttpClient okHttpClient) {
OkHttpClient.Builder builder;
if (okHttpClient != null) {
builder = okHttpClient.newBuilder();
} else {
builder = new OkHttpClient.Builder();
}
builder.addNetworkInterceptor(createInterceptor(new DispatchingProgressListener()));
glide.register(GlideUrl.class, InputStream.class,
new OkHttpUrlLoader.Factory(builder.build()));
}
示例11: provideGlide
import com.bumptech.glide.integration.okhttp3.OkHttpUrlLoader; //导入依赖的package包/类
@Singleton
@Provides
public RequestManager provideGlide() {
OkHttpUrlLoader.Factory factory = new OkHttpUrlLoader.Factory(mOkHttpClient);
Glide.get(app).register(GlideUrl.class, InputStream.class, factory);
return Glide.with(app);
}
示例12: registerComponents
import com.bumptech.glide.integration.okhttp3.OkHttpUrlLoader; //导入依赖的package包/类
@Override
public void registerComponents(Context context, Glide glide, Registry registry) {
registry.replace(
GlideUrl.class,
InputStream.class,
new OkHttpUrlLoader.Factory(
request -> GlobalApplication.getOkHttpClient().newCall(request)
)
);
}
示例13: load2
import com.bumptech.glide.integration.okhttp3.OkHttpUrlLoader; //导入依赖的package包/类
@Override protected void load2(Context context, ImageView imageView) throws Exception {
Glide
.with(this)
.using(new StreamModelLoaderWrapper<>(new OkHttpUrlLoader(longTimeoutClient)))
.load(new GlideUrl("https://httpbin.org/delay/12")) // timeout increased: 15 > 10, so it'll pass
.signature(new StringSignature("load2")) // distinguish from other load to make sure loader is picked up
.placeholder(R.drawable.glide_placeholder)
// since the test URL returns a JSON stream, the load will fail,
// let's still add an error to see that the load fails slower than the other,
// meaning the image was actually tried to be decoded
.error(R.drawable.glide_error)
.listener(new LoggingListener<GlideUrl, GlideDrawable>("load2"))
.into(new LoggingTarget<>("load2", Log.VERBOSE, new GlideDrawableImageViewTarget(imageView)))
;
}
示例14: provideGlide
import com.bumptech.glide.integration.okhttp3.OkHttpUrlLoader; //导入依赖的package包/类
@Singleton
@Provides
RequestManager provideGlide(OkHttpClient okHttpClient) {
OkHttpUrlLoader.Factory factory = new OkHttpUrlLoader.Factory(okHttpClient);
Glide.get(mView).register(GlideUrl.class, InputStream.class, factory);
return Glide.with(mView);
}
示例15: onCreate
import com.bumptech.glide.integration.okhttp3.OkHttpUrlLoader; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
Glide.get(this).register(GlideUrl.class
, InputStream.class
, new OkHttpUrlLoader.Factory(RetrofitClient.getOkHttpClient(this)));
LocalDisplay.init(this);
}