| | |
| | | package com.auto.lyric.vm; |
| | | |
| | | import com.auto.lyric.base.model.BaseViewModel; |
| | | import com.auto.lyric.data.ActiveResult; |
| | | import com.auto.lyric.retrofit.api.CollectApiCenter; |
| | | import com.auto.lyric.retrofit.observable.LoadingHttpObserver; |
| | | import com.auto.lyric.retrofit.utils.RetrofitUtils; |
| | | |
| | | import io.reactivex.Observable; |
| | | |
| | | /** |
| | | * Created by Runt (qingingrunt2010@qq.com) on 2022/3/20. |
| | | */ |
| | | public class MainViewModel extends BaseViewModel { |
| | | |
| | | CollectApiCenter apiCenter; |
| | | |
| | | public MainViewModel(){ |
| | | apiCenter = RetrofitUtils.getInstance().getRetrofit(CollectApiCenter.class); |
| | | } |
| | | |
| | | public void checkActive(String userId,String activeKey,LoadingHttpObserver<ActiveResult> observer){ |
| | | Observable<ActiveResult> observable = apiCenter.loginCheck(getApiFileds(userId,activeKey)); |
| | | httpObserverOn(observable,observer); |
| | | } |
| | | |
| | | public void register(String activeKey,LoadingHttpObserver<ActiveResult> observer){ |
| | | Observable<ActiveResult> observable = apiCenter.register(getApiFileds("0",activeKey)); |
| | | httpObserverOn(observable,observer); |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * @param userId |
| | | * @param activeKey |
| | | * @param title 歌词标题 |
| | | * @param lrc 歌词内容 |
| | | * @param observer |
| | | */ |
| | | public void addToCollect(String userId,String activeKey,String title,String lrc,LoadingHttpObserver<ActiveResult> observer){ |
| | | httpObserverOn(apiCenter.addLrcToCollect(title,lrc,getApiFileds(userId,activeKey)),observer); |
| | | } |
| | | |
| | | } |