package ai.pai.lensman.session;

import java.util.Timer;
import java.util.TimerTask;

/**
 * Created by chengzhenyu on 2016/7/7.
 */
public class SessionInteractor {

    private Timer timer;
    private SessionListener listener;

    public SessionInteractor(SessionListener listener) {
        this.listener = listener;
    }

    public interface SessionListener {

        void onSessionPhotoCaptured(PhotoBean bean);
    }

    public void startCapture() {
        if (timer != null) {
            return;
        }
        timer = new Timer();
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                if (listener != null) {
                    listener.onSessionPhotoCaptured(new PhotoBean());
                }
            }
        }, 1000, 1000);
    }

    public void stopCapture(){
        if(timer!=null){
            timer.cancel();
            timer = null;
        }
    }

}
