正如标题所说,当我尝试从Firebase存储中检索一些照片时,我的进度对话框没有显示。 这是我的代码:
progress = ProgressDialog.show(getActivity(), "Loading...", "Please wait...", true);
//Retrieve photos from storage
mDatabase.child("TopCommentPhotos").addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Iterable<DataSnapshot> children = dataSnapshot.getChildren();
Random r = new Random();
int random = r.nextInt((size+1) - 1) + 1;
int count=0;
for(DataSnapshot child: children) {
count = count+1;
if (count == random){
progress.dismiss();
ImageModel imageModel = child.getValue(ImageModel.class);
String downloadUrl = imageModel.getUrl();
// Display photo
Glide.with(getActivity())
.load(downloadUrl)
.into(mImageView);
}
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
Toast.makeText(getActivity(),"Error",Toast.LENGTH_LONG).show();
}
});
感谢您的帮助
答案 0 :(得分:0)
public void onDataChange(DataSnapshot dataSnapshot) {
Iterable<DataSnapshot> children = dataSnapshot.getChildren();
Random r = new Random();
int random = r.nextInt((size+1) - 1) + 1;
int count=0;
for(DataSnapshot child: children) {
count = count+1;
if (count == random){
ImageModel imageModel = child.getValue(ImageModel.class);
String downloadUrl = imageModel.getUrl();
// Display photo
Glide.with(getActivity())
.load(downloadUrl)
.into(mImageView);
}
}
progress.dismiss();
}
和
@Override
public void onCancelled(DatabaseError databaseError) {
Toast.makeText(getActivity(),"Error",Toast.LENGTH_LONG).show();
progress.dismiss();
}