package com.mints.goodmoney.mvp.presenters;

import android.app.Activity;

import com.mints.goodmoney.MintsApplication;
import com.mints.goodmoney.mvp.model.BaseResponse;
import com.mints.goodmoney.mvp.views.VedioAdManagerView;
import com.mints.goodmoney.net.LoanService;
import com.mints.library.net.neterror.BaseSubscriber;
import com.mints.library.net.neterror.Throwable;

import java.util.HashMap;

import rx.Subscription;
import rx.android.schedulers.AndroidSchedulers;

public class CsjFullVedioAdPresenter extends BasePresenter<VedioAdManagerView>{

    private MintsApplication loanApplication;
    private LoanService loanService;
    private Subscription subscription;

    /**
     * 检验立言任务是否重复
     */
    public void reportAddCoinMsg(Activity activity, HashMap<String, Object> vo) {
        if (activity == null)
            return;

        loanApplication = (MintsApplication) activity.getApplication();
        loanService = loanApplication.getLoanService();

        subscription = loanService.reportAddCoinMsg(vo)
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(loanApplication.defaultSubscribeScheduler())
                .subscribe(new BaseSubscriber<BaseResponse<Object>>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {
//                        view.checkLYContextSuc(false);
                    }

                    @Override
                    public void onNext(BaseResponse<Object> baseResponse) {

//                        int code = baseResponse.getStatus();
//                        String message = baseResponse.getMessage();
//                        switch (code) {
//                            case 200://成功
//                                view.checkLYContextSuc(true);
//                                break;
//                            case 611://重复
//                                view.checkLYContextSuc(false);
//                                break;
//                            default:
//                                break;
//                        }
                    }
                });
    }

    public void dispose() {
        loanService = null;
        loanApplication = null;
        if (subscription != null && !subscription.isUnsubscribed()) {
            subscription.unsubscribe();
        }
    }


}
