Initial commit
This commit is contained in:
190
sources/com/ubt/jimu/base/mvp/BaseMvpFragment.java
Normal file
190
sources/com/ubt/jimu/base/mvp/BaseMvpFragment.java
Normal file
@@ -0,0 +1,190 @@
|
||||
package com.ubt.jimu.base.mvp;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import com.ubt.jimu.R;
|
||||
import com.ubt.jimu.base.event.MessageEvent;
|
||||
import com.ubt.jimu.base.mvp.BaseMvpPresenter;
|
||||
import com.ubt.jimu.widgets.JAlertDialog;
|
||||
import com.ubtech.view.widget.ToastView;
|
||||
import com.ubtrobot.log.ALog;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class BaseMvpFragment<P extends BaseMvpPresenter> extends Fragment implements BaseRxView {
|
||||
private static final String TAG = "BaseMvpFragment";
|
||||
private boolean isInit;
|
||||
private boolean isInitData;
|
||||
private boolean isVisible;
|
||||
private String mCurrentName;
|
||||
protected JAlertDialog mJAlertDialog;
|
||||
public P mPresenter;
|
||||
public View rootView;
|
||||
|
||||
public abstract P createPresenter();
|
||||
|
||||
public abstract int getLayoutID();
|
||||
|
||||
protected void hideLoading() {
|
||||
JAlertDialog jAlertDialog = this.mJAlertDialog;
|
||||
if (jAlertDialog == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
jAlertDialog.dismiss();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.mvp.BaseView
|
||||
public void hideLoadingDialog() {
|
||||
hideLoading();
|
||||
}
|
||||
|
||||
public void init(View view, Bundle bundle) {
|
||||
initView(view, bundle);
|
||||
}
|
||||
|
||||
protected void initData() {
|
||||
}
|
||||
|
||||
protected void initFirstData() {
|
||||
if (this.isInitData) {
|
||||
return;
|
||||
}
|
||||
this.isInitData = true;
|
||||
initData();
|
||||
}
|
||||
|
||||
public void initView(View view, Bundle bundle) {
|
||||
}
|
||||
|
||||
public boolean isRegistEventBus() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override // androidx.fragment.app.Fragment
|
||||
public void onCreate(Bundle bundle) {
|
||||
super.onCreate(bundle);
|
||||
if (isRegistEventBus()) {
|
||||
EventBus.b().c(this);
|
||||
}
|
||||
if (this.mPresenter == null) {
|
||||
this.mPresenter = createPresenter();
|
||||
}
|
||||
P p = this.mPresenter;
|
||||
if (p != null) {
|
||||
p.attachModelView(this);
|
||||
}
|
||||
this.mCurrentName = toString();
|
||||
ALog.a(TAG).d(this.mCurrentName + "OnCreate");
|
||||
}
|
||||
|
||||
@Override // androidx.fragment.app.Fragment
|
||||
public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
|
||||
if (this.rootView == null) {
|
||||
this.rootView = layoutInflater.inflate(getLayoutID(), viewGroup, false);
|
||||
}
|
||||
return this.rootView;
|
||||
}
|
||||
|
||||
@Override // androidx.fragment.app.Fragment
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
this.isInitData = false;
|
||||
this.isInit = false;
|
||||
this.isVisible = false;
|
||||
ALog.a(TAG).d(this.mCurrentName + "onDestroy");
|
||||
}
|
||||
|
||||
@Override // androidx.fragment.app.Fragment
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
EventBus.b().d(this);
|
||||
}
|
||||
|
||||
@Override // androidx.fragment.app.Fragment
|
||||
public void onDetach() {
|
||||
super.onDetach();
|
||||
P p = this.mPresenter;
|
||||
if (p != null) {
|
||||
p.detachView();
|
||||
}
|
||||
ALog.a(TAG).d(this.mCurrentName + "onDetach");
|
||||
}
|
||||
|
||||
@Override // androidx.fragment.app.Fragment
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
ALog.a(TAG).d(this.mCurrentName + "OnPause");
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onReceiveMessage(MessageEvent messageEvent) {
|
||||
}
|
||||
|
||||
@Override // androidx.fragment.app.Fragment
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
ALog.a(TAG).d(this.mCurrentName + "OnResume");
|
||||
}
|
||||
|
||||
@Override // androidx.fragment.app.Fragment
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
ALog.a(TAG).d(this.mCurrentName + "OnStop");
|
||||
}
|
||||
|
||||
@Override // androidx.fragment.app.Fragment
|
||||
public void onViewCreated(View view, Bundle bundle) {
|
||||
super.onViewCreated(view, bundle);
|
||||
init(view, bundle);
|
||||
this.isInit = true;
|
||||
if (this.isInit && this.isVisible) {
|
||||
initFirstData();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.fragment.app.Fragment
|
||||
public void setUserVisibleHint(boolean z) {
|
||||
super.setUserVisibleHint(z);
|
||||
this.isVisible = z;
|
||||
if (this.isVisible && this.isInit) {
|
||||
initFirstData();
|
||||
}
|
||||
}
|
||||
|
||||
protected void showLoading(String str) {
|
||||
JAlertDialog jAlertDialog = this.mJAlertDialog;
|
||||
if (jAlertDialog == null) {
|
||||
JAlertDialog.Builder builder = new JAlertDialog.Builder(getContext());
|
||||
builder.a(R.drawable.ic_loading);
|
||||
builder.a(str);
|
||||
builder.a(true);
|
||||
this.mJAlertDialog = builder.a();
|
||||
} else {
|
||||
jAlertDialog.a(str);
|
||||
}
|
||||
this.mJAlertDialog.show();
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.mvp.BaseView
|
||||
public void showLoadingDialog(String str) {
|
||||
showLoading(str);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.mvp.BaseView
|
||||
public void showToast(int i) {
|
||||
ToastView.a(getContext(), getResources().getString(i), ToastView.Type.NORMAL).a();
|
||||
}
|
||||
|
||||
public void toast(String str) {
|
||||
ToastView.a(getContext(), str, ToastView.Type.NORMAL).a();
|
||||
}
|
||||
}
|
12
sources/com/ubt/jimu/base/mvp/BaseMvpPresenter.java
Normal file
12
sources/com/ubt/jimu/base/mvp/BaseMvpPresenter.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package com.ubt.jimu.base.mvp;
|
||||
|
||||
import androidx.lifecycle.Lifecycle;
|
||||
import androidx.lifecycle.LifecycleObserver;
|
||||
import androidx.lifecycle.OnLifecycleEvent;
|
||||
import com.ubt.jimu.base.mvp.BaseRxView;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface BaseMvpPresenter<B extends BaseRxView> extends LifecycleObserver, BasePresenter<B> {
|
||||
@OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
|
||||
void unSubscribeAll();
|
||||
}
|
12
sources/com/ubt/jimu/base/mvp/BasePresenter.java
Normal file
12
sources/com/ubt/jimu/base/mvp/BasePresenter.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package com.ubt.jimu.base.mvp;
|
||||
|
||||
import com.ubt.jimu.base.mvp.BaseView;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface BasePresenter<V extends BaseView> {
|
||||
void attachModelView(V v);
|
||||
|
||||
void detachView();
|
||||
|
||||
V getView();
|
||||
}
|
5
sources/com/ubt/jimu/base/mvp/BaseRxView.java
Normal file
5
sources/com/ubt/jimu/base/mvp/BaseRxView.java
Normal file
@@ -0,0 +1,5 @@
|
||||
package com.ubt.jimu.base.mvp;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface BaseRxView extends BaseView {
|
||||
}
|
10
sources/com/ubt/jimu/base/mvp/BaseView.java
Normal file
10
sources/com/ubt/jimu/base/mvp/BaseView.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package com.ubt.jimu.base.mvp;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface BaseView {
|
||||
void hideLoadingDialog();
|
||||
|
||||
void showLoadingDialog(String str);
|
||||
|
||||
void showToast(int i);
|
||||
}
|
76
sources/com/ubt/jimu/base/mvp/HbBaseActivity.java
Normal file
76
sources/com/ubt/jimu/base/mvp/HbBaseActivity.java
Normal file
@@ -0,0 +1,76 @@
|
||||
package com.ubt.jimu.base.mvp;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import com.ubt.jimu.BaseActivity;
|
||||
import com.ubt.jimu.base.event.MessageEvent;
|
||||
import com.ubt.jimu.base.mvp.BaseMvpPresenter;
|
||||
import com.ubtech.view.widget.ToastView;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class HbBaseActivity<T extends BaseMvpPresenter> extends BaseActivity implements BaseRxView, SingleClickListener {
|
||||
private long lastClickTime = 0;
|
||||
protected T mPresenter;
|
||||
|
||||
public abstract T createPresenter();
|
||||
|
||||
public abstract int getLayoutResId();
|
||||
|
||||
@Override // com.ubt.jimu.base.mvp.BaseView
|
||||
public void hideLoadingDialog() {
|
||||
hideLoading();
|
||||
}
|
||||
|
||||
public boolean isRegistEventBus() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.mvp.SingleClickListener, android.view.View.OnClickListener
|
||||
public /* synthetic */ void onClick(View view) {
|
||||
b.$default$onClick(this, view);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.BaseActivity, com.ubt.jimu.ScreenRotationManageActivity, androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, androidx.core.app.ComponentActivity, android.app.Activity
|
||||
protected void onCreate(Bundle bundle) {
|
||||
setContentView(getLayoutResId());
|
||||
super.onCreate(bundle);
|
||||
if (isRegistEventBus()) {
|
||||
EventBus.b().c(this);
|
||||
}
|
||||
if (this.mPresenter == null) {
|
||||
this.mPresenter = createPresenter();
|
||||
}
|
||||
T t = this.mPresenter;
|
||||
if (t != null) {
|
||||
t.attachModelView(this);
|
||||
}
|
||||
getLifecycle().a(this.mPresenter);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.BaseActivity, com.ubt.jimu.ScreenRotationManageActivity, androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, android.app.Activity
|
||||
protected void onDestroy() {
|
||||
T t = this.mPresenter;
|
||||
if (t != null) {
|
||||
t.detachView();
|
||||
getLifecycle().b(this.mPresenter);
|
||||
}
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onReceiveMessage(MessageEvent messageEvent) {
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.mvp.BaseView
|
||||
public void showLoadingDialog(String str) {
|
||||
showLoading(str);
|
||||
}
|
||||
|
||||
@Override // com.ubt.jimu.base.mvp.BaseView
|
||||
public void showToast(int i) {
|
||||
ToastView.a(this, getResources().getString(i), ToastView.Type.NORMAL).a();
|
||||
}
|
||||
}
|
14
sources/com/ubt/jimu/base/mvp/OnItemClickListener.java
Normal file
14
sources/com/ubt/jimu/base/mvp/OnItemClickListener.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package com.ubt.jimu.base.mvp;
|
||||
|
||||
import android.view.View;
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface OnItemClickListener extends BaseQuickAdapter.OnItemClickListener {
|
||||
public static final int FAST_CLICK_DELAY_TIME = 800;
|
||||
|
||||
void onAdapterItemClick(BaseQuickAdapter baseQuickAdapter, View view, int i);
|
||||
|
||||
@Override // com.chad.library.adapter.base.BaseQuickAdapter.OnItemClickListener
|
||||
void onItemClick(BaseQuickAdapter baseQuickAdapter, View view, int i);
|
||||
}
|
23
sources/com/ubt/jimu/base/mvp/RxHelper.java
Normal file
23
sources/com/ubt/jimu/base/mvp/RxHelper.java
Normal file
@@ -0,0 +1,23 @@
|
||||
package com.ubt.jimu.base.mvp;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.ObservableSource;
|
||||
import io.reactivex.ObservableTransformer;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class RxHelper {
|
||||
public static boolean DEVELOPMODE = true;
|
||||
public static long RX_DURATION = 1000;
|
||||
|
||||
public static <T> ObservableTransformer<T, T> transformer(final boolean z) {
|
||||
return new ObservableTransformer<T, T>() { // from class: com.ubt.jimu.base.mvp.RxHelper.1
|
||||
@Override // io.reactivex.ObservableTransformer
|
||||
public ObservableSource<T> apply(Observable<T> observable) {
|
||||
return observable.debounce(RxHelper.RX_DURATION, TimeUnit.MILLISECONDS).subscribeOn(Schedulers.b()).unsubscribeOn(Schedulers.b()).observeOn(z ? AndroidSchedulers.a() : Schedulers.b());
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
66
sources/com/ubt/jimu/base/mvp/RxPresenter.java
Normal file
66
sources/com/ubt/jimu/base/mvp/RxPresenter.java
Normal file
@@ -0,0 +1,66 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
13
sources/com/ubt/jimu/base/mvp/SingleClickListener.java
Normal file
13
sources/com/ubt/jimu/base/mvp/SingleClickListener.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package com.ubt.jimu.base.mvp;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface SingleClickListener extends View.OnClickListener {
|
||||
public static final int FAST_CLICK_DELAY_TIME = 500;
|
||||
|
||||
@Override // android.view.View.OnClickListener
|
||||
void onClick(View view);
|
||||
|
||||
void onSingleClick(View view);
|
||||
}
|
17
sources/com/ubt/jimu/base/mvp/a.java
Normal file
17
sources/com/ubt/jimu/base/mvp/a.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.ubt.jimu.base.mvp;
|
||||
|
||||
import android.view.View;
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.ubt.jimu.JimuApplication;
|
||||
|
||||
/* compiled from: OnItemClickListener.java */
|
||||
/* loaded from: classes.dex */
|
||||
public final /* synthetic */ class a {
|
||||
public static void $default$onItemClick(OnItemClickListener _this, BaseQuickAdapter baseQuickAdapter, View view, int i) {
|
||||
if (System.currentTimeMillis() - JimuApplication.i < 800) {
|
||||
return;
|
||||
}
|
||||
JimuApplication.i = System.currentTimeMillis();
|
||||
_this.onAdapterItemClick(baseQuickAdapter, view, i);
|
||||
}
|
||||
}
|
16
sources/com/ubt/jimu/base/mvp/b.java
Normal file
16
sources/com/ubt/jimu/base/mvp/b.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package com.ubt.jimu.base.mvp;
|
||||
|
||||
import android.view.View;
|
||||
import com.ubt.jimu.JimuApplication;
|
||||
|
||||
/* compiled from: SingleClickListener.java */
|
||||
/* loaded from: classes.dex */
|
||||
public final /* synthetic */ class b {
|
||||
public static void $default$onClick(SingleClickListener _this, View view) {
|
||||
if (System.currentTimeMillis() - JimuApplication.i < 500) {
|
||||
return;
|
||||
}
|
||||
JimuApplication.i = System.currentTimeMillis();
|
||||
_this.onSingleClick(view);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user