gpt4 book ai didi

android - 我无法显示来自 Cloud Firestore 的图像

转载 作者:行者123 更新时间:2023-11-29 22:44:00 26 4
gpt4 key购买 nike

My Firebase Cloud database Structure

我的 Activity 代码

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);

}
}
}

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

你能帮我解决这个问题吗

最佳答案

更新firestore ui依赖到最新版本:

    // FirebaseUI for Cloud Firestore
implementation 'com.firebaseui:firebase-ui-firestore:6.0.2'

在这里查看:

https://github.com/firebase/FirebaseUI-Android

关于android - 我无法显示来自 Cloud Firestore 的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58728689/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com