我想从存储中检索图像到recyclerview但它无法正常工作
mFirestore.collection("Users").whereEqualTo("special", s).get().addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if (task.isSuccessful()) {
final SpecializedDoctorNameFragment S = new SpecializedDoctorNameFragment();
final List<DoctorNameStructure> eventList = new ArrayList<>();
for (final DocumentSnapshot doc : task.getResult()) {
String id = doc.getString("id");
final DoctorNameStructure e = new DoctorNameStructure();
e.setName(doc.getString("name"));
e.setAddress(doc.getString("address"));
e.setConsultancy(doc.getString("consultancyFees"));
e.setSpecialization(doc.getString("special"));
storageReference.child("images/" + id).getDownloadUrl().addOnSuccessListener(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
uploadImages();
e.setImage(uri.toString());
eventList.add(e);
}
});
}
NameAdapter recyclerViewAdapter = new NameAdapter(getContext(), eventList, mFirestore);
recyclerName.setAdapter(recyclerViewAdapter);
}
}
});
监听器在setAdapter之后执行。更改填充列表的逻辑。