OSDN Git Service

8c0632760873c2e6ae0da691a852d5c35175e134
[gokigen/Gr2Control.git] / app / src / main / java / net / osdn / gokigen / gr2control / liveview / LiveViewFragment.java
1 package net.osdn.gokigen.gr2control.liveview;
2
3 import android.app.Activity;
4 import android.content.Context;
5 import android.content.SharedPreferences;
6 import android.os.Bundle;
7 import android.os.Vibrator;
8 import android.support.annotation.NonNull;
9 import android.support.v4.app.Fragment;
10 import android.support.v4.content.res.ResourcesCompat;
11 import android.support.v7.app.ActionBar;
12 import android.support.v7.app.AppCompatActivity;
13 import android.support.v7.preference.PreferenceManager;
14 import android.util.Log;
15 import android.view.LayoutInflater;
16 import android.view.View;
17 import android.view.ViewGroup;
18 import android.widget.Button;
19 import android.widget.ImageButton;
20 import android.widget.ImageView;
21 import android.widget.TextView;
22
23 import net.osdn.gokigen.gr2control.R;
24 import net.osdn.gokigen.gr2control.camera.ICameraConnection;
25 import net.osdn.gokigen.gr2control.camera.ICameraInformation;
26 import net.osdn.gokigen.gr2control.camera.ICameraRunMode;
27 import net.osdn.gokigen.gr2control.camera.ICameraStatusWatcher;
28 import net.osdn.gokigen.gr2control.camera.IDisplayInjector;
29 import net.osdn.gokigen.gr2control.camera.IFocusingModeNotify;
30 import net.osdn.gokigen.gr2control.camera.IInterfaceProvider;
31 import net.osdn.gokigen.gr2control.camera.ILiveViewControl;
32 import net.osdn.gokigen.gr2control.camera.IZoomLensControl;
33 import net.osdn.gokigen.gr2control.liveview.liveviewlistener.ILiveViewListener;
34 import net.osdn.gokigen.gr2control.preference.IPreferencePropertyAccessor;
35 import net.osdn.gokigen.gr2control.scene.IChangeScene;
36
37 import static android.content.Context.VIBRATOR_SERVICE;
38
39 /**
40  *  撮影用ライブビュー画面
41  *
42  */
43 public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFocusingModeNotify, IFavoriteSettingDialogKicker, ICameraStatusUpdateNotify
44 {
45     private final String TAG = this.toString();
46
47     private ILiveViewControl liveViewControl = null;
48     //private IZoomLensControl zoomLensControl = null;
49     private IInterfaceProvider interfaceProvider = null;
50     private IDisplayInjector interfaceInjector = null;
51     //private OlympusCameraLiveViewListenerImpl liveViewListener = null;
52     private IChangeScene changeScene = null;
53     private ICameraInformation cameraInformation = null;
54     private ICameraStatusWatcher statusWatcher = null;
55     private LiveViewClickTouchListener onClickTouchListener = null;
56     private LiveViewControlPanelClickListener onPanelClickListener = null;
57     private LiveViewKeyPanelClickListener onKeyPanelClickListener = null;
58
59     private TextView statusArea = null;
60     private TextView focalLengthArea = null;
61     private CameraLiveImageView imageView = null;
62
63     private ImageView manualFocus = null;
64     private ImageButton showGrid = null;
65     private ImageView connectStatus = null;
66     private Button changeLiveViewScale = null;
67
68     private boolean imageViewCreated = false;
69     private View myView = null;
70     private String messageValue = "";
71
72     private ICameraConnection.CameraConnectionStatus currentConnectionStatus =  ICameraConnection.CameraConnectionStatus.UNKNOWN;
73
74     public static LiveViewFragment newInstance(IChangeScene sceneSelector, @NonNull IInterfaceProvider provider)
75     {
76         LiveViewFragment instance = new LiveViewFragment();
77         instance.prepare(sceneSelector, provider);
78
79         // パラメータはBundleにまとめておく
80         Bundle arguments = new Bundle();
81         //arguments.putString("title", title);
82         //arguments.putString("message", message);
83         instance.setArguments(arguments);
84
85         return (instance);
86     }
87
88     /**
89      *
90      *
91      */
92     @Override
93     public void onCreate(Bundle savedInstanceState)
94     {
95         super.onCreate(savedInstanceState);
96         Log.v(TAG, "onCreate()");
97 /*
98         if (liveViewListener == null)
99         {
100             liveViewListener = new OlympusCameraLiveViewListenerImpl();
101         }
102 */
103     }
104
105     /**
106      *
107      *
108      */
109     @Override
110     public void onAttach(Context context)
111     {
112         super.onAttach(context);
113         Log.v(TAG, "onAttach()");
114     }
115
116     /**
117      *
118      *
119      */
120     @Override
121     public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
122     {
123         super.onCreateView(inflater, container, savedInstanceState);
124
125         Log.v(TAG, "onCreateView()");
126         if ((imageViewCreated)&&(myView != null))
127         {
128             // Viewを再利用。。。
129             Log.v(TAG, "onCreateView() : called again, so do nothing... : " + myView);
130             return (myView);
131         }
132
133         View view = inflater.inflate(R.layout.fragment_live_view, container, false);
134         myView = view;
135         imageViewCreated = true;
136         try
137         {
138
139             imageView = view.findViewById(R.id.cameraLiveImageView);
140             if (interfaceInjector != null)
141             {
142                 interfaceInjector.injectDisplay(imageView, imageView, this);
143             }
144             else
145             {
146                 Log.v(TAG, "interfaceInjector is NULL...");
147             }
148             Activity activity = this.getActivity();
149             Vibrator vibrator = (activity != null) ? (Vibrator) activity.getSystemService(VIBRATOR_SERVICE) : null;
150             if ((onClickTouchListener == null)&&(activity != null))
151             {
152                 onClickTouchListener = new LiveViewClickTouchListener(activity, imageView, this, changeScene, interfaceProvider, this);
153             }
154             imageView.setOnClickListener(onClickTouchListener);
155             imageView.setOnTouchListener(onClickTouchListener);
156
157             setOnClickListener(view, R.id.hideControlPanelTextView);
158             setOnClickListener(view, R.id.showControlPanelTextView);
159             setOnClickListener(view, R.id.showKeyPanelImageView);
160             setOnClickListener(view, R.id.hideKeyPanelTextView);
161             setOnClickListener(view, R.id.shutter_button);
162             setOnClickListener(view, R.id.focusUnlockImageView);
163             setOnClickListener(view, R.id.show_images_button);
164             setOnClickListener(view, R.id.camera_power_off_button);
165             setOnClickListener(view, R.id.show_preference_button);
166
167             if (onPanelClickListener == null)
168             {
169                 onPanelClickListener = new LiveViewControlPanelClickListener(activity, interfaceProvider);
170             }
171             setPanelClickListener(view, R.id.takemodeTextView);
172             setPanelClickListener(view, R.id.shutterSpeedTextView);
173             setPanelClickListener(view, R.id.apertureValueTextView);
174             setPanelClickListener(view, R.id.exposureCompensationTextView);
175             setPanelClickListener(view, R.id.aeModeTextView);
176             setPanelClickListener(view, R.id.whiteBalanceImageView);
177             setPanelClickListener(view, R.id.setEffectImageView);
178
179             if (onKeyPanelClickListener == null)
180             {
181                 onKeyPanelClickListener = new LiveViewKeyPanelClickListener(interfaceProvider, vibrator);
182             }
183             setKeyPanelClickListener(view, R.id.button_front_left);
184             setKeyPanelClickListener(view, R.id.button_front_right);
185             setKeyPanelClickListener(view, R.id.button_adjust_left);
186             setKeyPanelClickListener(view, R.id.button_adjust_enter);
187             setKeyPanelClickListener(view, R.id.button_adjust_right);
188             setKeyPanelClickListener(view, R.id.button_toggle_aeaf);
189             setKeyPanelClickListener(view, R.id.lever_ael_caf);
190             setKeyPanelClickListener(view, R.id.button_up);
191             setKeyPanelClickListener(view, R.id.button_left);
192             setKeyPanelClickListener(view, R.id.button_center_enter);
193             setKeyPanelClickListener(view, R.id.button_right);
194             setKeyPanelClickListener(view, R.id.button_down);
195             setKeyPanelClickListener(view, R.id.button_function_1);
196             setKeyPanelClickListener(view, R.id.button_function_2);
197             setKeyPanelClickListener(view, R.id.button_function_3);
198             setKeyPanelClickListener(view, R.id.button_plus);
199             setKeyPanelClickListener(view, R.id.button_minus);
200             setKeyPanelClickListener(view, R.id.button_playback);
201
202             /*
203             view.findViewById(R.id.show_preference_button).setOnClickListener(onClickTouchListener);
204             view.findViewById(R.id.camera_property_settings_button).setOnClickListener(onClickTouchListener);
205             view.findViewById(R.id.shutter_button).setOnClickListener(onClickTouchListener);
206             view.findViewById(R.id.btn_zoomin).setOnClickListener(onClickTouchListener);
207             view.findViewById(R.id.btn_zoomout).setOnClickListener(onClickTouchListener);
208
209             manualFocus = view.findViewById(R.id.focusing_button);
210             changeLiveViewScale = view.findViewById(R.id.live_view_scale_button);
211
212             ICameraConnection.CameraConnectionMethod connectionMethod = interfaceProvider.getCammeraConnectionMethod();
213
214             if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
215             {
216                 view.findViewById(R.id.show_favorite_settings_button).setOnClickListener(onClickTouchListener);
217             }
218             else
219             {
220                 // お気に入りボタン(とMFボタン)は、SONYモード, RICOH GR2モードのときには表示しない
221                 final View favoriteButton = view.findViewById(R.id.show_favorite_settings_button);
222                 final View propertyButton = view.findViewById(R.id.camera_property_settings_button);
223                 if ((favoriteButton != null)&&(manualFocus != null))
224                 {
225                     runOnUiThread(new Runnable()
226                     {
227                         @Override
228                         public void run()
229                         {
230                             favoriteButton.setVisibility(View.INVISIBLE);
231                             if (manualFocus != null)
232                             {
233                                 manualFocus.setVisibility(View.INVISIBLE);
234                             }
235                             propertyButton.setVisibility(View.INVISIBLE);
236                         }
237                     });
238                 }
239                 if (connectionMethod == ICameraConnection.CameraConnectionMethod.SONY)
240                 {
241                     if (changeLiveViewScale != null)
242                     {
243                         changeLiveViewScale.setVisibility(View.INVISIBLE);
244                     }
245                 }
246                 else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH_GR2)
247                 {
248                     if (changeLiveViewScale != null)
249                     {
250                         changeLiveViewScale.setVisibility(View.VISIBLE);
251                     }
252                 }
253             }
254
255             if (manualFocus != null)
256             {
257                 manualFocus.setOnClickListener(onClickTouchListener);
258             }
259             changedFocusingMode();
260
261             if (changeLiveViewScale != null)
262             {
263                 changeLiveViewScale.setOnClickListener(onClickTouchListener);
264             }
265
266             showGrid = view.findViewById(R.id.show_hide_grid_button);
267             showGrid.setOnClickListener(onClickTouchListener);
268             updateGridIcon();
269
270             updateConnectionStatus(ICameraConnection.CameraConnectionStatus.UNKNOWN);
271
272             statusArea = view.findViewById(R.id.informationMessageTextView);
273             focalLengthArea = view.findViewById(R.id.focal_length_with_digital_zoom_view);
274 */
275             connectStatus = view.findViewById(R.id.connect_disconnect_button);
276             if (connectStatus != null)
277             {
278                 connectStatus.setOnClickListener(onClickTouchListener);
279             }
280         }
281         catch (Exception e)
282         {
283             e.printStackTrace();
284         }
285
286         return (view);
287     }
288
289     private void setOnClickListener(View view, int id)
290     {
291         try
292         {
293             View button = view.findViewById(id);
294             if (button != null)
295             {
296                 button.setOnClickListener(onClickTouchListener);
297             }
298         }
299         catch (Exception e)
300         {
301             e.printStackTrace();
302         }
303     }
304
305     private void setPanelClickListener(View view, int id)
306     {
307         try
308         {
309             View button = view.findViewById(id);
310             if (button != null)
311             {
312                 button.setOnClickListener(onPanelClickListener);
313             }
314         }
315         catch (Exception e)
316         {
317             e.printStackTrace();
318         }
319     }
320
321     private void setKeyPanelClickListener(View view, int id)
322     {
323         try
324         {
325             View button = view.findViewById(id);
326             if (button != null)
327             {
328                 button.setOnClickListener(onKeyPanelClickListener);
329             }
330         }
331         catch (Exception e)
332         {
333             e.printStackTrace();
334         }
335     }
336
337     /**
338      *
339      */
340     private void prepare(IChangeScene sceneSelector, IInterfaceProvider interfaceProvider)
341     {
342         Log.v(TAG, "prepare()");
343
344         this.changeScene = sceneSelector;
345         this.interfaceProvider = interfaceProvider;
346         this.interfaceInjector = interfaceProvider.getDisplayInjector();
347         this.liveViewControl = interfaceProvider.getLiveViewControl();
348         //this.zoomLensControl = interfaceProvider.getZoomLensControl();
349         this.cameraInformation = interfaceProvider.getCameraInformation();
350         this.statusWatcher = interfaceProvider.getCameraStatusWatcher();
351     }
352
353     /**
354      *  カメラとの接続状態の更新
355      *
356      */
357     @Override
358     public void updateConnectionStatus(final ICameraConnection.CameraConnectionStatus connectionStatus)
359     {
360         try
361         {
362             currentConnectionStatus = connectionStatus;
363             runOnUiThread(new Runnable()
364             {
365                 @Override
366                 public void run()
367                 {
368                     int id = R.drawable.ic_cloud_off_black_24dp;
369                     if (currentConnectionStatus == ICameraConnection.CameraConnectionStatus.CONNECTING)
370                     {
371                         id = R.drawable.ic_cloud_queue_black_24dp;
372                     }
373                     else if  (currentConnectionStatus == ICameraConnection.CameraConnectionStatus.CONNECTED)
374                     {
375                         id = R.drawable.ic_cloud_done_black_24dp;
376                     }
377                     if (connectStatus != null)
378                     {
379                         connectStatus.setImageDrawable(ResourcesCompat.getDrawable(getResources(), id, null));
380                         connectStatus.invalidate();
381                     }
382                     if (imageView != null)
383                     {
384                         imageView.invalidate();
385                     }
386                 }
387             });
388
389         }
390         catch (Exception e)
391         {
392             e.printStackTrace();
393         }
394     }
395
396     /**
397      *  グリッドの表示・非表示の更新
398      *
399      */
400     @Override
401     public void updateGridIcon()
402     {
403         try
404         {
405             int id = (imageView.isShowGrid()) ? R.drawable.ic_grid_off_black_24dp : R.drawable.ic_grid_on_black_24dp;
406             showGrid.setImageDrawable(ResourcesCompat.getDrawable(getResources(), id, null));
407             showGrid.invalidate();
408             imageView.invalidate();
409         }
410         catch (Exception e)
411         {
412             e.printStackTrace();
413         }
414     }
415
416     /**
417      *   AF/MFの表示を更新する
418      *
419      */
420     @Override
421     public void changedFocusingMode()
422     {
423         try
424         {
425             if ((cameraInformation == null)||(manualFocus == null))
426             {
427                 return;
428             }
429             runOnUiThread(new Runnable()
430             {
431                 @Override
432                 public void run()
433                 {
434                     if (currentConnectionStatus == ICameraConnection.CameraConnectionStatus.CONNECTED)
435                     {
436                         manualFocus.setSelected(cameraInformation.isManualFocus());
437                         manualFocus.invalidate();
438                     }
439                 }
440             });
441         }
442         catch (Exception e)
443         {
444             e.printStackTrace();
445         }
446     }
447
448     @Override
449     public void updateLiveViewScale(boolean isChangeScale)
450     {
451         try
452         {
453             Log.v(TAG, "updateLiveViewScale() : " + isChangeScale);
454
455             // ライブビューの倍率設定
456             liveViewControl.updateMagnifyingLiveViewScale(isChangeScale);
457
458             // ボタンの文字を更新する
459             float scale = liveViewControl.getMagnifyingLiveViewScale();
460             final String datavalue = "LV: " + scale;
461
462             // デジタルズームの倍率を表示する
463             float digitalZoom = liveViewControl.getDigitalZoomScale();
464             final String digitalValue = (digitalZoom > 1.0f) ? "D x" + digitalZoom : "";
465
466             // 更新自体は、UIスレッドで行う
467             runOnUiThread(new Runnable()
468             {
469                 @Override
470                 public void run()
471                 {
472                     changeLiveViewScale.setText(datavalue);
473                     changeLiveViewScale.postInvalidate();
474
475                     focalLengthArea.setText(digitalValue);
476                     focalLengthArea.postInvalidate();
477                 }
478             });
479         }
480         catch (Exception e)
481         {
482             e.printStackTrace();
483         }
484     }
485
486     /**
487      *
488      *
489      *
490      */
491     @Override
492     public void onStart()
493     {
494         super.onStart();
495         Log.v(TAG, "onStart()");
496     }
497
498     /**
499      *
500      *
501      */
502     @Override
503     public void onResume()
504     {
505         super.onResume();
506         Log.v(TAG, "onResume() Start");
507
508         AppCompatActivity activity = (AppCompatActivity)getActivity();
509         if (activity != null)
510         {
511             ActionBar bar = activity.getSupportActionBar();
512             if (bar != null)
513             {
514                 bar.hide();   // ActionBarの表示を消す
515             }
516         }
517
518         // 撮影モードかどうかを確認して、撮影モードではなかったら撮影モードに切り替える
519         ICameraRunMode changeRunModeExecutor = interfaceProvider.getCameraRunMode();
520         if ((changeRunModeExecutor != null)&&(!changeRunModeExecutor.isRecordingMode()))
521         {
522             // Runモードを切り替える。(でも切り替えると、設定がクリアされてしまう...。)
523             changeRunModeExecutor.changeRunMode(true);
524         }
525
526 /*
527         // ステータスの変更を通知してもらう
528         camera.setCameraStatusListener(statusListener);
529
530         // 画面下部の表示エリアの用途を切り替える
531         setupLowerDisplayArea();
532 */
533         // propertyを取得
534         try
535         {
536             Context context = getContext();
537             if (context != null)
538             {
539                 SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getContext());
540
541                 // グリッド・フォーカスアシストの情報を戻す
542                 boolean showGrid = preferences.getBoolean(IPreferencePropertyAccessor.SHOW_GRID_STATUS, false);
543                 if ((imageView != null) && (imageView.isShowGrid() != showGrid)) {
544                     imageView.toggleShowGridFrame();
545                     imageView.postInvalidate();
546                 }
547             }
548             if (currentConnectionStatus == ICameraConnection.CameraConnectionStatus.CONNECTED)
549             {
550                 startLiveView();
551             }
552         }
553         catch (Exception e)
554         {
555             e.printStackTrace();
556         }
557         Log.v(TAG, "onResume() End");
558     }
559
560     /**
561      *
562      *
563      */
564     @Override
565     public void onPause()
566     {
567         super.onPause();
568         Log.v(TAG, "onPause() Start");
569
570         // ライブビューとステータス監視の停止
571         try
572         {
573             liveViewControl.stopLiveView();
574             stopWatchStatus();
575         }
576         catch (Exception e)
577         {
578             e.printStackTrace();
579         }
580
581         Log.v(TAG, "onPause() End");
582     }
583
584     /**
585      *   表示エリアに文字を表示する
586      *
587      */
588     @Override
589     public void updateStatusView(String message)
590     {
591         messageValue = message;
592         runOnUiThread(new Runnable()
593         {
594             /**
595              * カメラの状態(ステータステキスト)を更新する
596              * (ステータステキストは、プライベート変数で保持して、書き換える)
597              */
598             @Override
599             public void run()
600             {
601                 if (statusArea != null)
602                 {
603                     statusArea.setText(messageValue);
604                     statusArea.invalidate();
605                 }
606             }
607         });
608     }
609
610     /**
611      *   ライブビューの開始
612      *
613      */
614     @Override
615     public void startLiveView()
616     {
617         ICameraConnection.CameraConnectionMethod connectionMethod = interfaceProvider.getCammeraConnectionMethod();
618         if (liveViewControl == null)
619         {
620             if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC)
621             {
622                 Log.v(TAG, "startLiveView() : liveViewControl is null.");
623                 return;
624             }
625             else
626             {
627                 // ダミー
628                 prepare(changeScene, interfaceProvider);
629             }
630         }
631         try
632         {
633             // ライブビューの開始
634             Context context = getContext();
635             boolean isCameraScreen = true;
636             if (context != null)
637             {
638                 SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
639                 liveViewControl.changeLiveViewSize(preferences.getString(IPreferencePropertyAccessor.LIVE_VIEW_QUALITY, IPreferencePropertyAccessor.LIVE_VIEW_QUALITY_DEFAULT_VALUE));
640                 isCameraScreen = preferences.getBoolean(IPreferencePropertyAccessor.GR2_DISPLAY_CAMERA_VIEW, true);
641             }
642             ILiveViewListener lvListener = interfaceProvider.getLiveViewListener();
643             if (lvListener != null)
644             {
645                 lvListener.setCameraLiveImageView(imageView);
646             }
647             liveViewControl.startLiveView(isCameraScreen);   // false : ライブビューのみ、 true : カメラ画面をミラー
648
649             // ステータス監視も実施する
650             startWatchStatus();
651         }
652         catch (Exception e)
653         {
654             e.printStackTrace();
655         }
656     }
657
658     @Override
659     public void showFavoriteSettingDialog()
660     {
661         try
662         {
663             Log.v(TAG, "showFavoriteSettingDialog()");
664 /*
665             LoadSaveMyCameraPropertyDialog dialog = new LoadSaveMyCameraPropertyDialog();
666             dialog.setTargetFragment(this, COMMAND_MY_PROPERTY);
667             dialog.setPropertyOperationsHolder(new LoadSaveCameraProperties(getActivity(), interfaceProvider.getOlympusInterface()));
668             FragmentManager manager = getFragmentManager();
669             if (manager != null)
670             {
671                 dialog.show(manager, "my_dialog");
672             }
673 */
674         }
675         catch (Exception e)
676         {
677             e.printStackTrace();
678         }
679     }
680
681     /**
682      *
683      *
684      */
685     private void startWatchStatus()
686     {
687         if (statusWatcher != null)
688         {
689             statusWatcher.startStatusWatch(this);
690         }
691     }
692
693     /**
694      *
695      *
696      */
697     private void stopWatchStatus()
698     {
699         if (statusWatcher != null)
700         {
701             statusWatcher.stoptStatusWatch();
702         }
703     }
704
705     /**
706      *
707      *
708      */
709     private void runOnUiThread(Runnable action)
710     {
711         Activity activity = getActivity();
712         if (activity == null)
713         {
714             return;
715         }
716         activity.runOnUiThread(action);
717     }
718
719     @Override
720     public void updatedTakeMode(final String mode)
721     {
722         try
723         {
724             final Activity activity = getActivity();
725             if (activity == null)
726             {
727                 return;
728             }
729             activity.runOnUiThread(new Runnable()
730             {
731                 @Override
732                 public void run()
733                 {
734                     TextView view = activity.findViewById(R.id.takemodeTextView);
735                     if (view != null)
736                     {
737                         view.setText(mode);
738                         view.invalidate();
739                     }
740                 }
741             });
742         }
743         catch (Exception e)
744         {
745             e.printStackTrace();
746         }
747     }
748
749     @Override
750     public void updatedShutterSpeed(final String tv)
751     {
752         try
753         {
754             final String shutterSpeed = tv.replace(".", "/");
755             final Activity activity = getActivity();
756             if (activity == null)
757             {
758                 return;
759             }
760             activity.runOnUiThread(new Runnable()
761             {
762                 @Override
763                 public void run()
764                 {
765                     TextView view = activity.findViewById(R.id.shutterSpeedTextView);
766                     if (view != null) {
767                         view.setText(shutterSpeed);
768                         view.invalidate();
769                     }
770                 }
771             });
772         }
773         catch (Exception e)
774         {
775             e.printStackTrace();
776         }
777
778     }
779
780     @Override
781     public void updatedAperture(final String av)
782     {
783         try
784         {
785             final String apertureValue = (av.length() > 1) ? ("F" + av) : "";
786             final Activity activity = getActivity();
787             if (activity == null)
788             {
789                 return;
790             }
791             activity.runOnUiThread(new Runnable()
792             {
793                 @Override
794                 public void run()
795                 {
796                     TextView view = activity.findViewById(R.id.apertureValueTextView);
797                     if (view != null)
798                     {
799                         view.setText(apertureValue);
800                         view.invalidate();
801                     }
802                 }
803             });
804         }
805         catch (Exception e)
806         {
807             e.printStackTrace();
808         }
809     }
810
811     @Override
812     public void updatedExposureCompensation(final String xv)
813     {
814         try
815         {
816             final Activity activity = getActivity();
817             if (activity == null)
818             {
819                 return;
820             }
821             activity.runOnUiThread(new Runnable()
822             {
823                 @Override
824                 public void run()
825                 {
826                     TextView view = activity.findViewById(R.id.exposureCompensationTextView);
827                     if (view != null)
828                     {
829                         view.setText(xv);
830                         view.invalidate();
831                     }
832                 }
833             });
834         }
835         catch (Exception e)
836         {
837             e.printStackTrace();
838         }
839     }
840
841     @Override
842     public void updatedMeteringMode(final String meteringMode)
843     {
844         try
845         {
846             final Activity activity = getActivity();
847             if (activity == null)
848             {
849                 return;
850             }
851             activity.runOnUiThread(new Runnable()
852             {
853                 @Override
854                 public void run()
855                 {
856                     TextView view = activity.findViewById(R.id.aeModeTextView);
857                     if (view != null)
858                     {
859                         view.setText(meteringMode);
860                         view.invalidate();
861                     }
862                 }
863             });
864         }
865         catch (Exception e)
866         {
867             e.printStackTrace();
868         }
869     }
870
871     @Override
872     public void updatedWBMode(final String wbMode)
873     {
874         // とりあえず何もしない... 選択肢は以下
875         // auto, multiAuto, daylight, shade, cloud, tungsten, warmWhiteFluorescent, daylightFluorescent, dayWhiteFluorescent, coolWhiteFluorescent, incandescent,manual1, cte, custom
876     }
877
878     /**
879      *   残りバッテリー状態をアイコンで示す
880      *
881      */
882     @Override
883     public void updateRemainBattery(int percentage)
884     {
885         try
886         {
887             final Activity activity = getActivity();
888             if (activity == null)
889             {
890                 return;
891             }
892             int iconId;
893             if (percentage < 20)
894             {
895                 iconId = R.drawable.ic_battery_alert_black_24dp;
896             }
897             else if (percentage < 60)
898             {
899                 iconId = R.drawable.ic_battery_20_black_24dp;
900             }
901             else if (percentage < 80)
902             {
903                 iconId = R.drawable.ic_battery_60_black_24dp;
904             }
905             else
906             {
907                 iconId = R.drawable.ic_battery_full_black_24dp;
908             }
909             final int id = iconId;
910             activity.runOnUiThread(new Runnable()
911             {
912                 @Override
913                 public void run()
914                 {
915                     ImageView view = activity.findViewById(R.id.currentBatteryImageView);
916                     if (view != null)
917                     {
918                         view.setImageDrawable(ResourcesCompat.getDrawable(getResources(), id, null));
919                         view.invalidate();
920                     }
921                 }
922             });
923         }
924         catch (Exception e)
925         {
926             e.printStackTrace();
927         }
928     }
929 }