package com.gyf.csams.activity.model import android.app.Application import androidx.lifecycle.viewModelScope import com.google.gson.reflect.TypeToken import com.gyf.csams.module.ActivityVo import com.gyf.csams.module.ApiResponse import com.gyf.csams.module.FindTendencyVo import com.gyf.csams.module.TendencyType import com.gyf.lib.model.ScrollViewModel import com.gyf.lib.util.* import kotlinx.coroutines.launch class TendencyViewModel(application: Application) : ScrollViewModel(application = application) { fun load(type: TendencyType) { viewModelScope.launch { HttpClient.post( url = Api.buildUrl(ActivityApi.FindTendency), callback = HttpCallback>( action = "加载${type.desc}活动", onSuccess = { it.body?.apply { _data.postValue(this) } }, typeToken = object : TypeToken>>() {}.type ), jsonParam = FindTendencyVo(type = type, token = TokenManager.getToken()) ) } } }