|
|
@@ -0,0 +1,68 @@
|
|
|
+package com.miekir.mvp.jetpack.backup;
|
|
|
+
|
|
|
+//得到一个LiveData,用于传递Observer参数的形式,这里暂时用不到
|
|
|
+//private <T> MutableLiveData<T> observeOnce(final Observer<T> observer) {
|
|
|
+//final MutableLiveData<T> specificLiveData = new MutableLiveData<>();
|
|
|
+// specificLiveData.observeForever(new Observer<T>() {
|
|
|
+//@Override
|
|
|
+//public void onChanged(T t) {
|
|
|
+//specificLiveData.removeObserver(this);
|
|
|
+//observer.onChanged(t);
|
|
|
+//}
|
|
|
+//});
|
|
|
+//return specificLiveData;
|
|
|
+//}
|
|
|
+
|
|
|
+/**
|
|
|
+ * Copyright (C), 2019-2020, Miekir
|
|
|
+ *
|
|
|
+ * @author Miekir
|
|
|
+ * @date 2020/11/14 20:45
|
|
|
+ * Description:
|
|
|
+ * @param <T> 监听者里面的数据类型
|
|
|
+ * @param <C> 返回的任务,是可取消的类型,一般定义为Void即可,除非要在Activity上执行特定操作取消某个特定任务
|
|
|
+ */
|
|
|
+//public class RawLiveData<T, C> extends MutableLiveData<T> {
|
|
|
+// protected BasePresenter mPresenter;
|
|
|
+// protected boolean mWidthProgress;
|
|
|
+// public RawLiveData(BasePresenter mPresenter, boolean withProgress) {
|
|
|
+// this.mPresenter = mPresenter;
|
|
|
+// this.mWidthProgress = withProgress;
|
|
|
+// }
|
|
|
+//
|
|
|
+// private ResultObserver<T, C> mObserver;
|
|
|
+// public void cancelObserve() {
|
|
|
+// mObserver.setLiveData(null);
|
|
|
+// removeObserver(mObserver);
|
|
|
+// mObserver = null;
|
|
|
+// mPresenter = null;
|
|
|
+// }
|
|
|
+//
|
|
|
+// private C mTask;
|
|
|
+// public void setCancelableTask(C cancelableTask) {
|
|
|
+// mTask = cancelableTask;
|
|
|
+// }
|
|
|
+// /**
|
|
|
+// * 只监听一次的LiveData
|
|
|
+// * @param observer
|
|
|
+// */
|
|
|
+// public C observeOnce(ResultObserver<T, C> observer) {
|
|
|
+// mObserver = observer;
|
|
|
+// observer.setLiveData(this);
|
|
|
+// observeForever(observer);
|
|
|
+// return mTask;
|
|
|
+// }
|
|
|
+//
|
|
|
+// public void post(T dataBean) {
|
|
|
+// if (mPresenter == null) {
|
|
|
+// return;
|
|
|
+// }
|
|
|
+//
|
|
|
+// if (mWidthProgress) {
|
|
|
+// mPresenter.dismissLoading();
|
|
|
+// }
|
|
|
+//
|
|
|
+// mPresenter.getLiveDataList().remove(this);
|
|
|
+// postValue(dataBean);
|
|
|
+// }
|
|
|
+//}
|