當前位置: 首頁>>代碼示例>>Java>>正文


Java OkHttpDownloader類代碼示例

本文整理匯總了Java中com.squareup.picasso.OkHttpDownloader的典型用法代碼示例。如果您正苦於以下問題:Java OkHttpDownloader類的具體用法?Java OkHttpDownloader怎麽用?Java OkHttpDownloader使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


OkHttpDownloader類屬於com.squareup.picasso包,在下文中一共展示了OkHttpDownloader類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: loadImageViaUnsafeOkHttpPicassoInstance

import com.squareup.picasso.OkHttpDownloader; //導入依賴的package包/類
private void loadImageViaUnsafeOkHttpPicassoInstance() {
    // create Picasso.Builder object
    Picasso.Builder picassoBuilder = new Picasso.Builder(context);

    // let's change the standard behavior before we create the Picasso instance
    // for example, let's switch out the standard downloader for the OkHttpClient
    // this OkHttpClient is special since it allows connection to HTTPS urls with a self-signed certificate
    picassoBuilder.downloader(new OkHttpDownloader(UnsafeOkHttpClient.getUnsafeOkHttpClient()));

    // you could further modify Picasso's behavior here, for example setting a custom cache implementation
    // but that would go too far for this tutorial

    // Picasso.Builder creates the Picasso object to do the actual requests
    Picasso picasso = picassoBuilder.build();

    picasso
            .load(UsageExampleListView.eatFoodyImages[3])
            .into(imageView4);
}
 
開發者ID:fs-opensource,項目名稱:android-tutorials-picasso,代碼行數:20,代碼來源:UsageExamplePicassoBuilderBasics.java

示例2: setPicasso

import com.squareup.picasso.OkHttpDownloader; //導入依賴的package包/類
public void setPicasso() {
	OkHttpClient client = new OkHttpClient();
	client.networkInterceptors().add(new StethoInterceptor());
	File cache = new File(this.getCacheDir(), PICASSO_CACHE);
	if (!cache.exists()) {
		//noinspection ResultOfMethodCallIgnored
		cache.mkdirs();
	}
	try {
		client.setCache(new Cache(cache, PICASSO_CACHE_SIZE));
	} catch (IOException e) {
		e.printStackTrace();
	}
	Picasso picasso = new Picasso.Builder(this)
			.downloader(new OkHttpDownloader(client))
			.build();
	Picasso.setSingletonInstance(picasso);
}
 
開發者ID:imallan,項目名稱:tuchong-daily-android,代碼行數:19,代碼來源:TuchongApplication.java

示例3: providesPicasso

import com.squareup.picasso.OkHttpDownloader; //導入依賴的package包/類
@Provides
@Singleton
Picasso providesPicasso(Application app, OkHttpClient client){

    return new Picasso.Builder(app)

            .downloader(new OkHttpDownloader(client))

            .listener(new Picasso.Listener() {

                @Override
                public void onImageLoadFailed(Picasso picasso, Uri uri, Exception exception) {

                    Timber.e(exception, "Failed to load image: %s", uri);
                }
            })
            .build();
}
 
開發者ID:ArthurSav,項目名稱:paradise,代碼行數:19,代碼來源:DataModule.java

示例4: onCreate

import com.squareup.picasso.OkHttpDownloader; //導入依賴的package包/類
@Override
public void onCreate() {
    super.onCreate();
    // crashlytics
    if (!BuildConfig.DEBUG) {
        Fabric.with(this, new Crashlytics());
    }

    // picasso
    Picasso.Builder builder = new Picasso.Builder(this);
    builder.downloader(new OkHttpDownloader(this, Integer.MAX_VALUE));
    Picasso picasso = builder.build();
    Picasso.setSingletonInstance(picasso);

    Iconify.with(new FontAwesomeModule());

    // realm (added by T. Kopp on 2/2/16)
    RealmConfiguration config = new RealmConfiguration.Builder(this)
            .name(Constants.REALM_FILE_NAME)
            .schemaVersion(Constants.SCHEMA_VERSION)
            .deleteRealmIfMigrationNeeded()
            .build();
    Realm.setDefaultConfiguration(config);

}
 
