com.jakewharton.picasso.OkHttp3Downloader Java Examples

The following examples show how to use com.jakewharton.picasso.OkHttp3Downloader. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FriendListAdapter.java    From AndFChat with GNU General Public License v3.0 6 votes vote down vote up
public FriendListAdapter(final Context context, List<FCharacter> chars) {
    super(context, R.layout.list_item_friend, chars);

    if (chars.size() > 1) {
        sortList();
    }

    this.chars = chars;

    RoboGuice.getInjector(context).injectMembers(this);

    if (picasso == null)  {
        picasso = new Picasso.Builder(getContext())
                .downloader(new OkHttp3Downloader(client))
                .build();
    }
}
 
Example #2
Source File: ChatroomListAdapter.java    From AndFChat with GNU General Public License v3.0 6 votes vote down vote up
public ChatroomListAdapter(Context context, List<Chatroom> entries) {
    super(context, R.layout.list_item_chat, entries);

    RoboGuice.getInjector(context).injectMembers(this);

    TypedArray colorArray = context.getTheme().obtainStyledAttributes(new int[]{
            R.attr.BackgroundChatTab,
            R.attr.BackgroundChatTabActive,
            R.attr.BackgroundChatTabAttention,
            R.attr.BackgroundChatTabStatus});

    standardColor = colorArray.getColor(0, 0);
    activeColor = colorArray.getColor(1, 0);
    attentionColor = colorArray.getColor(2, 0);
    statusColor = colorArray.getColor(3, 0);

    colorArray.recycle();

    OkHttpClient client = new OkHttpClient();
    //client.setProtocols(Collections.singletonList(Protocol.HTTP_1_1));

    picasso = new Picasso.Builder(getContext())
            .downloader(new OkHttp3Downloader(client))
            .build();
}
 
Example #3
Source File: PicassoLoader.java    From ImageLoader with Apache License 2.0 5 votes vote down vote up
private Picasso getPicasso(){
    if(picasso ==null){
        client = MyUtil.getClient(GlobalConfig.ignoreCertificateVerify);
        picasso =  new Picasso.Builder(GlobalConfig.context)
                .downloader(new OkHttp3Downloader(client))
                .build();
    }
    return picasso;
}
 
Example #4
Source File: DebugDataModule.java    From u2020 with Apache License 2.0 5 votes vote down vote up
@Provides @Singleton Picasso providePicasso(OkHttpClient client, NetworkBehavior behavior,
    @IsMockMode boolean isMockMode, Application app) {
  Picasso.Builder builder = new Picasso.Builder(app).downloader(new OkHttp3Downloader(client));
  if (isMockMode) {
    builder.addRequestHandler(new MockRequestHandler(behavior, app.getAssets()));
  }
  builder.listener((picasso, uri, exception) -> {
    Timber.e(exception, "Error while loading image %s", uri);
  });
  return builder.build();
}
 
