mardi 30 juin 2020

How to get pagedlist size in android when using paging library with mvvm

please, I'm using android MVVM with retrofit and with paging library and the problem is I can't get size of pagedlist. pagedlist = 0 in UI always.

and the below code that the way how I get the list size.

 private void getAllAds() {
        userHomeViewModel.getHomeAllAdsPagedList().observe(this, new Observer<PagedList<AllAdsModel>>() {
            @Override
            public void onChanged(PagedList<AllAdsModel> list) {
                allAdsModelPagedList = list;
                Toast.makeText(AllAdsActivity.this, ""+list.size(), Toast.LENGTH_SHORT).show();
                //list.size = 0!!!!
                initUserAllAds();
            }
        });
    }

Aucun commentaire:

Enregistrer un commentaire