OSDN Git Service

PENTAX/GRの画像取得時のタイムアウト値をPreference値から取得するように変更する。
authorMRSa <mrsa@myad.jp>
Mon, 5 Aug 2019 09:52:42 +0000 (18:52 +0900)
committerMRSa <mrsa@myad.jp>
Mon, 5 Aug 2019 09:52:42 +0000 (18:52 +0900)
app/build.gradle
app/src/main/java/net/osdn/gokigen/gr2control/camera/ricohgr2/wrapper/RicohGr2InterfaceProvider.java
app/src/main/java/net/osdn/gokigen/gr2control/camera/ricohgr2/wrapper/RicohGr2PlaybackControl.java
app/src/main/java/net/osdn/gokigen/gr2control/preference/IPreferencePropertyAccessor.java
app/src/main/java/net/osdn/gokigen/gr2control/preference/ricohgr2/RicohGr2PreferenceFragment.java
app/src/main/res/values-ja/strings.xml
app/src/main/res/values/strings.xml
app/src/main/res/xml/preferences_ricoh_gr2.xml

index 11b19fc..e85e605 100644 (file)
@@ -6,8 +6,8 @@ android {
         applicationId "net.osdn.gokigen.gr2control"
         minSdkVersion 14
         targetSdkVersion 29
-        versionCode 1002003
-        versionName "1.2.3"
+        versionCode 1002004
+        versionName "1.2.4"
     }
     buildTypes {
         release {
index a99f4ad..f14782b 100644 (file)
@@ -66,7 +66,19 @@ public class RicohGr2InterfaceProvider implements IRicohGr2InterfaceProvider, ID
         SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
         useGrCommand = preferences.getBoolean(IPreferencePropertyAccessor.USE_GR2_SPECIAL_COMMAND, true);
         pentaxCaptureAfterAf = preferences.getBoolean(IPreferencePropertyAccessor.PENTAX_CAPTURE_AFTER_AF, false);
-
+        int communicationTimeoutMs = 5000;  // デフォルトは 5000ms とする
+        try
+        {
+            communicationTimeoutMs = Integer.parseInt(preferences.getString(IPreferencePropertyAccessor.RICOH_GET_PICS_LIST_TIMEOUT, IPreferencePropertyAccessor.RICOH_GET_PICS_LIST_TIMEOUT_DEFAULT_VALUE)) * 1000;
+            if (communicationTimeoutMs < 5000)
+            {
+                communicationTimeoutMs = 5000;  // 最小値は 5000msとする。
+            }
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
         //this.activity = context;
         //this.provider = provider;
         gr2Connection = new RicohGr2Connection(context, provider);
@@ -74,7 +86,7 @@ public class RicohGr2InterfaceProvider implements IRicohGr2InterfaceProvider, ID
         zoomControl = new RicohGr2CameraZoomLensControl();
         buttonControl = new RicohGr2CameraButtonControl();
         statusChecker = new RicohGr2StatusChecker(500, useGrCommand);
-        playbackControl = new RicohGr2PlaybackControl();
+        playbackControl = new RicohGr2PlaybackControl(communicationTimeoutMs);
         hardwareStatus = new RicohGr2HardwareStatus();
         runMode = new RicohGr2RunMode();
     }
index 5a76760..d87843f 100644 (file)
@@ -31,6 +31,7 @@ public class RicohGr2PlaybackControl implements IPlaybackControl
     private final String TAG = toString();
     private final String getPhotoUrl = "http://192.168.0.1/v1/photos/";
     private static final int DEFAULT_TIMEOUT = 5000;
+    private final int timeoutValue;
 
     /*****
          [操作メモ]
@@ -45,9 +46,9 @@ public class RicohGr2PlaybackControl implements IPlaybackControl
             動画をダウンロードする      : http://192.168.0.1/v1/photos/yyyRICOH/R0000xxx.MOV?size=full
      *****/
 
-    RicohGr2PlaybackControl()
+    RicohGr2PlaybackControl(int timeoutMSec)
     {
-
+        this.timeoutValue  = (timeoutMSec < DEFAULT_TIMEOUT) ? DEFAULT_TIMEOUT : timeoutMSec;
     }
 
     @Override
@@ -64,7 +65,7 @@ public class RicohGr2PlaybackControl implements IPlaybackControl
         String contentList;
         try
         {
-            contentList = SimpleHttpClient.httpGet(imageListurl, DEFAULT_TIMEOUT);
+            contentList = SimpleHttpClient.httpGet(imageListurl, timeoutValue);
             if (contentList == null)
             {
                 // ぬるぽ発行
@@ -81,7 +82,7 @@ public class RicohGr2PlaybackControl implements IPlaybackControl
         try
         {
             JSONArray dirsArray = new JSONObject(contentList).getJSONArray("dirs");
-            if (dirsArray != null)
+            // if (dirsArray != null)
             {
                 int size = dirsArray.length();
                 for (int index = 0; index < size; index++)
@@ -113,7 +114,7 @@ public class RicohGr2PlaybackControl implements IPlaybackControl
         Log.v(TAG, "updateCameraFileInfo() GET URL : " + url);
         try
         {
-            String response = SimpleHttpClient.httpGet(url, DEFAULT_TIMEOUT);
+            String response = SimpleHttpClient.httpGet(url, timeoutValue);
             if ((response == null)||(response.length() < 1))
             {
                 return;
@@ -160,7 +161,7 @@ public class RicohGr2PlaybackControl implements IPlaybackControl
         Log.v(TAG, "getContentInfo() GET URL : " + url);
         try
         {
-            String response = SimpleHttpClient.httpGet(url, DEFAULT_TIMEOUT);
+            String response = SimpleHttpClient.httpGet(url, timeoutValue);
             if ((response == null)||(response.length() < 1))
             {
                 callback.onErrorOccurred(new NullPointerException());
@@ -181,7 +182,7 @@ public class RicohGr2PlaybackControl implements IPlaybackControl
         Log.v(TAG, "downloadContentScreennail() GET URL : " + url);
         try
         {
-            Bitmap bmp = SimpleHttpClient.httpGetBitmap(url, DEFAULT_TIMEOUT);
+            Bitmap bmp = SimpleHttpClient.httpGetBitmap(url, timeoutValue);
             HashMap<String, Object> map = new HashMap<>();
             map.put("Orientation", 0);
             callback.onCompleted(bmp, map);
@@ -205,7 +206,7 @@ public class RicohGr2PlaybackControl implements IPlaybackControl
         Log.v(TAG, "downloadContentThumbnail() GET URL : " + url);
         try
         {
-            Bitmap bmp = SimpleHttpClient.httpGetBitmap(url, DEFAULT_TIMEOUT);
+            Bitmap bmp = SimpleHttpClient.httpGetBitmap(url, timeoutValue);
             HashMap<String, Object> map = new HashMap<>();
             map.put("Orientation", 0);
             callback.onCompleted(bmp, map);
@@ -230,7 +231,7 @@ public class RicohGr2PlaybackControl implements IPlaybackControl
         Log.v(TAG, "downloadContent() GET URL : " + url);
         try
         {
-            SimpleHttpClient.httpGetBytes(url, DEFAULT_TIMEOUT, new SimpleHttpClient.IReceivedMessageCallback() {
+            SimpleHttpClient.httpGetBytes(url, timeoutValue, new SimpleHttpClient.IReceivedMessageCallback() {
                 @Override
                 public void onCompleted() {
                     callback.onCompleted();
index 1d48db8..6d4b731 100644 (file)
@@ -49,6 +49,9 @@ public interface IPreferencePropertyAccessor
     String MAGNIFYING_LIVE_VIEW_SCALE = "magnifying_live_view_scale";
     String MAGNIFYING_LIVE_VIEW_SCALE_DEFAULT_VALUE = "10.0";
 
+    String RICOH_GET_PICS_LIST_TIMEOUT = "ricoh_get_pics_list_timeout";
+    String RICOH_GET_PICS_LIST_TIMEOUT_DEFAULT_VALUE = "5";
+
 /*
     //String GR2_DISPLAY_MODE = "gr2_display_mode";
     //String GR2_DISPLAY_MODE_DEFAULT_VALUE = "0";
index bf9c221..46269fe 100644 (file)
@@ -130,6 +130,9 @@ public class RicohGr2PreferenceFragment  extends PreferenceFragmentCompat implem
             if (!items.containsKey(IPreferencePropertyAccessor.PENTAX_CAPTURE_AFTER_AF)) {
                 editor.putBoolean(IPreferencePropertyAccessor.PENTAX_CAPTURE_AFTER_AF, false);
             }
+            if (!items.containsKey(IPreferencePropertyAccessor.RICOH_GET_PICS_LIST_TIMEOUT)) {
+                editor.putString(IPreferencePropertyAccessor.RICOH_GET_PICS_LIST_TIMEOUT, IPreferencePropertyAccessor.RICOH_GET_PICS_LIST_TIMEOUT_DEFAULT_VALUE);
+            }
             editor.apply();
         }
         catch (Exception e)
index b223fc0..611a605 100644 (file)
 
     <string name="select_radio_date">日付</string>
     <string name="select_radio_path">パス</string>
+
+    <string name="pref_ricoh_get_pics_list_timeout">撮影画像一覧取得時のタイムアウト(単位:秒)</string>
+    <string name="pref_summary_ricoh_get_pics_list_timeout">カメラ内の画像が多い場合は数を増やしてください。</string>
 </resources>
index 1d6fc6e..4e85442 100644 (file)
 
     <string name="select_radio_date">Date</string>
     <string name="select_radio_path">Path</string>
+
+    <string name="pref_ricoh_get_pics_list_timeout">Get Pics List Timeout(unit: sec.)</string>
+    <string name="pref_summary_ricoh_get_pics_list_timeout">If the camera has many number of Pics, increase number.</string>
 </resources>
index 823a08a..1140257 100644 (file)
             android:summary="@string/summary_pentax_capture_after_auto_focus"
             />
 
+        <EditTextPreference
+            android:key="ricoh_get_pics_list_timeout"
+            android:title="@string/pref_ricoh_get_pics_list_timeout"
+            android:defaultValue="5"
+            android:inputType="number"
+            android:summary="@string/pref_summary_ricoh_get_pics_list_timeout" />
+
     </PreferenceCategory>
 
     <PreferenceCategory