|
|
@@ -36,7 +36,7 @@ public abstract class SheepSubscriber<T> implements Observer<T> {
|
|
|
public void onSubscribe(Disposable d) {
|
|
|
if (!NetUtil.isConnected(context)) {
|
|
|
if (SheepApp.getInstance().getCurrentActivity() != null) {
|
|
|
- SheepApp.getInstance().getCurrentActivity().runOnUiThread(() -> G.shortToast("当前网络不可用,请检查网络情况"));
|
|
|
+ SheepApp.getInstance().getCurrentActivity().runOnUiThread(this::showNoNetView);
|
|
|
}
|
|
|
// 一定好主动调用下面这一句,取消本次Subscriber订阅
|
|
|
if (!d.isDisposed()) {
|
|
|
@@ -46,6 +46,15 @@ public abstract class SheepSubscriber<T> implements Observer<T> {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public static long showTipTime;
|
|
|
+ public void showNoNetView(){
|
|
|
+ long curTime = System.currentTimeMillis();
|
|
|
+ if(showTipTime == 0 || curTime - showTipTime > 5000L) {//5秒内只提示一次
|
|
|
+ showTipTime = curTime;
|
|
|
+ G.shortToast("当前网络不可用,请检查网络情况");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void onError(Throwable e) {
|
|
|
try {
|