| | |
| | | package com.android.app_base.base.viewmodel; |
| | | |
| | | import android.app.Application; |
| | | import android.os.Bundle; |
| | | |
| | | import androidx.annotation.NonNull; |
| | | import androidx.lifecycle.AndroidViewModel; |
| | |
| | | |
| | | import com.android.app_base.base.StateViewEnum; |
| | | import com.android.app_base.base.model.BaseModel; |
| | | |
| | | |
| | | import org.reactivestreams.Subscriber; |
| | | |
| | | import io.reactivex.disposables.CompositeDisposable; |
| | | import io.reactivex.disposables.Disposable; |
| | |
| | | /** |
| | | * 控制状态视图的LiveData |
| | | */ |
| | | private MutableLiveData<StateViewEnum> stateViewLiveData; |
| | | protected MutableLiveData<StateViewEnum> stateViewLiveData = new MutableLiveData<>(); |
| | | protected MutableLiveData<String> messageLiveData = new MutableLiveData<>(); |
| | | //管理RxJava,主要针对RxJava异步操作造成的内存泄漏 |
| | | private CompositeDisposable mCompositeDisposable; |
| | | |
| | |
| | | stateViewLiveData = new MutableLiveData<>(); |
| | | } |
| | | return stateViewLiveData; |
| | | } |
| | | public MutableLiveData<String> getMessageLivaData(){ |
| | | if(messageLiveData == null){ |
| | | messageLiveData = new MutableLiveData<>(); |
| | | } |
| | | return messageLiveData; |
| | | } |
| | | /** |
| | | * 更改状态视图的状态 |
| | |
| | | public void onDestroy(@NonNull LifecycleOwner owner) { |
| | | DefaultLifecycleObserver.super.onDestroy(owner); |
| | | } |
| | | |
| | | protected void onCreate(Bundle savedInstanceState) { |
| | | } |
| | | } |