package com.hi.music.player.network;

import com.hi.music.player.api.RequestListener;
import com.hi.music.player.helper.CommonUtils;

import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;

public class ObserverWrapper<T> implements Observer<T> {
    private RequestListener<T> requestListener;

    public ObserverWrapper(RequestListener<T> requestListener) {
        this.requestListener = requestListener;
    }

    @Override
    public void onSubscribe(Disposable d) {
        CommonUtils.LogMsg("----------onSubscribe");
    }

    @Override
    public void onNext(T t) {
        CommonUtils.LogMsg("----------onNext");
        requestListener.onSuccess(t);
    }

    @Override
    public void onError(Throwable e) {
        CommonUtils.LogMsg("----------onError"+e.getMessage());
        requestListener.onFail(e.getMessage());
    }

    @Override
    public void onComplete() {
        CommonUtils.LogMsg("----------onComplete");
    }
}

