我无法显示Cloud Firestore中的图像

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了我无法显示Cloud Firestore中的图像相关的知识,希望对你有一定的参考价值。

My Firebase Cloud database Structure

我的活动代码

private FirebaseFirestore firebaseFirestore  = FirebaseFirestore.getInstance();
private CollectionReference collectionReference;
private void getData() 

    mAuth = FirebaseAuth.getInstance();
    FirebaseUser currentUser = mAuth.getCurrentUser();
    mobileNumber = currentUser.getPhoneNumber();

    collectionReference = firebaseFirestore.collection("OWNERS_DATA");
    query = collectionReference.document(mobileNumber).collection("BUILDING_DATA");

    FirestoreRecyclerOptions<AddBuilding> options = new FirestoreRecyclerOptions.Builder<AddBuilding>()
            .setQuery(query, AddBuilding.class)
            .build();

    adapter = new OwnerBuildingListAdapter(options);

    recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    recyclerView.setHasFixedSize(true);
    recyclerView.setAdapter(adapter);

@Override
public void onStart() 
    super.onStart();
    adapter.startListening();


@Override
public void onStop() 
    super.onStop();
    adapter.stopListening();

在我的Pojo类中,我给出了一个空的构造函数,构造函数,getter和setter。我在.setquery(query,AddBuilding.class)行遇到错误。我的适配器类看起来像这样。

public class OwnerBuildingListAdapter extends FirestoreRecyclerAdapter<AddBuilding, OwnerBuildingListAdapter.OwnerBuildingListHolder> 
public OwnerBuildingListAdapter(FirestoreRecyclerOptions<AddBuilding> options) 
    super(options);


@Override
protected void onBindViewHolder(OwnerBuildingListHolder ownerBuildingListHolder, int i, AddBuilding addBuilding) 

    ownerBuildingListHolder.buildingName.setText(addBuilding.getBuildingName());
    String imageUrl = addBuilding.getImageUrl();
    Picasso.get().load(imageUrl).into(ownerBuildingListHolder.buildingImage);



@NonNull
@Override
public OwnerBuildingListHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) 

    View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_cardview, parent, false);
    return new OwnerBuildingListHolder(view);


class OwnerBuildingListHolder extends RecyclerView.ViewHolder

    TextView buildingName;
    ImageView buildingImage;

    public OwnerBuildingListHolder(@NonNull View itemView) 
        super(itemView);

        buildingName = itemView.findViewById(R.id.text_view);
        buildingImage = itemView.findViewById(R.id.image_view);

    


如果运行程序,我得到的是输出但没有得到图像

您能帮我解决这个问题吗?>

我的Firebase云数据库结构我的活动代码私有FirebaseFirestore firebaseFirestore = FirebaseFirestore.getInstance(); private CollectionReference collectionReference; private void ...

答案

将firestore ui依赖项更新为最新版本:

以上是关于我无法显示Cloud Firestore中的图像的主要内容,如果未能解决你的问题,请参考以下文章

由于权限问题,无法访问 Firebase 中的 Cloud Firestore

从Google Cloud Firestore上载和下载文件

如何解决“由于上述问题,无法构建插件 cloud_firestore。”

无法在 Android 上使用 Cloud Firestore 保存文档

React Native Firebase Cloud Firestore

@firebase/firestore:Firestore (8.6.5):无法访问 Cloud Firestore 后端