package cn.dankal.basiclib.rx;

import android.util.Log;

//import com.hyphenate.chat.EMClient;

import cn.dankal.basiclib.DKUserManager;
import cn.dankal.basiclib.DankalApplication;
import cn.dankal.basiclib.R;
import cn.dankal.basiclib.domain.HttpStatusCode;
import cn.dankal.basiclib.exception.ApiException;
import cn.dankal.basiclib.exception.LocalException;
import cn.dankal.basiclib.util.ActivityUtils;
import cn.dankal.basiclib.util.ToastUtils;
import io.reactivex.Observer;

/**
 * @author Dankal Android Developer
 * @since 2018/7/18
 */

public abstract class NormalSubscriber<T> implements Observer<T> {

    @Override
    public void onError(Throwable e) {

        if (e instanceof LocalException){
            LocalException localException= (LocalException) e;
            ToastUtils.showLong(localException.getMsg());
        }else if (e instanceof ApiException){
            ApiException exception= (ApiException) e;
            ToastUtils.showLong(exception.getMessage());
        }else {
            ToastUtils.showLong(e.getLocalizedMessage());
        }

        onComplete();

    }

    @Override
    public void onComplete() {
    }
}
