|
@@ -1,10 +1,10 @@
|
|
|
-package com.miekir.network.core.impl;
|
|
|
|
|
|
|
+package com.miekir.network.widget.observe;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
import android.content.Context;
|
|
|
|
|
|
|
|
import com.miekir.network.R;
|
|
import com.miekir.network.R;
|
|
|
-import com.miekir.network.core.base.BaseObserver;
|
|
|
|
|
import com.miekir.network.widget.CustomProgressDialog;
|
|
import com.miekir.network.widget.CustomProgressDialog;
|
|
|
|
|
+import com.miekir.network.widget.observe.net.NetStickyObserver;
|
|
|
|
|
|
|
|
import io.reactivex.annotations.NonNull;
|
|
import io.reactivex.annotations.NonNull;
|
|
|
import io.reactivex.disposables.Disposable;
|
|
import io.reactivex.disposables.Disposable;
|
|
@@ -14,18 +14,19 @@ import io.reactivex.disposables.Disposable;
|
|
|
* 需要进度条时,调用onSubscribe同时显示进度条,
|
|
* 需要进度条时,调用onSubscribe同时显示进度条,
|
|
|
* 流程走到onComplete/onError时隐藏进度条。
|
|
* 流程走到onComplete/onError时隐藏进度条。
|
|
|
* @author Miekir
|
|
* @author Miekir
|
|
|
|
|
+ * 用于可见,但不可手动取消的网络任务
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
-public abstract class ProgressObserver<T> extends BaseObserver<T> {
|
|
|
|
|
|
|
+public abstract class BackupObserver<T> extends NetStickyObserver<T> {
|
|
|
private CustomProgressDialog mProgressDialog;
|
|
private CustomProgressDialog mProgressDialog;
|
|
|
private Context mContext;
|
|
private Context mContext;
|
|
|
private String mText;
|
|
private String mText;
|
|
|
|
|
|
|
|
- public ProgressObserver(Context context) {
|
|
|
|
|
|
|
+ public BackupObserver(Context context) {
|
|
|
this(context, context.getString(R.string.network_loading));
|
|
this(context, context.getString(R.string.network_loading));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public ProgressObserver(Context context, String text) {
|
|
|
|
|
|
|
+ public BackupObserver(Context context, String text) {
|
|
|
this.mContext = context;
|
|
this.mContext = context;
|
|
|
this.mText = text;
|
|
this.mText = text;
|
|
|
}
|
|
}
|
|
@@ -38,7 +39,7 @@ public abstract class ProgressObserver<T> extends BaseObserver<T> {
|
|
|
}
|
|
}
|
|
|
if (mProgressDialog == null) {
|
|
if (mProgressDialog == null) {
|
|
|
mProgressDialog = new CustomProgressDialog(mContext, mText);
|
|
mProgressDialog = new CustomProgressDialog(mContext, mText);
|
|
|
- mProgressDialog.setCancelable(true);
|
|
|
|
|
|
|
+ mProgressDialog.setCancelable(false);
|
|
|
mProgressDialog.setCanceledOnTouchOutside(false);
|
|
mProgressDialog.setCanceledOnTouchOutside(false);
|
|
|
}
|
|
}
|
|
|
mProgressDialog.show();
|
|
mProgressDialog.show();
|