use of com.jakewharton.picasso.OkHttp3Downloader in project cw-omnibus by commonsguy.
the class QuestionsFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View result = super.onCreateView(inflater, container, savedInstanceState);
setRetainInstance(true);
OkHttpClient.Builder okb = new OkHttpClient.Builder();
TrustManagerBuilder tmb = new TrustManagerBuilder().withManifestConfig(getActivity());
try {
OkHttp3Integrator.applyTo(tmb, okb);
OkHttpClient ok = okb.build();
picasso = new Picasso.Builder(getActivity()).downloader(new OkHttp3Downloader(ok)).build();
Retrofit retrofit = new Retrofit.Builder().baseUrl("https://api.stackexchange.com").client(ok).addConverterFactory(GsonConverterFactory.create()).build();
StackOverflowInterface so = retrofit.create(StackOverflowInterface.class);
so.questions("android").enqueue(this);
} catch (Exception e) {
Toast.makeText(getActivity(), e.getMessage(), Toast.LENGTH_LONG).show();
Log.e(getClass().getSimpleName(), "Exception from TrustManagerBuilder setup", e);
}
return (result);
}
use of com.jakewharton.picasso.OkHttp3Downloader in project u2020 by JakeWharton.
the class DebugDataModule method providePicasso.
@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();
}
use of com.jakewharton.picasso.OkHttp3Downloader in project Tusky by Vavassor.
the class TuskyApplication method onCreate.
@Override
public void onCreate() {
super.onCreate();
// Initialize Picasso configuration
Picasso.Builder builder = new Picasso.Builder(this);
builder.downloader(new OkHttp3Downloader(this));
if (BuildConfig.DEBUG) {
builder.listener(new Picasso.Listener() {
@Override
public void onImageLoadFailed(Picasso picasso, Uri uri, Exception exception) {
exception.printStackTrace();
}
});
}
try {
Picasso.setSingletonInstance(builder.build());
} catch (IllegalStateException e) {
throw new RuntimeException(e);
}
if (BuildConfig.DEBUG) {
Picasso.with(this).setLoggingEnabled(true);
}
}
Aggregations