Commit 4304aa39 by sikang

bug fix

parent 9088e96f
package tech.starwin.impl; package tech.starwin.impl;
import android.text.TextUtils;
import com.google.gson.Gson; import com.google.gson.Gson;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
...@@ -23,14 +25,16 @@ import tech.starwin.utils.LoginManager; ...@@ -23,14 +25,16 @@ import tech.starwin.utils.LoginManager;
* HTTP请求回调 * HTTP请求回调
*/ */
public abstract class HttpObserver<T> implements Observer<T> { public abstract class HttpObserver<T> implements Observer<T> {
private String action; private String action = "";
public HttpObserver() { public HttpObserver() {
} }
public HttpObserver(String action) { public HttpObserver(String action) {
this.action = action; if (action != null) {
this.action = action;
}
} }
private Disposable disposable; private Disposable disposable;
...@@ -52,15 +56,19 @@ public abstract class HttpObserver<T> implements Observer<T> { ...@@ -52,15 +56,19 @@ public abstract class HttpObserver<T> implements Observer<T> {
@Override @Override
public void onNext(T tResult) { public void onNext(T tResult) {
onFinish(); try {
onSuccess(tResult); onFinish();
onSuccess(tResult);
} catch (Exception e) {
onError(Error.UNKNOW, action + " error");
}
} }
@Override @Override
public void onError(Throwable throwable) { public void onError(Throwable throwable) {
onFinish(); onFinish();
String msg = throwable.getMessage(); String msg = throwable.getMessage();
LogUtils.d("HttpObserver", action+" -> error msg : " + msg); LogUtils.d("HttpObserver", action + " -> error msg : " + msg);
try { try {
if (throwable != null) { if (throwable != null) {
if (isNetworkError(msg)) { if (isNetworkError(msg)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment