import androidx.annotation.NonNull;
+import net.osdn.gokigen.a01d.camera.ILiveViewControl;
import net.osdn.gokigen.a01d.camera.theta.wrapper.IThetaSessionIdProvider;
import net.osdn.gokigen.a01d.camera.utils.SimpleHttpClient;
import net.osdn.gokigen.a01d.liveview.IAutoFocusFrameDisplay;
{
private final String TAG = toString();
private final IThetaSessionIdProvider sessionIdProvider;
- private final IAutoFocusFrameDisplay frameDisplayer;
+ private final ILiveViewControl liveViewControl;
+ private final IIndicatorControl indicator;
private boolean useThetaV21 = false;
private int timeoutMs = 6000;
- public ThetaSingleShotControl(@NonNull Context context, @NonNull final IThetaSessionIdProvider sessionIdProvider, @NonNull IAutoFocusFrameDisplay frameDisplayer, @NonNull IIndicatorControl indicator)
+ public ThetaSingleShotControl(@NonNull Context context, @NonNull final IThetaSessionIdProvider sessionIdProvider, @NonNull IIndicatorControl indicator, @NonNull ILiveViewControl liveViewControl)
{
this.sessionIdProvider = sessionIdProvider;
- this.frameDisplayer = frameDisplayer;
+ this.liveViewControl = liveViewControl;
+ this.indicator = indicator;
try
{
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
Log.v(TAG, "singleShot()");
try
{
- Thread thread = new Thread(new Runnable()
+ final Thread thread = new Thread(new Runnable()
{
@Override
public void run()
{
Log.v(TAG, "singleShot() reply is null.");
}
+ else
+ {
+ Log.v(TAG, " singleShot() : " + result);
+ indicator.onShootingStatusUpdate(IIndicatorControl.shootingStatus.Starting);
+
+ // TODO: 画像処理が終わるまで待つ
+ waitMs(2000);
+
+ // ライブビューのの再実行を指示する
+ indicator.onShootingStatusUpdate(IIndicatorControl.shootingStatus.Stopping);
+ liveViewControl.stopLiveView();
+ waitMs(500);
+ liveViewControl.startLiveView();
+ }
}
catch (Exception e)
{
e.printStackTrace();
}
- frameDisplayer.hideFocusFrame();
}
});
thread.start();
e.printStackTrace();
}
}
+
+ private void waitMs(int waitMs)
+ {
+ try
+ {
+ Thread.sleep(waitMs);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
}
import androidx.annotation.NonNull;
import net.osdn.gokigen.a01d.camera.ICaptureControl;
-import net.osdn.gokigen.a01d.camera.olympuspen.operation.OlympusPenSingleShotControl;
-import net.osdn.gokigen.a01d.camera.panasonic.operation.PanasonicCameraCaptureControl;
-import net.osdn.gokigen.a01d.camera.panasonic.operation.takepicture.SingleShotControl;
-import net.osdn.gokigen.a01d.camera.panasonic.wrapper.IPanasonicCamera;
+import net.osdn.gokigen.a01d.camera.ILiveViewControl;
import net.osdn.gokigen.a01d.camera.theta.operation.ThetaSingleShotControl;
-import net.osdn.gokigen.a01d.liveview.IAutoFocusFrameDisplay;
import net.osdn.gokigen.a01d.liveview.IIndicatorControl;
public class ThetaCaptureControl implements ICaptureControl
private static final String TAG = ThetaCaptureControl.class.getSimpleName();
private final ThetaSingleShotControl singleShotControl;
- public ThetaCaptureControl(@NonNull Context context, @NonNull final IThetaSessionIdProvider sessionIdProvider, @NonNull IAutoFocusFrameDisplay frameDisplayer, @NonNull IIndicatorControl indicator)
+ ThetaCaptureControl(@NonNull Context context, @NonNull final IThetaSessionIdProvider sessionIdProvider, @NonNull IIndicatorControl indicator, @NonNull ILiveViewControl liveViewControl)
{
- singleShotControl = new ThetaSingleShotControl(context, sessionIdProvider, frameDisplayer, indicator);
+ singleShotControl = new ThetaSingleShotControl(context, sessionIdProvider, indicator, liveViewControl);
}
/**
{
Log.v(TAG, "injectDisplay()");
focusControl = new ThetaFocusControl(frameDisplayer);
- captureControl = new ThetaCaptureControl(activity, this, frameDisplayer, indicator);
+ captureControl = new ThetaCaptureControl(activity, this, indicator, liveViewControl);
}
@Override
@Override
public void startLiveView()
{
- Log.v(TAG, "startLiveView()");
+ Log.v(TAG, " startLiveView()");
//prepare();
try
{
String response2 = SimpleHttpClient.httpPost(getStateUrl, "", TIMEOUT_MS);
Log.v(TAG, " " + getStateUrl + " " + response2);
-
- onConnectNotify();
+ if (response2.length() > 0)
+ {
+ try
+ {
+ JSONObject object = new JSONObject(response2);
+ String sessionId = object.getJSONObject("state").getString("sessionId");
+ sessionIdNotifier.receivedSessionId(sessionId);
+ onConnectNotify();
+ return;
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ // 応答なし、を応答する。
+ onConnectError(context.getString(R.string.theta_connect_response_ng));
}
catch (Exception e)
{
<string name="pref_use_osc_theta_v21">THETA Web API v2.1の使用</string>
<string name="pref_summary_use_osc_theta_v21"> </string>
+ <string name="theta_connect_response_ng">応答がありません。</string>
</resources>
<string name="pref_use_osc_theta_v21">Use THETA Web API v2.1</string>
<string name="pref_summary_use_osc_theta_v21"> </string>
+ <string name="theta_connect_response_ng">Did not receive any response.</string>
</resources>