Picasso未将图像从URL

时间:2018-04-08 20:13:13

标签: android android-recyclerview kotlin picasso

我正在使用Picasso从API中检索的URL加载图像。

这是我目前的毕加索配置。我正在使用Dagger2来提供毕加索的依赖。

@Provides
Picasso getPicasso(@Named("application-context") Context context, OkHttp3Downloader downloader) {
     return new Picasso.Builder(context)
              .downloader(downloader)
              .indicatorsEnabled(true)
              .loggingEnabled(true)
              .build();
    }

这是我的OkHttp配置

@Provides
OkHttpClient getOkHttpClient(HttpLoggingInterceptor loggingInterceptor, Cache cache, Interceptor httpInterceptor) {
    return new OkHttpClient.Builder()
            .addInterceptor(httpInterceptor)
            .addInterceptor(loggingInterceptor)
            .cache(cache)
            .build();
   }

这是LoggingInterceptor的实现

@Provides
HttpLoggingInterceptor getHttpLoggingInterceptor() {
    HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor(message -> Timber.tag("OkHttp").d(message));         
    loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BASIC);
    return loggingInterceptor;
    }

但是当我在回收器视图适配器中使用picasso时,就像这样

picasso.load(article.urlToImage)
    .placeholder(R.drawable.placeholder)
    .into(thumbnailImageView)

仅加载占位符图像。传递的图像URL未在图像视图中加载

也没有抛出任何错误。 这是logcat

D/Picasso: Main        created      [R1] Request{http://bsmedia.business-standard.com/_media/bs/img/article/2017-09/04/full/1504466214-5997.jpg}
D/Picasso: Hunter      executing    [R0]+11ms 
D/Picasso: Dispatcher  enqueued     [R1]+1ms 
D/Picasso: Hunter      executing    [R1]+2ms 
D/Picasso: Main        created      [R2] Request{https://img.etimg.com/thumb/msid-63672403,width-672,resizemode-4,imgsize-538337/air-india.jpg}
D/Picasso: Dispatcher  enqueued     [R2]+1ms 
D/Picasso: Hunter      executing    [R2]+1ms 
D/Picasso: Main        created      [R3] Request{http://bsmedia.business-standard.com/include/_mod/site/html5/images/no-meta-preview.jpg}
D/Picasso: Dispatcher  enqueued     [R3]+1ms 
D/Picasso: Hunter      executing    [R3]+1ms 
D/Picasso: Main        created      [R4] Request{https://www.livemint.com/rf/Image-621x414/LiveMint/Period2/2018/04/09/Photos/Processed/chaipoint-kT0--621x414@LiveMint.JPG}
D/Picasso: Dispatcher  enqueued     [R4]+1ms 
D/Picasso: Hunter      executing    [R4]+1ms 
D/Picasso: Main        created      [R5] Request{http://bsmedia.business-standard.com/_media/bs/img/article/2018-03/12/full/1520793310-387.jpg}
D/Picasso: Dispatcher  enqueued     [R5]+1ms 
D/Picasso: Hunter      executing    [R5]+1ms

我看到正在执行加载图像的请求,但图像未加载。

这里有什么问题?

0 个答案:

没有答案