開發者ID:ceaseless-prayer,項目名稱:CeaselessAndroid,代碼行數:26,代碼來源:CeaselessApplication.java

示例5: providePicasso

import com.squareup.picasso.OkHttpDownloader; //導入依賴的package包/類
/**
 * @return
 */
@Provides
@Singleton
Picasso providePicasso() {
    final Context context = activity.getApplicationContext();

    return new Picasso.Builder(context)
            .downloader(new OkHttpDownloader(createOkHttpClient(context)))
            .listener(new Picasso.Listener() {
                @Override
                public void onImageLoadFailed(Picasso picasso, Uri uri, Exception e) {
                    //Timber.e(e, "Failed to load image: %s", uri);
                }
            })
            .build();
}
 
開發者ID:remelpugh,項目名稱:android-shared,代碼行數:19,代碼來源:ActivityModule.java

示例6: onCreate

import com.squareup.picasso.OkHttpDownloader; //導入依賴的package包/類
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
public void onCreate() {
    super.onCreate();
    me = this;

    // Only for development
    // if (Utils.hasHoneycomb()) {
    // Utils.enableStrictMode();
    // }

    initAuthData();

    picasso = new Picasso.Builder(this)
            .downloader(new OkHttpDownloader(this, 100 * 1024 * 1024))
            .memoryCache(new LruCache(20 * 1024 * 1024)).build();
}
 
開發者ID:cuipengpeng,項目名稱:p1-android,代碼行數:18,代碼來源:P1Application.java

示例7: initPicasso

import com.squareup.picasso.OkHttpDownloader; //導入依賴的package包/類
private void initPicasso() {
  File cacheDirectory = new File(getCacheDir().getAbsolutePath(), "OKHttpCache");

  OkHttpClient okHttpClient = new OkHttpClient();
  okHttpClient.setCache(new Cache(cacheDirectory, Integer.MAX_VALUE));

  /** Dangerous interceptor that rewrites the server's cache-control header. */
  okHttpClient.networkInterceptors().add(new Interceptor() {
    @Override public Response intercept(Chain chain) throws IOException {
      Response originalResponse = chain.proceed(chain.request());
      return originalResponse.newBuilder()
          .header("Cache-Control", "public, max-age=432000")
          .header("Pragma", "")
          .build();
    }
  });

  OkHttpDownloader okHttpDownloader = new OkHttpDownloader(okHttpClient);

  Picasso.Builder builder = new Picasso.Builder(this);
  builder.downloader(okHttpDownloader);

  Picasso picasso = builder.build();
  //picasso.setIndicatorsEnabled(true);
  //picasso.setLoggingEnabled(true);
  Picasso.setSingletonInstance(picasso);
}
 
開發者ID:tarek360,項目名稱:PhotoDiscovery,代碼行數:28,代碼來源:App.java

示例8: initPicasso

import com.squareup.picasso.OkHttpDownloader; //導入依賴的package包/類
private void initPicasso() {
        Picasso.Builder builder = new Picasso.Builder(this);
        builder.downloader(new OkHttpDownloader(this, Integer.MAX_VALUE));
        Picasso built = builder.build();
//        built.setIndicatorsEnabled(true);
//        built.setLoggingEnabled(true);
        Picasso.setSingletonInstance(built);
    }
 
開發者ID:ChenAt,項目名稱:PlayTogether,代碼行數:9,代碼來源:MyApplication.java

示例9: providePicasso

import com.squareup.picasso.OkHttpDownloader; //導入依賴的package包/類
@Provides
@Singleton
Picasso providePicasso(@ApplicationContext Context context){
    return new Picasso.Builder(context)
            .downloader(new OkHttpDownloader(context,Integer.MAX_VALUE))
           // .indicatorsEnabled(true)
           // .loggingEnabled(true)
            .build();
}
 
開發者ID:adhamenaya,項目名稱:AppsFeed,代碼行數:10,代碼來源:ApplicationModule.java

示例10: onCreate