Example #5
Source File: InternalReleaseDataModule.java    From u2020-mvp with Apache License 2.0 5 votes vote down vote up
@Provides
@ApplicationScope
Picasso providePicasso(Application app, OkHttpClient client) {
    return new Picasso.Builder(app)
            .downloader(new OkHttp3Downloader(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();
}
 
Example #6
Source File: ReleaseDataModule.java    From u2020-mvp with Apache License 2.0 5 votes vote down vote up
@Provides
@ApplicationScope
Picasso providePicasso(Application app, OkHttpClient client) {
    return new Picasso.Builder(app)
            .downloader(new OkHttp3Downloader(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();
}
 
Example #7
Source File: DebugDataModule.java    From u2020-mvp with Apache License 2.0 5 votes vote down vote up
@Provides
@ApplicationScope
Picasso providePicasso(OkHttpClient client, NetworkBehavior behavior,
                       @IsMockMode boolean isMockMode, Application app) {
    Picasso.Builder builder = new Picasso.Builder(app).downloader(new OkHttp3Downloader(client));
    if (isMockMode) {
        builder.addRequestHandler(new MockRequestHandler(behavior, app.getAssets()));
    }
    builder.listener((picasso, uri, exception) -> Timber.e(exception, "Error while loading image %s", uri));
    return builder.build();
}
 
Example #8
Source File: WebserviceModule.java    From BaseAndroidApp with Apache License 2.0 5 votes vote down vote up
@Provides
@Singleton
Picasso providePicasso(Context context, OkHttp3Downloader downloader) {
   return new Picasso.Builder(context).executor(Executors.newSingleThreadExecutor())
         .downloader(downloader)
         .indicatorsEnabled(BuildConfig.IS_IDE_BUILD)
         .build();
}
 
Example #9
Source File: SpectreApplication.java    From quill with MIT License 5 votes vote down vote up
@SuppressWarnings("WeakerAccess")
protected void initPicasso() {
    if (mPicasso != null) {
        return;
    }
    mPicasso = new Picasso.Builder(this)
            .downloader(new OkHttp3Downloader(mOkHttpClient))
            .listener((picasso, uri, exception) -> {
                Log.e("Picasso", "Failed to load image: " + uri + "\n"
                        + Log.getStackTraceString(exception));
            })
            .build();
}
 
Example #10
Source File: MoviesApp.java    From AndroidSchool with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    sInstance = this;

    Picasso picasso = new Picasso.Builder(this)
            .downloader(new OkHttp3Downloader(this))
            .build();
    Picasso.setSingletonInstance(picasso);

    RealmConfiguration configuration = new RealmConfiguration.Builder(this)
            .rxFactory(new RealmObservableFactory())
            .build();
    Realm.setDefaultConfiguration(configuration);
}
 
Example #11
Source File: DayPictureApp.java    From AndroidSchool with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    sInstance = this;

    RepositoryProvider.init();

    Picasso picasso = new Picasso.Builder(this)
            .downloader(new OkHttp3Downloader(this))
            .build();
    Picasso.setSingletonInstance(picasso);
}
 
Example #12
Source File: MoviesApp.java    From AndroidSchool with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    sInstance = this;

    Picasso picasso = new Picasso.Builder(this)
            .downloader(new OkHttp3Downloader(this))
            .build();
    Picasso.setSingletonInstance(picasso);

    RealmConfiguration configuration = new RealmConfiguration.Builder(this)
            .rxFactory(new RealmObservableFactory())
            .build();
    Realm.setDefaultConfiguration(configuration);
}
 
Example #13
Source File: MoviesApp.java    From AndroidSchool with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    sInstance = this;

    Picasso picasso = new Picasso.Builder(this)
            .downloader(new OkHttp3Downloader(this))
            .build();
    Picasso.setSingletonInstance(picasso);
}
 
Example #14
Source File: MainActivity.java    From Study_Android_Demo with Apache License 2.0 5 votes vote down vote up
public void loadImg2(View view){
        //此方式创建Picasso对象,拥有更好的扩展性(可指定缓存位置等)
        Picasso picasso = new Picasso.Builder(this)
                //OkHttp3.0改了包名(3.0之前是"com.squareup.okhttp.OkHttpClient",3.0之后是okhttp3.OkHttpClient)(所以直接new 一个downloader用不了okhttp,用的就是httpurlconnection)
                //所以,要导包compile 'com.jakewharton.picasso:picasso2-okhttp3-downloader:1.1.0'
                .downloader(new OkHttp3Downloader(this.getExternalCacheDir()))
                .build();

//        Picasso.setSingletonInstance(picasso);
        picasso.load(IMAGEURL).into(iv);

    }
 
