package com.tjzhxx.union.public_store.rx;


import android.app.ProgressDialog;
import android.content.Context;

import com.tjzhxx.union.public_store.FNNetwork;
import com.tjzhxx.union.system.HodingView;
import com.tjzhxx.union.system.MyApplication;

import io.reactivex.disposables.Disposable;

/**
 * 描述:
 * @author yanghuaxiong
 * @create 2018/6/11 上午10:29
 * 
 */
public abstract class ProgressSubscriber<T> extends DefaultSubscriber<T> {

    private Context mContext;
    ProgressDialog mProgress;
    private boolean isCancelable = false;

    
    public ProgressSubscriber(Context activity) {
        super(activity);
        this.mContext = activity;
    }

    public ProgressSubscriber(Context activity, boolean _isCancelable) {
        super(activity);
        this.mContext = activity;
        this.isCancelable = _isCancelable;
    }

    @Override
    public void onSubscribe(Disposable d) {
        super.onSubscribe(d);
        if (FNNetwork.isConnected(MyApplication.getInstance())) {
            showProgressBar("正在加载...");
        }
    }

    @Override
    public void onError(Throwable e) {
        hideProgressBar();
        super.onError(e);
    }

    @Override
    public void onComplete() {
        hideProgressBar();
    }

    public void showProgressBar(String message) {
        HodingView.build().setContext(mContext).show(message);
    }

    public void hideProgressBar() {
        HodingView.build().hide();
    }


}
