X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=wear%2Fsrc%2Fmain%2Fjava%2Fjp%2Fsfjp%2Fgokigen%2Fa01c%2FMainActivity.java;h=90089acf6d5e68f2d498b348bf4d8bc3f9f98c42;hb=1aaf0858f9f4d0a7d0d9ac12035fa32ba6935129;hp=83c4f5d01601a19be6295ddb58ff03c6fa74988f;hpb=8d2417f9da4a156b525a4d4e82bf58b98ab9fff5;p=gokigen%2FA01c.git diff --git a/wear/src/main/java/jp/sfjp/gokigen/a01c/MainActivity.java b/wear/src/main/java/jp/sfjp/gokigen/a01c/MainActivity.java index 83c4f5d..90089ac 100644 --- a/wear/src/main/java/jp/sfjp/gokigen/a01c/MainActivity.java +++ b/wear/src/main/java/jp/sfjp/gokigen/a01c/MainActivity.java @@ -37,7 +37,7 @@ import jp.sfjp.gokigen.a01c.thetacamerawrapper.ThetaCameraController; * メインのActivity * */ -public class MainActivity extends AppCompatActivity implements IChangeScene, IShowInformation, ICameraStatusReceiver, IDialogDismissedNotifier +public class MainActivity extends AppCompatActivity implements IChangeScene, IShowInformation, ICameraStatusReceiver, IDialogDismissedNotifier, ICameraStatusUpdateNotify { private final String TAG = toString(); static final int REQUEST_NEED_PERMISSIONS = 1010; @@ -423,6 +423,13 @@ public class MainActivity extends AppCompatActivity implements IChangeScene, IS // ライブビューを停止させる currentCoordinator.stopLiveView(); + // ステータス監視を止める + ICameraStatusWatcher watcher = currentCoordinator.getStatusWatcher(); + if (watcher != null) + { + watcher.stopStatusWatch(); + } + // パラメータを確認し、カメラの電源を切る if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean(IPreferenceCameraPropertyAccessor.EXIT_APPLICATION_WITH_DISCONNECT, true)) { @@ -522,6 +529,11 @@ public class MainActivity extends AppCompatActivity implements IChangeScene, IS listener.setEnableOperation(operation.ENABLE); setMessage(IShowInformation.AREA_C, Color.WHITE, ""); currentCoordinator.updateStatusAll(); + ICameraStatusWatcher watcher = currentCoordinator.getStatusWatcher(); + if (watcher != null) + { + watcher.startStatusWatch(this); + } } catch (Exception e) { @@ -933,4 +945,39 @@ public class MainActivity extends AppCompatActivity implements IChangeScene, IS } }); } + + @Override + public void updateCameraStatus(String message) + { + try + { + setMessage(IShowInformation.AREA_8, Color.WHITE, message); + } + catch (Exception ee) + { + ee.printStackTrace(); + } + } + + @Override + public void updateRemainBattery(double percentageDouble) + { + int color = Color.YELLOW; + if (percentageDouble < 0.5d) + { + if (percentageDouble < 0.3d) + { + color = Color.RED; + } + try + { + int percentage = (int) Math.ceil(percentageDouble * 100.0d); + setMessage(IShowInformation.AREA_7, color, "Bat: " + percentage + "%"); + } + catch (Exception ee) + { + ee.printStackTrace(); + } + } + } }