package com.gh.gamecenter.gamecollection.choose

import android.app.Application
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import com.gh.gamecenter.feature.entity.GameEntity
import com.gh.gamecenter.mygame.PlayedGameViewModel
import com.gh.gamecenter.retrofit.RetrofitManager
import com.halo.assistant.HaloApp
import com.lightgame.utils.Utils
import io.reactivex.Single

class AddUserPlayedGameViewModel(application: Application, userId: String, isKeepTagStyle: Boolean = false) :
    PlayedGameViewModel(application, userId, isKeepTagStyle) {

    override fun provideDataSingle(page: Int): Single<MutableList<GameEntity>> {
        val map = mapOf("view" to "game_list")
        return RetrofitManager.getInstance().api.getPlayedGames(userId, page, Utils.getTime(getApplication()), map)
    }

    class Factory(private val mUserId: String, val isKeepTagStyle: Boolean = false) :
        ViewModelProvider.NewInstanceFactory() {
        override fun <T : ViewModel> create(modelClass: Class<T>): T {
            return AddUserPlayedGameViewModel(HaloApp.getInstance().application, mUserId, isKeepTagStyle) as T
        }
    }

}