OkHTTP and Picasso don't run together

前端 未结 6 2042
灰色年华
灰色年华 2020-12-05 18:40

I use Picasso library in my project to load images ande cache them. It works good without any problem. However, when I try to use OkHttp library to perform data communicatio

6条回答
  •  Happy的楠姐
    2020-12-05 19:05

    //Below code for Picasso initializing once for the app
    private Picasso picasso;
    private OkHttpClient okHttpClient;
    
    okHttpClient = new OkHttpClient();
    picasso = new Picasso.Builder(this)
                    .downloader(new OkHttpDownloader(okHttpClient))
                    .build();
    
    //Below code to retrieve the images whereever required on the app
    picasso.with(context).load(imageUrl).placeholder(R.drawable.ic_launcher)
    

    The above code works fine for me.

提交回复
热议问题