package com.duben.microtribe.manager;

import com.duben.microtribe.MintsApplication;
import com.duben.microtribe.mvp.model.VedioBean;
import com.duben.microtribe.mvp.presenters.TrackPresenter;

import java.util.HashMap;

/**
 * 描述：离线管理器
 */
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 visitorlogin() {
        if (trackPresenter != null) {
            trackPresenter.visitorlogin();
        }
    }

    public void firstShowVedio() {
        if (trackPresenter != null) {
            trackPresenter.firstShowVedio();
        }
    }

    public void commitVedio(VedioBean data) {
        if (trackPresenter != null) {
            HashMap<String, Object> vo = new HashMap<>();
            vo.put("vedioIndex", data.getSeeIndex());
            vo.put("vedioId", data.getVedioId());
            vo.put("thirdId", data.getThirdId());
            trackPresenter.commitVedio(vo);
        }
    }

    public void collect(String vedioId) {
        if (trackPresenter != null) {
            trackPresenter.collect(vedioId);
        }
    }

    public void cancelCollect(String vedioId) {
        if (trackPresenter != null) {
            trackPresenter.cancelCollect(vedioId);
        }
    }

    public void getMyInfo() {
        if (trackPresenter != null) {
            trackPresenter.getMyInfo();
        }
    }

    public void commitCsjShotInfo(String json) {
        if (trackPresenter != null) {
            trackPresenter.commitCsjShotInfo(json);
        }
    }
}
