|
|
@@ -23,13 +23,18 @@ import com.miekir.mvp.presenter.BasePresenter;
|
|
|
* @date 2020/11/14 20:45
|
|
|
* Description:
|
|
|
*/
|
|
|
-public class MvpLiveData<T> extends MutableLiveData<T> {
|
|
|
+public class MvpLiveData<T, C> extends MutableLiveData<T> {
|
|
|
protected BasePresenter mPresenter;
|
|
|
- protected boolean mWidthDialog;
|
|
|
+ protected boolean mWidthProgress;
|
|
|
|
|
|
- public MvpLiveData(BasePresenter mPresenter, boolean mWidthDialog) {
|
|
|
+ private C mTask;
|
|
|
+ public void setCancelableTask(C cancelableTask) {
|
|
|
+ mTask = cancelableTask;
|
|
|
+ }
|
|
|
+
|
|
|
+ public MvpLiveData(BasePresenter mPresenter, boolean withProgress) {
|
|
|
this.mPresenter = mPresenter;
|
|
|
- this.mWidthDialog = mWidthDialog;
|
|
|
+ this.mWidthProgress = withProgress;
|
|
|
}
|
|
|
|
|
|
private MvpObserver<T> mObserver;
|
|
|
@@ -44,10 +49,11 @@ public class MvpLiveData<T> extends MutableLiveData<T> {
|
|
|
* 只监听一次的LiveData
|
|
|
* @param observer
|
|
|
*/
|
|
|
- public void observeOnce(MvpObserver<T> observer) {
|
|
|
+ public C observeOnce(MvpObserver<T> observer) {
|
|
|
mObserver = observer;
|
|
|
observer.setLiveData(this);
|
|
|
observeForever(observer);
|
|
|
+ return mTask;
|
|
|
}
|
|
|
|
|
|
public void post(T dataBean) {
|