use of com.commonsware.cwac.netsecurity.TrustManagerBuilder 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);
}
Aggregations