package com.offline.music.playermp3.ui.activity.viewmodel;

import android.util.Pair;

import androidx.annotation.OptIn;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;
import androidx.media3.common.util.UnstableApi;
import androidx.media3.exoplayer.offline.Download;

import com.offline.music.playermp3.javabean.response.ResponsePlayListInfo;

import java.util.List;

public class VMApplication extends ViewModel {


    private MutableLiveData<List<ResponsePlayListInfo>> _playList = new MutableLiveData<List<ResponsePlayListInfo>>();
    public LiveData<List<ResponsePlayListInfo>> playList = _playList;


    private MutableLiveData<Integer> _playStatus = new MutableLiveData<Integer>();
    public LiveData<Integer> playStatus = _playStatus;


    private MutableLiveData<List<Download>> _downloadData = new MutableLiveData<>();
    public LiveData<List<Download>> downloadData = _downloadData;


    private MutableLiveData<Pair<Boolean,Download>> _downloadChange = new MutableLiveData<>();
    public LiveData<Pair<Boolean,Download>> downloadChange = _downloadChange;


    /**
     * 重置播放列表
     *
     * @param list
     */
    public void reSetPlayList(List<ResponsePlayListInfo> list) {
        _playList.setValue(list);
    }

    public void setPlayStatus(int status) {
        _playStatus.setValue(status);
    }


    @OptIn(markerClass = UnstableApi.class)
    public void setDownloadData(List<Download> downloadList) {

        _downloadData.setValue(downloadList);
    }


    @OptIn(markerClass = UnstableApi.class)
    public void setDownloadChange(Pair<Boolean,Download> download) {
        _downloadChange.setValue(download);
    }
}
