|
@@ -10,13 +10,15 @@ import com.miekir.mvp.presenter.BasePresenter;
|
|
|
* @author Miekir
|
|
* @author Miekir
|
|
|
* @date 2020/11/14 21:36
|
|
* @date 2020/11/14 21:36
|
|
|
* Description:
|
|
* Description:
|
|
|
|
|
+ * @param <T> 监听者里面的数据类型
|
|
|
|
|
+ * @param <C> 返回的任务,是可取消的类型,一般定义为Void即可,除非要在Activity上执行特定操作取消某个特定任务
|
|
|
*/
|
|
*/
|
|
|
-public class BeanLiveData<D, C> extends MvpLiveData<DataResult<D>, C> {
|
|
|
|
|
|
|
+public class BeanLiveData<T, C> extends MvpLiveData<DataResult<T>, C> {
|
|
|
public BeanLiveData(BasePresenter mPresenter, boolean withProgress) {
|
|
public BeanLiveData(BasePresenter mPresenter, boolean withProgress) {
|
|
|
super(mPresenter, withProgress);
|
|
super(mPresenter, withProgress);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public void post(int responseCode, String message, D dataBean) {
|
|
|
|
|
|
|
+ public void post(int responseCode, String message, T dataBean) {
|
|
|
if (mPresenter == null) {
|
|
if (mPresenter == null) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
@@ -26,10 +28,10 @@ public class BeanLiveData<D, C> extends MvpLiveData<DataResult<D>, C> {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
mPresenter.getLiveDataList().remove(this);
|
|
mPresenter.getLiveDataList().remove(this);
|
|
|
- postValue(new DataResult<D>(responseCode, message, dataBean));
|
|
|
|
|
|
|
+ postValue(new DataResult<T>(responseCode, message, dataBean));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public void postSuccess(D dataBean) {
|
|
|
|
|
|
|
+ public void postSuccess(T dataBean) {
|
|
|
post(MvpResponse.SUCCESS, "", dataBean);
|
|
post(MvpResponse.SUCCESS, "", dataBean);
|
|
|
}
|
|
}
|
|
|
|
|
|