import com.squareup.picasso.OkHttpDownloader; //導入依賴的package包/類
@Override
public void onCreate() {
    super.onCreate();

    // config Picasso to use OkHttp for image caching
    // This will speed up image loading time and allow offline usage of the app
    Picasso.Builder builder = new Picasso.Builder(this);
    builder.downloader(new OkHttpDownloader(this, Integer.MAX_VALUE));
    Picasso built = builder.build();
    built.setIndicatorsEnabled(false);
    if(BuildConfig.DEBUG) {
        built.setLoggingEnabled(true);
    }
    Picasso.setSingletonInstance(built);
}
 
開發者ID:frank-tan,項目名稱:XYZReader,代碼行數:16,代碼來源:XYZReaderApplication.java

示例11: getPicasso

import com.squareup.picasso.OkHttpDownloader; //導入依賴的package包/類
public static Picasso getPicasso(Context context) {
        if (sPicasso == null) {
            sPicasso = new Picasso.Builder(context)
                    //硬盤緩存池大小
                    .downloader(new OkHttpDownloader(context, ConfigConstants.MAX_CACHE_DISK_SIZE))
                    //內存緩存池大小
                    .memoryCache(new LruCache(ConfigConstants.MAX_CACHE_MEMORY_SIZE))
//                    .defaultBitmapConfig(Bitmap.Config.ARGB_4444)
                    .build();
        }
        return sPicasso;
    }
 
開發者ID:zhouruikevin,項目名稱:ImageLoadPK,代碼行數:13,代碼來源:PicassoConfigFactory.java

示例12: setUpPicasso

import com.squareup.picasso.OkHttpDownloader; //導入依賴的package包/類
private void setUpPicasso() {
    Picasso.Builder builder = new Picasso.Builder(this);
    builder.downloader(new OkHttpDownloader(this, Integer.MAX_VALUE));
    Picasso built = builder.build();
    built.setIndicatorsEnabled(ApplicationConstants.DEBUG);
    built.setLoggingEnabled(ApplicationConstants.DEBUG);
    Picasso.setSingletonInstance(built);
}
 
開發者ID:Protino,項目名稱:Fad-Flicks,代碼行數:9,代碼來源:Global.java

示例13: getPicasso

import com.squareup.picasso.OkHttpDownloader; //導入依賴的package包/類
public static Picasso getPicasso(){
    if(picasso==null){
        picasso = new Picasso.Builder(App.getInstance())
                .downloader(new OkHttpDownloader(OkHttpProvider.getInstance(sAccount)))
                .build();
    }
    return picasso;
}
 
開發者ID:dyweb,項目名稱:gitlab-android,代碼行數:9,代碼來源:GitlabClient.java

示例14: doInBackground

import com.squareup.picasso.OkHttpDownloader; //導入依賴的package包/類
@Override
protected byte[] doInBackground(Void... params) {
    try {
        // Grab an input stream to the image
        OkHttpDownloader downloader = new OkHttpDownloader(getContext());
        Downloader.Response response = downloader.load(Uri.parse(url), 0);

        // Read the image into a byte array
        return Okio.buffer(Okio.source(response.getInputStream())).readByteArray();
    } catch (Exception e) {
        Log.d(ImageFragment.class.getSimpleName(), "Error fetching image", e);
        return null;
    }
}
 
開發者ID:SteamGifts,項目名稱:SteamGifts,代碼行數:15,代碼來源:ImageFragment.java

示例15: providePicasso

import com.squareup.picasso.OkHttpDownloader; //導入依賴的package包/類
@Provides
@Singleton
Picasso providePicasso(Application app, OkHttpClient client) {
    return new Picasso.Builder(app)
            .downloader(new OkHttpDownloader(client))
            .listener(new Picasso.Listener() {
                @Override public void onImageLoadFailed(Picasso picasso, Uri uri, Exception e) {
                    Timber.e(e, "Failed to load image: %s", uri);
                }
            })
            .build();
}
 
開發者ID:baoti,項目名稱:Pioneer,代碼行數:13,代碼來源:DataModule.java


注:本文中的com.squareup.picasso.OkHttpDownloader類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。