package com.mints.goodmoney.manager;


import android.text.TextUtils;

import com.mints.goodmoney.MintsApplication;
import com.mints.goodmoney.mvp.presenters.TrackPresenter;

/**
 * 描述：离线管理器
 */
public class TrackManager {

    private static volatile TrackManager _inst;

    private TrackPresenter trackPresenter = null;

    public static TrackManager getInstance() {
        if (_inst == null) {
            synchronized (TrackManager.class) {
                if (_inst == null) {
                    _inst = new TrackManager();
                }
            }
        }
        return _inst;
    }

    private TrackManager() {
        init();
    }

    private void init() {
        trackPresenter = new TrackPresenter();
        trackPresenter.attachView((MintsApplication) MintsApplication.getContext());
    }

    /**
     * 离线收益
     */
    public void offline() {
        if (trackPresenter != null &&
                UserManager.getInstance().userIsLogin() &&
                !TextUtils.isEmpty(UserManager.getInstance().getTokenID())) {
            trackPresenter.offline();
        }
    }

    /**
     * 广告事件
     */
    public void addCallImp(String adSource, String eventType, String errorcode, String errormsg) {
        if (trackPresenter != null) {
            trackPresenter.addCallImp(adSource, eventType, errorcode, errormsg);
        }
    }
}
