OSDN Git Service

OPC機でのZoomin / Zoomoutボタンの制御を追加した。
authorMRSa <mrsa@myad.jp>
Wed, 13 Jun 2018 15:15:25 +0000 (00:15 +0900)
committerMRSa <mrsa@myad.jp>
Wed, 13 Jun 2018 15:15:25 +0000 (00:15 +0900)
app/src/main/java/net/osdn/gokigen/a01d/camera/olympus/wrapper/OlyCameraZoomLensControl.java
app/src/main/java/net/osdn/gokigen/a01d/liveview/LiveViewFragment.java

index b5fd809..8d9c6d1 100644 (file)
@@ -57,6 +57,7 @@ class OlyCameraZoomLensControl implements IZoomLensControl
     @Override
     public boolean canZoom()
     {
+        initialize();
         return (canZoom);
     }
 
@@ -188,8 +189,8 @@ class OlyCameraZoomLensControl implements IZoomLensControl
             return;
         }
 
-        float scale = 0.0f;
-        float focalLength = 0.0f;
+        float scale;
+        float focalLength;
         SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
         String value = preferences.getString(IPreferencePropertyAccessor.POWER_ZOOM_LEVEL, IPreferencePropertyAccessor.POWER_ZOOM_LEVEL_DEFAULT_VALUE);
         try
index d90f03a..0331e6b 100644 (file)
@@ -6,6 +6,7 @@ import android.content.SharedPreferences;
 import android.os.Bundle;
 import android.support.annotation.NonNull;
 import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentManager;
 import android.support.v4.content.res.ResourcesCompat;
 import android.support.v7.preference.PreferenceManager;
 import android.util.Log;
@@ -384,14 +385,17 @@ public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFo
         // propertyを取得
         try
         {
-            SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getContext());
-
-            // グリッド・フォーカスアシストの情報を戻す
-            boolean showGrid = preferences.getBoolean(IPreferencePropertyAccessor.SHOW_GRID_STATUS, false);
-            if ((imageView != null)&&(imageView.isShowGrid() != showGrid))
+            Context context = getContext();
+            if (context != null)
             {
-                imageView.toggleShowGridFrame();
-                imageView.postInvalidate();
+                SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getContext());
+
+                // グリッド・フォーカスアシストの情報を戻す
+                boolean showGrid = preferences.getBoolean(IPreferencePropertyAccessor.SHOW_GRID_STATUS, false);
+                if ((imageView != null) && (imageView.isShowGrid() != showGrid)) {
+                    imageView.toggleShowGridFrame();
+                    imageView.postInvalidate();
+                }
             }
             if (currentConnectionStatus == ICameraConnection.CameraConnectionStatus.CONNECTED)
             {
@@ -402,7 +406,6 @@ public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFo
         {
             e.printStackTrace();
         }
-
         Log.v(TAG, "onResume() End");
     }
 
@@ -478,8 +481,12 @@ public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFo
         try
         {
             // ライブビューの開始
-            SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getContext());
-            liveViewControl.changeLiveViewSize(preferences.getString(IPreferencePropertyAccessor.LIVE_VIEW_QUALITY, IPreferencePropertyAccessor.LIVE_VIEW_QUALITY_DEFAULT_VALUE));
+            Context context = getContext();
+            if (context != null)
+            {
+                SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
+                liveViewControl.changeLiveViewSize(preferences.getString(IPreferencePropertyAccessor.LIVE_VIEW_QUALITY, IPreferencePropertyAccessor.LIVE_VIEW_QUALITY_DEFAULT_VALUE));
+            }
             ILiveViewListener lvListener;
             if (interfaceProvider.useOlympusCamera())
             {
@@ -496,8 +503,28 @@ public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFo
             // デジタルズームの設定
             liveViewControl.updateDigitalZoom();
 
-            // パワーズームの設定 (初期化位置の設定)
-            zoomLensControl.moveInitialZoomPosition();
+            // ズームが制御できない場合は、ボタンを消す
+            if (!zoomLensControl.canZoom())
+            {
+                final Activity activity  = getActivity();
+                if (activity != null)
+                {
+                    activity.runOnUiThread(new Runnable()
+                    {
+                        @Override
+                        public void run()
+                        {
+                            activity.findViewById(R.id.btn_zoomin).setVisibility(View.INVISIBLE);
+                            activity.findViewById(R.id.btn_zoomout).setVisibility(View.INVISIBLE);
+                        }
+                    });
+                }
+            }
+            else
+            {
+                // パワーズームの設定 (初期化位置の設定)
+                zoomLensControl.moveInitialZoomPosition();
+            }
 
             // 測光モードをスポットに切り替える
             setAEtoSpot();
@@ -542,7 +569,11 @@ public class LiveViewFragment extends Fragment implements IStatusViewDrawer, IFo
             LoadSaveMyCameraPropertyDialog dialog = new LoadSaveMyCameraPropertyDialog();
             dialog.setTargetFragment(this, COMMAND_MY_PROPERTY);
             dialog.setPropertyOperationsHolder(new LoadSaveCameraProperties(getActivity(), interfaceProvider.getOlympusInterface()));
-            dialog.show(getFragmentManager(), "my_dialog");
+            FragmentManager manager = getFragmentManager();
+            if (manager != null)
+            {
+                dialog.show(manager, "my_dialog");
+            }
         }
         catch (Exception e)
         {