如果查询或路径中有数据,它将在FirestoreRecyclerAdapter中显示数据.但是当该路径上没有数据时 [英] If there is data in query or Path it show data in FirestoreRecyclerAdapter. but when there is no data at that path

查看:87
本文介绍了如果查询或路径中有数据,它将在FirestoreRecyclerAdapter中显示数据.但是当该路径上没有数据时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在查询中使用FirestoreRecyclerAdapter.我将显示负载,直到它不进入onBindViewHolder()为止.如果涉及到onBindViewHolder,则我关闭对话框.

I use FirestoreRecyclerAdapter with query. I show the loading till it's not getting into onBindViewHolder(). If it comes to onBindViewHolder then I close the dialog.

但是在我的情况下,没有数据进入查询,并且也没有进入onBindViewHolder,所以我还是找不到关闭它的方法.这是我的代码.请帮忙.

But in my scenario there is no data into query and its not get into onBindViewHolder so I do not found anyway to close it. Here is my code. Please help.

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

推荐答案

我得到了答案

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

                        }

                    }

这篇关于如果查询或路径中有数据,它将在FirestoreRecyclerAdapter中显示数据.但是当该路径上没有数据时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