67 lines
1.8 KiB
Java
67 lines
1.8 KiB
Java
package com.ubt.jimu.base.mvp;
|
|
|
|
import com.ubt.jimu.base.mvp.BaseRxView;
|
|
import io.reactivex.disposables.CompositeDisposable;
|
|
import io.reactivex.disposables.Disposable;
|
|
import java.lang.ref.WeakReference;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class RxPresenter<V extends BaseRxView> implements BaseMvpPresenter<V> {
|
|
CompositeDisposable mCompositeDisposable = new CompositeDisposable();
|
|
public WeakReference<V> mViewRef;
|
|
|
|
public void add(Disposable disposable) {
|
|
this.mCompositeDisposable.b(disposable);
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.mvp.BasePresenter
|
|
public void detachView() {
|
|
if (hasAttach()) {
|
|
this.mViewRef.clear();
|
|
this.mViewRef = null;
|
|
}
|
|
}
|
|
|
|
public boolean hasAttach() {
|
|
WeakReference<V> weakReference = this.mViewRef;
|
|
return (weakReference == null || weakReference.get() == null) ? false : true;
|
|
}
|
|
|
|
public void hideLoadViewing() {
|
|
if (getView() != null) {
|
|
getView().hideLoadingDialog();
|
|
}
|
|
}
|
|
|
|
public void showLoadingView() {
|
|
if (getView() != null) {
|
|
getView().showLoadingDialog("");
|
|
}
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.mvp.BaseMvpPresenter
|
|
public void unSubscribeAll() {
|
|
this.mCompositeDisposable.dispose();
|
|
this.mCompositeDisposable.a();
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.mvp.BasePresenter
|
|
public void attachModelView(V v) {
|
|
this.mViewRef = new WeakReference<>(v);
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.mvp.BasePresenter
|
|
public V getView() {
|
|
if (hasAttach()) {
|
|
return this.mViewRef.get();
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public void showLoadingView(String str) {
|
|
if (getView() != null) {
|
|
getView().showLoadingDialog(str);
|
|
}
|
|
}
|
|
}
|