Search in sources :

Example 1 with TrustManagerBuilder

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);
}
Also used : Retrofit(retrofit2.Retrofit) OkHttpClient(okhttp3.OkHttpClient) TrustManagerBuilder(com.commonsware.cwac.netsecurity.TrustManagerBuilder) Picasso(com.squareup.picasso.Picasso) OkHttp3Downloader(com.jakewharton.picasso.OkHttp3Downloader) TrustManagerBuilder(com.commonsware.cwac.netsecurity.TrustManagerBuilder) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) ListView(android.widget.ListView) KeyManagementException(java.security.KeyManagementException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException)

Aggregations

View (android.view.View)1 ImageView (android.widget.ImageView)1 ListView (android.widget.ListView)1 TextView (android.widget.TextView)1 TrustManagerBuilder (com.commonsware.cwac.netsecurity.TrustManagerBuilder)1 OkHttp3Downloader (com.jakewharton.picasso.OkHttp3Downloader)1 Picasso (com.squareup.picasso.Picasso)1 KeyManagementException (java.security.KeyManagementException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 OkHttpClient (okhttp3.OkHttpClient)1 Retrofit (retrofit2.Retrofit)1