package ai.pai.lensman.session;

import android.content.Context;

import java.util.ArrayList;

import ai.pai.lensman.bean.PhotoBean;

public class SessionPresenterImpl implements SessionContract.SessionPresenter ,SessionInteractor.SessionListener{

    private Context context;
    private SessionInteractor interactor;
    private ArrayList<PhotoBean> photoList;
    private SessionContract.SessionView sessionView;

    public SessionPresenterImpl(Context context,String sessionId, SessionContract.SessionView view){
        this.context = context;
        this.sessionView = view;
        photoList = new ArrayList<>();
        interactor = new SessionInteractor(context,sessionId,this);
    }

    @Override
    public void start() {
        interactor.startSession();
        if(photoList.size()==0){
            sessionView.showEmptyView();
        }else{
            sessionView.showPhotoRecyclerView();
        }
    }

    @Override
    public void stop() {
        interactor.endSession();
    }

    @Override
    public void onSessionStartSuccess(String session) {

    }

    @Override
    public void onSessionStartError(String session) {

    }

    @Override
    public void onSessionPhotoCaptured(final PhotoBean bean) {
        sessionView.showPhotoRecyclerView();
        sessionView.addNewPhoto(bean);
    }

    @Override
    public void onSessionEnd(String session) {

    }
}
