1 package jp.sfjp.gokigen.a01c.olycamerawrapper.takepicture;
3 import android.graphics.RectF;
4 import android.util.Log;
6 import java.util.HashMap;
7 import jp.co.olympus.camerakit.OLYCamera;
8 import jp.co.olympus.camerakit.OLYCameraAutoFocusResult;
9 import jp.sfjp.gokigen.a01c.IShowInformation;
10 import jp.sfjp.gokigen.a01c.liveview.IAutoFocusFrameDisplay;
11 import jp.sfjp.gokigen.a01c.olycamerawrapper.IIndicatorControl;
16 * Created by MRSa on 2016/06/18.
18 public class SingleShotControl implements OLYCamera.TakePictureCallback
20 private final String TAG = toString();
21 //private final Context context;
22 private final OLYCamera camera;
23 private final IIndicatorControl indicator;
24 private final IAutoFocusFrameDisplay frameDisplayer;
25 private final IShowInformation statusDrawer;
31 public SingleShotControl(OLYCamera camera, IAutoFocusFrameDisplay frameInfo, IIndicatorControl indicator, IShowInformation statusDrawer)
33 //this.context = context;
35 this.indicator = indicator;
36 this.frameDisplayer = frameInfo;
37 this.statusDrawer = statusDrawer;
44 public void singleShot()
48 camera.takePicture(new HashMap<String, Object>(), this);
57 public void onProgress(OLYCamera olyCamera, OLYCamera.TakingProgress takingProgress, OLYCameraAutoFocusResult olyCameraAutoFocusResult)
59 if (takingProgress != OLYCamera.TakingProgress.EndFocusing)
64 String result = olyCameraAutoFocusResult.getResult();
67 Log.v(TAG, "FocusResult is null.");
72 RectF postFocusFrameRect = olyCameraAutoFocusResult.getRect();
73 if (postFocusFrameRect != null)
75 showFocusFrame(postFocusFrameRect, IAutoFocusFrameDisplay.FocusFrameStatus.Focused, 0.0);
87 public void onCompleted()
91 camera.clearAutoFocusPoint();
94 statusDrawer.vibrate(IShowInformation.VIBRATE_PATTERN_SIMPLE_MIDDLE);
97 //Toast.makeText(context, R.string.shoot_camera, Toast.LENGTH_SHORT).show();
107 public void onErrorOccurred(Exception e)
111 camera.clearAutoFocusPoint();
114 statusDrawer.vibrate(IShowInformation.VIBRATE_PATTERN_SIMPLE_SHORT);
117 //Toast.makeText(context, R.string.shoot_camera_failure, Toast.LENGTH_SHORT).show();
122 ee.printStackTrace();
127 private void showFocusFrame(RectF rect, IAutoFocusFrameDisplay.FocusFrameStatus status, double duration)
129 if (frameDisplayer != null)
131 frameDisplayer.showFocusFrame(rect, status, duration);
133 indicator.onAfLockUpdate(IAutoFocusFrameDisplay.FocusFrameStatus.Focused == status);
136 private void hideFocusFrame()
138 if (frameDisplayer != null)
140 frameDisplayer.hideFocusFrame();
142 indicator.onAfLockUpdate(false);