Recycler视图不显示来自firebase firestore的数据

时间:2018-02-09 08:21:08

标签: android android-fragments android-recyclerview recycler-adapter android-livedata

问题是在调用onchanged方法后,recycleler视图不显示数据。或者如果是,则显示信息需要很长时间。继承人代码:

 mViewModel.getMutableLiveData().observe(this, new Observer<Filters>() {
            @Override
            public void onChanged(@Nullable Filters filters) {
                if (filters != null){


                    Log.d("ExploreFragObserver", filters.getCategory() + " ");
                    Log.d("ExploreFragObserver", filters.getCity() + "");
                    Log.d("ExploreFragObserver", filters.getSortBy() + " ");
                    Log.d("ExploreFragObserver", filters.getPrice() + " ");
                    onFilter(filters);
                    Log.d("Done Loading Adapt", filters.getSortBy() + " ");
                    Log.d("ExploreFragObserver", filters.getCategory() + " ");
                    Log.d("ExploreFragObserver", filters.getCity() + "");
                    Log.d("ExploreFragObserver", filters.getSortBy() + " ");
                    Log.d("ExploreFragObserver", filters.getPrice() + " ");

                   // onFilter(Filters.getDefault());


                }




            }
        });

这是方法被调用的地方,我从viewmodel获取数据,没有问题但回收者视图剂量显示数据。

{
"item": [
        {
            "item_id": 484,
            "user_id": 123,
            "lucky_number": -1,
            "liked_user": [
                {
                    "user_id": 2
                },
                {
                    "user_id": 1
                }
            ],
            "modified_time": "0000-09-19 10:24:02"
        }

    ]
}

对话框片段在viewmodel中设置filters对象的数据,该片段和调用片段都共享。

1 个答案:

答案 0 :(得分:0)

我认为您忘记添加adapter.startListening()