public static void init(final Context context) { OkHttpClient okHttpClient = new OkHttpClient(); okHttpClient.setReadTimeout(30, TimeUnit.SECONDS); okHttpClient.setConnectTimeout(30, TimeUnit.SECONDS); // okHttpClient.setProtocols(Arrays.asList(Protocol.HTTP_1_1)); GlideBuilder glideBuilder = new GlideBuilder(context) .setDiskCache(new DiskCache.Factory() { @Override public DiskCache build() { // Careful: the external cache directory doesn't enforce permissions File cacheLocation = new File(context.getExternalCacheDir(), AppConfig.CACHE_IMAGE_DIR); cacheLocation.mkdirs(); return DiskLruCacheWrapper.get(cacheLocation, 100 * 1024 * 1024); } }); if (!Glide.isSetup()) { Glide.setup(glideBuilder); } Glide.get(context).register(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(okHttpClient)); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Glide.get(this).register(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(new OkHttpClient())); mHandler = new Handler(); imageLoader = new ImageLoader(this); ActionBar ab = getSupportActionBar(); if (ab != null) { ab.setDisplayHomeAsUpEnabled(true); } mLUtils = LUtils.getInstance(this); mThemedStatusBarColor = getResources().getColor(R.color.theme_primary_dark); mNormalStatusBarColor = mThemedStatusBarColor; SyncUtils.createSyncAccount(this); getLoaderManager().restartLoader(0, buildLoaderArgs(), new AccountLoader()); }
@Override public void onCreate() { // TODO Auto-generated method stub super.onCreate(); mContext = this; client = new OkHttpClient(); Glide.get(this).register(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(client) ); PushService.setDefaultPushCallback(this, MainActivity.class); }
protected void setupGlide() { Glide.get(mApp).register(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(mOkHttpClient)); }
@Override public void registerComponents(Context context, Glide glide) { if (BuildConfig.DEBUG) { OkHttpClient client = new OkHttpClient(); client.networkInterceptors().add(new StethoInterceptor()); OkHttpUrlLoader.Factory factory = new OkHttpUrlLoader.Factory(client); glide.register(GlideUrl.class, InputStream.class, factory); } }
@Override public void registerComponents(Context context, Glide glide) { // Use OkHttp to fetch images. glide.register(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(new OkHttpClient())); }
@Override public void registerComponents(Context context, Glide glide) { glide.register(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(InstaApplication.from(context).getHttpClient())); }