package com.hd.live.wall.wallpapers.viewmode;

import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;
import androidx.paging.Pager;
import androidx.paging.PagingConfig;
import androidx.paging.PagingData;
import androidx.paging.PagingLiveData;

import com.hd.live.wall.wallpapers.dbData.Collection;
import com.hd.live.wall.wallpapers.pages.PageSourceLike;

import java.util.List;


public class VmCollction extends ViewModel {

    public  Pager<Integer, Collection> pager;



    private MutableLiveData<PagingData<Collection>> _likeLiveData = new MutableLiveData<>();
    public LiveData<PagingData<Collection>> likeLiveData = _likeLiveData  ;

    public LiveData<PagingData<Collection>> getPagingData() {
        Pager<Integer, Collection> integerLikeDataPager = new Pager<>(
                new PagingConfig(10), // 每页加载 20 条数据
                PageSourceLike::new
        );

        return PagingLiveData.getLiveData(integerLikeDataPager);
    }
    public  void update(List<Collection> data){
        PagingData<Collection> from = PagingData.from(data);
        _likeLiveData.postValue(from);
    }


}
