当前位置: 首页>>代码示例>>Java>>正文


Java OkHttpUrlLoader类代码示例

本文整理汇总了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));
	}
 
开发者ID:TWiStErRob,项目名称:glide-support,代码行数:20,代码来源:GlideModule.java

示例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));
}
 
开发者ID:toshiapp,项目名称:toshi-android-client,代码行数:17,代码来源:GlideOkHttpStack.java

示例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);
}
 
开发者ID:HotBitmapGG,项目名称:LeisureRead,代码行数:18,代码来源:GlideModuleSetting.java

示例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));
}
 
开发者ID:ChoicesWang,项目名称:DesignDemo,代码行数:22,代码来源:MyApplication.java

示例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);
        }
    }
}
 
开发者ID:BioStar2,项目名称:BioStar2Android,代码行数:19,代码来源:PhotoUserAdapter.java

示例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());
}
 
开发者ID:aliumujib,项目名称:Orin,代码行数:13,代码来源:ArtistImageLoader.java

示例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()));
}
 
开发者ID:alphater,项目名称:garras,代码行数:12,代码来源:GlideProgressSupport.java

示例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));
}
 
开发者ID:YMlion,项目名称:leisure-glance,代码行数:12,代码来源:GankGlideModule.java

示例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));
}
 
开发者ID:DylanVann,项目名称:react-native-fast-image,代码行数:9,代码来源:OkHttpProgressGlideModule.java

示例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()));
}
 
开发者ID:hkq325800,项目名称:YellowNote,代码行数:12,代码来源:GlideProgressSupport.java

示例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);
}
 
开发者ID:xdtianyu,项目名称:Kindle,代码行数:8,代码来源:AppModule.java

示例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)
            )
    );
}
 
开发者ID:moko256,项目名称:twicalico,代码行数:11,代码来源:GlideModule.java

示例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)))
	;
}
 
开发者ID:TWiStErRob,项目名称:glide-support,代码行数:16,代码来源:TestFragment.java

示例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);
}
 
开发者ID:xdtianyu,项目名称:Gallery,代码行数:8,代码来源:ViewerModule.java

示例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);
}
 
开发者ID:ayaseruri,项目名称:luxunPro,代码行数:11,代码来源:MApplication.java


注:本文中的com.bumptech.glide.integration.okhttp3.OkHttpUrlLoader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。