Example #15
Source File: ApplicationModule.java    From FriendlyDemo with Apache License 2.0 5 votes vote down vote up
@Provides
@NonNull
@Singleton
public Picasso providePicasso(@NonNull Application boxBeeApplication, @NonNull OkHttpClient okHttpClient) {
    return new Picasso.Builder(boxBeeApplication)
            .downloader(new OkHttp3Downloader(okHttpClient))
            .build();
}
 
Example #16
Source File: NetworkModule.java    From android-rxmvp with Apache License 2.0 5 votes vote down vote up
@AppScope
@Provides
public Picasso picasso(Context context, OkHttpClient okHttpClient) {
    return new Picasso.Builder(context)
            .downloader(new OkHttp3Downloader(okHttpClient))
            .build();
}
 
Example #17
Source File: NetworkModule.java    From android-rxmvp-tutorial with Apache License 2.0 5 votes vote down vote up
@AppScope
@Provides
public Picasso picasso(Context context, OkHttpClient okHttpClient) {
  return new Picasso.Builder(context)
      .downloader(new OkHttp3Downloader(okHttpClient))
      .build();
}
 
Example #18
Source File: Global.java    From Simple-Blog-App with MIT License 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();

    Picasso.Builder builder = new Picasso.Builder(this);
    builder.downloader(new OkHttp3Downloader(this,Integer.MAX_VALUE));
    Picasso built = builder.build();
    built.setIndicatorsEnabled(true);
    built.setLoggingEnabled(true);
    Picasso.setSingletonInstance(built);

}
 
Example #19
Source File: PicassoBigLoader.java    From ImageLoader with Apache License 2.0 5 votes vote down vote up
public PicassoBigLoader(OkHttpClient client) {
   OkHttpClient client1 =  client.newBuilder().addNetworkInterceptor(new ProgressInterceptor()).build();
    this.client = client1;
    picasso =  new Picasso.Builder(GlobalConfig.context)
            .downloader(new OkHttp3Downloader(client1))
            .build();
}
 
Example #20
Source File: WebserviceModule.java    From BaseAndroidApp with Apache License 2.0 4 votes vote down vote up
@Provides
@Singleton
OkHttp3Downloader provideOkHttpDownloader(Context context) {
   return new OkHttp3Downloader(context, CACHE_SIZE);
}
 
Example #21
Source File: WebserviceModuleTest.java    From BaseAndroidApp with Apache License 2.0 4 votes vote down vote up
@Test
public void testProvidePicasso() {
   assertThat(webserviceModule.providePicasso(context, new OkHttp3Downloader(context)),
         notNullValue());
}
 
Example #22
Source File: DataModule.java    From droidconat-2016 with Apache License 2.0 4 votes vote down vote up
@Provides @Singleton Picasso providePicasso(Application app, OkHttpClient client) {
    return new Picasso.Builder(app)
            .downloader(new OkHttp3Downloader(client))
            .listener((picasso, uri, e) -> Timber.e(e, "Failed to load image: %s", uri))
            .build();
}
 
Example #23
Source File: DataModule.java    From u2020 with Apache License 2.0 4 votes vote down vote up
@Provides @Singleton Picasso providePicasso(Application app, OkHttpClient client) {
  return new Picasso.Builder(app)
      .downloader(new OkHttp3Downloader(client))
      .listener((picasso, uri, e) -> Timber.e(e, "Failed to load image: %s", uri))
      .build();
}
 
Example #24
Source File: ImageModule.java    From cathode with Apache License 2.0 4 votes vote down vote up
@Provides @Singleton Downloader provideDownloader(@Named("Images") OkHttpClient okClient) {
  return new OkHttp3Downloader(okClient);
}
 
Example #25
Source File: ApiModule.java    From photoviewer with Apache License 2.0 3 votes vote down vote up
@Provides @Singleton Picasso providePicasso(OkHttpClient httpClient, Context context) {

    Picasso.Builder builder = new Picasso.Builder(context);
    Picasso picasso = builder.downloader(new OkHttp3Downloader(httpClient)).build();

    return picasso;
  }