Glide无法加载图像

时间:2020-06-11 21:28:34

标签: android android-glide

目前,我在使用Glide和8以上版本的android设备时遇到了一些麻烦。

我的问题:

在适配器(RecyclerView)内,我想用Glide绑定图像(位于公共可用服务器/ URL上)。对于android 8以下版本的设备,滑行不会出现问题,并将图像加载到imageview中。

在设备(8+)上,滑行无法正常工作。没有图像加载到图像视图中。

在logcat中,我没有收到错误消息或其他东西。

我使用最新的Android Studio,并且所有依赖项都是最新的(Androidx)。

我的滑行代码(无自定义配置):

 GlideApp.with(activity)
            .load(feedItem.getThumbnail())
            .error(R.drawable.error)
            .transition(DrawableTransitionOptions.withCrossFade(2000))
            .into(feedListRowHolder.listview_thumbnail); 

成绩文件:

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.recyclerview:recyclerview:1.1.0'
    implementation 'com.jakewharton.threetenabp:threetenabp:1.2.4'
    implementation 'com.github.bumptech.glide:glide:4.11.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
 //   implementation 'com.github.bumptech.glide:okhttp3-integration:4.11.0'
    implementation 'com.squareup.okhttp3:okhttp:4.7.2'
    implementation 'com.getkeepsafe.taptargetview:taptargetview:1.11.0'
    // androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.core:core:1.3.0'
    implementation 'com.google.android.gms:play-services-safetynet:17.0.0'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.gridlayout:gridlayout:1.0.0'
    implementation 'androidx.lifecycle:lifecycle-livedata-core:2.2.0'
    implementation 'androidx.lifecycle:lifecycle-livedata:2.2.0'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
    implementation 'com.google.android.material:material:1.1.0'
    implementation "androidx.room:room-runtime:$rootProject.roomVersion"
    annotationProcessor "androidx.room:room-compiler:$rootProject.roomVersion"
    annotationProcessor "androidx.annotation:annotation:1.1.0"
    androidTestImplementation "androidx.room:room-testing:$rootProject.roomVersion"
    implementation 'androidx.navigation:navigation-fragment:2.2.2'
    implementation 'androidx.navigation:navigation-ui:2.2.2'
}

我对okhttp集成进行了评论,因为这些库没有效果。

有人可以帮我解决我的问题吗? (您需要更多行代码吗?)

编辑和解决方案: 正如我在上一条评论中提到的那样,添加以下两种方法后,glide的工作方式如下:

GlideApp.with(activity)
             .asBitmap()
            .load(feedItem.getThumbnail())
            .placeholder(R.drawable.placeholder)
            .error(R.drawable.error)
            .transition(DrawableTransitionOptions.withCrossFade(2000))
            .into(feedListRowHolder.listview_thumbnail); 

0 个答案:

没有答案