我尝试使用Firebase与Glide集成,出于某种原因,
Glide.using()
无法解决此方法。
我添加了:
compile 'com.firebaseui:firebase-ui-storage:0.6.0'
进入build.gradle
并且还:
compile 'com.github.bumptech.glide:glide:4.0.0-RC1'
以下是我尝试使用Glide的部分:
mStorageRef = FirebaseStorage.getInstance().getReference();
mStorageRef.child("images/Puffer-fish-are-pretty-damn-cute.jpg");
// Load the image using Glide
Glide.with(this)
.using(new FirebaseImageLoader()) // cannot resolve method using!
.load(mStorageRef)
.into(imageView);
我希望你可以帮助我,没有在网上找到任何解决方案。
答案 0 :(得分:8)
要解决此问题,请更改此行:
compile 'com.github.bumptech.glide:glide:4.0.0-RC1'
与
compile 'com.github.bumptech.glide:glide:3.7.0'
答案 1 :(得分:2)
Glide v4正在将模块加载器与注释处理器库一起使用。
创建AppGlideModule
,然后注册FirebaseImageLoader
。加载图像时,请使用StorageReference
。
这是详细信息。
在gradle中添加库
implementation 'com.github.bumptech.glide:glide:4.7.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'
implementation 'com.firebaseui:firebase-ui-storage:4.1.0'
扩展模块并注册
@GlideModule
public class MyAppGlideModule extends AppGlideModule {
@Override
public void registerComponents(@NonNull Context context, @NonNull Glide glide, @NonNull Registry registry) {
registry.append(StorageReference.class, InputStream.class, new FirebaseImageLoader.Factory());
}
}
使用参考加载图像
Uri uri = Uri.parse(photoUrl);
StorageReference ref = FirebaseStorage.getInstance().getReference().child(uri.getPath());
Glide.with(itemView.getContext())
.load(ref)
.into(thumb);