Java 类com.bumptech.glide.integration.okhttp3.OkHttpUrlLoader 实例源码

项目:glide-support    文件:GlideModule.java   
@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));
    }
项目:toshi-android-client    文件:GlideOkHttpStack.java   
@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));
}
项目:LeisureRead    文件:GlideModuleSetting.java   
@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);
}
项目:DesignDemo    文件:MyApplication.java   
@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));
}
项目:BioStar2Android    文件:PhotoUserAdapter.java   
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);
        }
    }
}
项目:Orin    文件:ArtistImageLoader.java   
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());
}
项目:garras    文件:GlideProgressSupport.java   
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()));
}
项目:leisure-glance    文件:GankGlideModule.java   
@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));
}
项目:react-native-fast-image    文件:OkHttpProgressGlideModule.java   
@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));
}
项目:RetroMusicPlayer    文件:ArtistImageLoader.java   
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());
}
项目:YellowNote    文件:GlideProgressSupport.java   
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()));
}
项目:Kindle    文件:AppModule.java   
@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);
}
项目:twicalico    文件:GlideModule.java   
@Override
public void registerComponents(Context context, Glide glide, Registry registry) {
    registry.replace(
            GlideUrl.class,
            InputStream.class,
            new OkHttpUrlLoader.Factory(
                    request -> GlobalApplication.getOkHttpClient().newCall(request)
            )
    );
}
项目:glide-support    文件:TestFragment.java   
@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)))
    ;
}
项目:BigImageViewer    文件:GlideProgressSupport.java   
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()));
}
项目:Gallery    文件:ViewerModule.java   
@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);
}
项目:Gallery    文件:MainModule.java   
@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);
}
项目:noefinderlein    文件:GlideProgressSupport.java   
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()));
}
项目:BigImageViewer-master    文件:GlideProgressSupport.java   
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()));
}
项目:luxunPro    文件:MApplication.java   
@Override
public void onCreate() {
    super.onCreate();

    Glide.get(this).register(GlideUrl.class
            , InputStream.class
            , new OkHttpUrlLoader.Factory(RetrofitClient.getOkHttpClient(this)));

    LocalDisplay.init(this);
}
项目:Phonograph    文件:ArtistImageLoader.java   
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());
}
项目:BioStar2Android    文件:PhotoUserAdapter.java   
public PhotoUserAdapter(Activity context, ArrayList<ListUser> items, ListView listView, OnItemClickListener onItemClickListener, Popup popup, BaseListAdapter.OnItemsListener onUsersListener) {
    super(context, items, listView, onItemClickListener, popup, onUsersListener);
    mPermissionDataProvider = PermissionDataProvider.getInstance(context);

    mSubDomain = (String)ConfigDataProvider.getLocalStorage(LocalStorage.SUBDOMAIN);
    if (mFactory == null) {
        mFactory = new OkHttpUrlLoader.Factory(mUserDataProvider.getOkHttpClient());
        Glide.get(mActivity).register(GlideUrl.class, InputStream.class,
                mFactory);
    }
    if (mPermissionDataProvider.getLoginUserInfo() == null) {
        return;
    }
    mLoginedUserID = mPermissionDataProvider.getLoginUserInfo().user_id;
}
项目:ProgressManager    文件:GlideConfiguration.java   
@Override
public void registerComponents(Context context, Glide glide, Registry registry) {
    BaseApplication application = (BaseApplication) context.getApplicationContext();
    //Glide 底层默认使用 HttpConnection 进行网络请求,这里替换为 Okhttp 后才能使用本框架,进行 Glide 的加载进度监听
    registry.replace(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(application.getOkHttpClient()));
}
项目:Book-Shelf    文件:CustomTrustOkHttpGlideModule.java   
@Override
public void registerComponents(Context context, Glide glide) {
    OkHttpClient client = OkHttpClientFactory.getTrustedOkHttpClient("", "");
    glide.register(GlideUrl.class, InputStream.class,
            new OkHttpUrlLoader.Factory(client));
}
项目:MVVM-JueJin    文件:GlideConfig.java   
@Override
public void registerComponents(Context context, Glide glide) {
    glide.register(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(OkHttpFactory.INSTANCE.create(null, false)));
}
项目:StatusStories    文件:OkHttpProgressGlideModule.java   
@Override public void registerComponents(Context context, Glide glide) {
    OkHttpClient client = new OkHttpClient.Builder()
            .addNetworkInterceptor(createInterceptor(new DispatchingProgressListener()))
            .build();
    glide.register(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(client));
}
项目:Hitalk    文件:VideoListGlideModule.java   
@Override
public void registerComponents(Context context, Glide glide) {
    glide.register(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(sClient));
}
项目:Hitalk    文件:VideoListGlideModule.java   
public static OkHttpUrlLoader getOkHttpUrlLoader() {
    return sOkHttpUrlLoader;
}
项目:Protein    文件:OKHttpLibraryGlideModule.java   
@Override
public void registerComponents(Context context, Glide glide, Registry registry) {
    registry.replace(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory());
}
项目:AndroidBasicLibs    文件:OkHttpProgressGlideModule.java   
@Override
public void registerComponents(Context context, Glide glide) {
    OkHttpClient.Builder builder = new OkHttpClient.Builder();
    builder.networkInterceptors().add(createInterceptor(new DispatchingProgressListener()));
    glide.register(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(builder.build()));
}
项目:lrs_android    文件:MyGlideModuleConfig.java   
@Override
public void registerComponents(Context context, Glide glide) {
    //glide.clearDiskCache();
    glide.register(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory());
    glide.setMemoryCategory(MemoryCategory.NORMAL);
}
项目:Coder    文件:GlideConfig.java   
@Override
public void registerComponents(Context context, Glide glide) {
    glide.register(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory());//将底层网络框架替换为okhttp
}
项目:espresso-sample-for-droidkaigi2017    文件:QiitaGlideModule.java   
@Override
public void registerComponents(Context context, Glide glide) {
    MainApplication app = (MainApplication) context.getApplicationContext();
    OkHttpClient client = app.getGlideOkHttpClient();
    glide.register(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(client));
}
项目:glide-support    文件:OkHttpProgressGlideModule.java   
@Override public void registerComponents(Context context, Glide glide) {
    OkHttpClient client = new OkHttpClient.Builder()
            .addNetworkInterceptor(createInterceptor(new DispatchingProgressListener()))
            .build();
    glide.register(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(client));
}
项目:GankGirl    文件:GlideConfiguration.java   
@Override
public void registerComponents(Context context, Glide glide) {
    // 配置使用OKHttp3来请求网络
    glide.register(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(new OkHttpClient()));
}
项目:BaseProject    文件:BaseGlide.java   
@Override
public void registerComponents(Context context, Glide glide, Registry registry) {
    super.registerComponents(context, glide, registry);
    registry.replace(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(ProgressManager.getOkHttpClient()));
}
项目:VideoListPlayer    文件:VideoListGlideModule.java   
@Override
public void registerComponents(Context context, Glide glide) {
    glide.register(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(sClient));
}
项目:VideoListPlayer    文件:VideoListGlideModule.java   
public static OkHttpUrlLoader getOkHttpUrlLoader() {
    return sOkHttpUrlLoader;
}
项目:LargeImage    文件:OkHttpProgressGlideModule.java   
@Override
public void registerComponents(Context context, Glide glide) {
    OkHttpClient.Builder builder = new OkHttpClient.Builder();
    builder.networkInterceptors().add(createInterceptor(new DispatchingProgressListener()));
    glide.register(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(builder.build()));
}
项目:danish-media-license    文件:DmlOkHttpGlideModule.java   
@Override
public void registerComponents(Context context, Glide glide) {
  glide.register(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(callFactory));
}