• R/O
  • HTTP
  • SSH
  • HTTPS

Gr2Control: コミット

Ricoh GR2 Control App for Android.


コミットメタ情報

リビジョンfbd3718f64525df954bc7b305afe14d002a04c7a (tree)
日時2020-05-05 21:48:17
作者MRSa <mrsa@myad...>
コミッターMRSa

ログメッセージ

RICOHの接続処理を微修正。

変更サマリ

差分

--- a/app/src/main/java/net/osdn/gokigen/gr2control/camera/ricohgr2/wrapper/connection/RicohGr2Connection.java
+++ b/app/src/main/java/net/osdn/gokigen/gr2control/camera/ricohgr2/wrapper/connection/RicohGr2Connection.java
@@ -1,6 +1,5 @@
11 package net.osdn.gokigen.gr2control.camera.ricohgr2.wrapper.connection;
22
3-import android.app.Activity;
43 import android.content.BroadcastReceiver;
54 import android.content.Context;
65 import android.content.DialogInterface;
@@ -21,6 +20,7 @@ import java.util.concurrent.Executors;
2120
2221 import androidx.annotation.NonNull;
2322 import androidx.appcompat.app.AlertDialog;
23+import androidx.fragment.app.FragmentActivity;
2424
2525
2626 /**
@@ -30,7 +30,7 @@ import androidx.appcompat.app.AlertDialog;
3030 public class RicohGr2Connection implements ICameraConnection
3131 {
3232 private final String TAG = toString();
33- private final Activity context;
33+ private final FragmentActivity context;
3434 private final ICameraStatusReceiver statusReceiver;
3535 private final BroadcastReceiver connectionReceiver;
3636 private final IUseGR2CommandNotify gr2CommandNotify;
@@ -45,9 +45,9 @@ public class RicohGr2Connection implements ICameraConnection
4545 *
4646 *
4747 */
48- public RicohGr2Connection(@NonNull final Activity context, @NonNull final ICameraStatusReceiver statusReceiver, @NonNull IUseGR2CommandNotify gr2CommandNotify)
48+ public RicohGr2Connection(@NonNull final FragmentActivity context, @NonNull final ICameraStatusReceiver statusReceiver, @NonNull IUseGR2CommandNotify gr2CommandNotify)
4949 {
50- Log.v(TAG, "RicohGr2Connection()");
50+ Log.v(TAG, " RicohGr2Connection()");
5151 this.context = context;
5252 this.statusReceiver = statusReceiver;
5353 this.gr2CommandNotify = gr2CommandNotify;
@@ -183,47 +183,41 @@ public class RicohGr2Connection implements ICameraConnection
183183 public void alertConnectingFailed(String message)
184184 {
185185 Log.v(TAG, "alertConnectingFailed() : " + message);
186- final AlertDialog.Builder builder = new AlertDialog.Builder(context)
187- .setTitle(context.getString(R.string.dialog_title_connect_failed))
188- .setMessage(message)
189- .setPositiveButton(context.getString(R.string.dialog_title_button_retry), new DialogInterface.OnClickListener() {
190- @Override
191- public void onClick(DialogInterface dialog, int which)
192- {
193- connect();
194- }
195- })
196- .setNeutralButton(R.string.dialog_title_button_network_settings, new DialogInterface.OnClickListener() {
197- @Override
198- public void onClick(DialogInterface dialog, int which)
199- {
200- try
201- {
202- // Wifi 設定画面を表示する
203- context.startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
204- }
205- catch (android.content.ActivityNotFoundException ex)
206- {
207- // Activity が存在しなかった...設定画面が起動できなかった
208- Log.v(TAG, "android.content.ActivityNotFoundException...");
209-
210- // この場合は、再試行と等価な動きとする
186+ if (context != null)
187+ {
188+ final AlertDialog.Builder builder = new AlertDialog.Builder(context)
189+ .setTitle(context.getString(R.string.dialog_title_connect_failed))
190+ .setMessage(message)
191+ .setPositiveButton(context.getString(R.string.dialog_title_button_retry), new DialogInterface.OnClickListener() {
192+ @Override
193+ public void onClick(DialogInterface dialog, int which) {
211194 connect();
212195 }
213- catch (Exception e)
214- {
215- e.printStackTrace();
196+ })
197+ .setNeutralButton(R.string.dialog_title_button_network_settings, new DialogInterface.OnClickListener() {
198+ @Override
199+ public void onClick(DialogInterface dialog, int which) {
200+ try {
201+ // Wifi 設定画面を表示する
202+ context.startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
203+ } catch (android.content.ActivityNotFoundException ex) {
204+ // Activity が存在しなかった...設定画面が起動できなかった
205+ Log.v(TAG, "android.content.ActivityNotFoundException...");
206+
207+ // この場合は、再試行と等価な動きとする
208+ connect();
209+ } catch (Exception e) {
210+ e.printStackTrace();
211+ }
216212 }
217- }
218- });
219- context.runOnUiThread(new Runnable()
220- {
221- @Override
222- public void run()
223- {
224- builder.show();
225- }
226- });
213+ });
214+ context.runOnUiThread(new Runnable() {
215+ @Override
216+ public void run() {
217+ builder.show();
218+ }
219+ });
220+ }
227221 }
228222
229223 @Override
旧リポジトリブラウザで表示