package ai.pai.lensman.session;

import android.app.Activity;

import java.util.ArrayList;

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

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

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

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

    @Override
    public void onSessionComplete() {
        context.finish();

    }

    @Override
    public void scanToFetchSessionQR() {

    }

    @Override
    public void showQRCodeForSession() {

    }

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

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