package ai.pai.lensman.upload;

import android.app.Activity;
import android.content.Intent;

import java.util.ArrayList;

import ai.pai.lensman.bean.SessionBean;
import ai.pai.lensman.session.SessionActivity;

public class UploadPresenterImpl implements UploadContract.UploadPresenter {

    private Activity activity;
    private UploadContract.UploadView uploadView;
    private ArrayList<SessionBean> sessionList;

    private int seq = 0;
    public UploadPresenterImpl(Activity activity,UploadContract.UploadView view){
        this.activity = activity;
        this.uploadView = view;
        sessionList = new ArrayList<>();
    }

    @Override
    public void checkBTStatus() {

    }

    @Override
    public void start() {
        if(sessionList.size()==0){
            uploadView.showEmptyView();
        }else{
            uploadView.showSessionViews();
            uploadView.refreshSessionViews(sessionList);
        }
    }

    @Override
    public void stop() {

    }


    @Override
    public void jumpToBriefs() {

    }

    @Override
    public void jumpToNewSession() {
        seq ++;
        SessionBean sessionBean = new SessionBean();
        sessionBean.sessionSeq = seq;
        sessionList.add(sessionBean);
       jumpToSelectedSession(sessionBean);
    }

    @Override
    public void jumpToSelectedSession(SessionBean sessionBean) {
        Intent intent = new Intent(activity, SessionActivity.class);
        intent.putExtra("session",sessionBean);
        activity.startActivity(intent);
    }

}
