Commit 4304aa39 by sikang

bug fix

parent 9088e96f
package tech.starwin.impl;
import android.text.TextUtils;
import com.google.gson.Gson;
import org.greenrobot.eventbus.EventBus;
......@@ -23,14 +25,16 @@ import tech.starwin.utils.LoginManager;
* HTTP请求回调
*/
public abstract class HttpObserver<T> implements Observer<T> {
private String action;
private String action = "";
public HttpObserver() {
}
public HttpObserver(String action) {
this.action = action;
if (action != null) {
this.action = action;
}
}
private Disposable disposable;
......@@ -52,15 +56,19 @@ public abstract class HttpObserver<T> implements Observer<T> {
@Override
public void onNext(T tResult) {
onFinish();
onSuccess(tResult);
try {
onFinish();
onSuccess(tResult);
} catch (Exception e) {
onError(Error.UNKNOW, action + " error");
}
}
@Override
public void onError(Throwable throwable) {
onFinish();
String msg = throwable.getMessage();
LogUtils.d("HttpObserver", action+" -> error msg : " + msg);
LogUtils.d("HttpObserver", action + " -> error msg : " + msg);
try {
if (throwable != null) {
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