我使用FirestoreRecyclerAdapter
查询。我显示加载,直到它没有进入onBindViewHolder()
。如果涉及onBindViewHolder
,则关闭对话框。
但是在我的场景中,没有数据进入查询,它没有进入onBindViewHolder
所以我无论如何都没有找到关闭它。这是我的代码。请帮忙。
Query query = GlobalApplication.applianceRef.whereEqualTo("applianceType", appType);
FirestoreRecyclerOptions < RoomAppliance > response = new FirestoreRecyclerOptions.Builder < RoomAppliance > ()
.setQuery(query, RoomAppliance.class)
.build();
if (dialog != null) {
dialog.show();
}
adapter = new FirestoreRecyclerAdapter < RoomAppliance, ApplianceActivity.ViewHolder > (response) {
@Override
public void onBindViewHolder(final ApplianceActivity.ViewHolder holder, final int position, final RoomAppliance model) {
dialog.dismiss();
}
@Override
public ApplianceActivity.ViewHolder onCreateViewHolder(ViewGroup group, int i) {
View view = null;
try {
view = LayoutInflater.from(group.getContext())
.inflate(R.layout.user_appliance, group, false);
} catch (Exception e) {
Log.e("error", e.getMessage());
}
return new ApplianceActivity.ViewHolder(view);
}
};
答案 0 :(得分:1)
我得到了答案
@Override
public void onDataChanged() {
if(dialog != null && dialog.isShowing()){
dialog.dismiss();
}
if(getItemCount() == 0){
remoteListRV.setVisibility(View.GONE);
msgTv.setVisibility(View.VISIBLE);
msgTv.setText("No "+ appType +" Available !!!!");
}else {
remoteListRV.setVisibility(View.VISIBLE);
msgTv.setVisibility(View.GONE);
}
}