From ce32762c28bb195b49a9ef1c0ac3137357ea1880 Mon Sep 17 00:00:00 2001 From: Nathaniel Wesley Filardo Date: Sun, 22 Sep 2019 15:19:34 +0100 Subject: [PATCH] treewide: fix inspection-reported issues --- .../ctfwstimer/AboutActivity.java | 14 ++-- .../ctfwstimer/AndroidResourceUtils.java | 1 + .../ctfwstimer/CheckedAsyncDownloader.java | 10 ++- .../ctfwstimer/CtFwSCallbacksMQTT.java | 12 ++-- .../ctfwstimer/CtFwSDisplayLocal.java | 6 +- .../ctfwstimer/CtFwSDisplayTinyChrono.java | 2 - .../ctfwstimer/HandbookDownloader.java | 7 +- .../ctfwstimer/MainService.java | 2 +- .../ctfwstimer/MainServiceNotification.java | 3 - mobile/src/main/res/layout/activity_main.xml | 72 +++++++++---------- 10 files changed, 60 insertions(+), 69 deletions(-) diff --git a/mobile/src/main/java/com/acmetensortoys/ctfwstimer/AboutActivity.java b/mobile/src/main/java/com/acmetensortoys/ctfwstimer/AboutActivity.java index 369219a..cb2b399 100644 --- a/mobile/src/main/java/com/acmetensortoys/ctfwstimer/AboutActivity.java +++ b/mobile/src/main/java/com/acmetensortoys/ctfwstimer/AboutActivity.java @@ -40,7 +40,7 @@ public class AboutActivity extends AppCompatActivity { private TextView mTvDebug; private void makeDebugText() { - final StringBuffer sb = new StringBuffer(""); + final StringBuffer sb = new StringBuffer(); sb.append("Android host version: "); sb.append(Build.VERSION.RELEASE); @@ -93,7 +93,7 @@ public class AboutActivity extends AppCompatActivity { super.onCreate(savedInstanceState); setContentView(R.layout.activity_about); - mTvDebug = (TextView) findViewById(R.id.about_debug_tv); + mTvDebug = findViewById(R.id.about_debug_tv); makeDebugText(); ActionBar ab = getSupportActionBar(); @@ -115,17 +115,17 @@ public class AboutActivity extends AppCompatActivity { }); { - final WebView wv = (WebView) findViewById(R.id.about_text); + final WebView wv = findViewById(R.id.about_text); wv.loadData(getResources().getString(R.string.about_text), "text/html", null); } { - final WebView wv = (WebView) findViewById(R.id.about_licenses); + final WebView wv = findViewById(R.id.about_licenses); wv.loadUrl("file:///android_asset/licenses.html"); } - TabHost th = (TabHost) findViewById(R.id.about_tab_host); + TabHost th = findViewById(R.id.about_tab_host); th.setup(); th.addTab(th.newTabSpec(TAB_PROG) @@ -154,7 +154,7 @@ public class AboutActivity extends AppCompatActivity { return true; } - private MainService.Observer mSrvObs = new MainService.Observer() { + private final MainService.Observer mSrvObs = new MainService.Observer() { @Override public void onMqttServerChanged(MainService.LocalBinder b, String sURL) { @@ -172,7 +172,7 @@ public class AboutActivity extends AppCompatActivity { } }; - private CtFwSGameStateManager.Observer mCtFwSObs = new CtFwSGameStateManager.Observer() { + private final CtFwSGameStateManager.Observer mCtFwSObs = new CtFwSGameStateManager.Observer() { @Override public void onCtFwSConfigure(CtFwSGameStateManager game) { makeDebugText(); diff --git a/mobile/src/main/java/com/acmetensortoys/ctfwstimer/AndroidResourceUtils.java b/mobile/src/main/java/com/acmetensortoys/ctfwstimer/AndroidResourceUtils.java index ac64571..aee9aa0 100644 --- a/mobile/src/main/java/com/acmetensortoys/ctfwstimer/AndroidResourceUtils.java +++ b/mobile/src/main/java/com/acmetensortoys/ctfwstimer/AndroidResourceUtils.java @@ -10,6 +10,7 @@ public class AndroidResourceUtils { if (Build.VERSION.SDK_INT >= 24) { return Html.fromHtml(String.format(rs.getString(id), args), 0); } else { + //noinspection deprecation return Html.fromHtml(String.format(rs.getString(id), args)); } } diff --git a/mobile/src/main/java/com/acmetensortoys/ctfwstimer/CheckedAsyncDownloader.java b/mobile/src/main/java/com/acmetensortoys/ctfwstimer/CheckedAsyncDownloader.java index 38c7dab..91e415c 100644 --- a/mobile/src/main/java/com/acmetensortoys/ctfwstimer/CheckedAsyncDownloader.java +++ b/mobile/src/main/java/com/acmetensortoys/ctfwstimer/CheckedAsyncDownloader.java @@ -1,6 +1,5 @@ package com.acmetensortoys.ctfwstimer; -import android.content.Context; import android.os.AsyncTask; import java.io.BufferedInputStream; @@ -12,7 +11,6 @@ import java.io.IOException; import java.io.OutputStream; import java.net.URL; import java.net.URLConnection; -import java.nio.file.NoSuchFileException; import java.security.DigestInputStream; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; @@ -75,6 +73,7 @@ public class CheckedAsyncDownloader extends AsyncTask mDLFiniCB; private IMqttAsyncClient mMqc; - private Handler mHdl; + private final Handler mHdl; private Runnable nextSubRunnable; public HandbookDownloader(Context ctx, Handler hdl, diff --git a/mobile/src/main/java/com/acmetensortoys/ctfwstimer/MainService.java b/mobile/src/main/java/com/acmetensortoys/ctfwstimer/MainService.java index e0766d1..6f0e614 100644 --- a/mobile/src/main/java/com/acmetensortoys/ctfwstimer/MainService.java +++ b/mobile/src/main/java/com/acmetensortoys/ctfwstimer/MainService.java @@ -62,7 +62,7 @@ public class MainService extends Service { // Handbook fetch logic; this is a singleton for the service, even as connections come and go. private CheckedAsyncDownloader.DL lastHandDL; - private HandbookDownloader mHandDL = new HandbookDownloader(this, + private final HandbookDownloader mHandDL = new HandbookDownloader(this, new Handler(Looper.getMainLooper()), new Consumer() { @Override diff --git a/mobile/src/main/java/com/acmetensortoys/ctfwstimer/MainServiceNotification.java b/mobile/src/main/java/com/acmetensortoys/ctfwstimer/MainServiceNotification.java index e94894b..be9c038 100644 --- a/mobile/src/main/java/com/acmetensortoys/ctfwstimer/MainServiceNotification.java +++ b/mobile/src/main/java/com/acmetensortoys/ctfwstimer/MainServiceNotification.java @@ -20,7 +20,6 @@ import android.util.Log; import com.acmetensortoys.ctfwstimer.lib.CtFwSGameStateManager; import java.text.NumberFormat; -import java.util.List; import java.util.SortedSet; class MainServiceNotification { @@ -105,8 +104,6 @@ class MainServiceNotification { String txt; switch(now.rationale) { default: - case NR_GAME_IN_PROGRESS: - case NR_START_FUTURE: txt = ""; break; case NR_TIME_UP: diff --git a/mobile/src/main/res/layout/activity_main.xml b/mobile/src/main/res/layout/activity_main.xml index 8dcc45d..735ee3f 100644 --- a/mobile/src/main/res/layout/activity_main.xml +++ b/mobile/src/main/res/layout/activity_main.xml @@ -209,54 +209,48 @@ - + android:stretchColumns="1"> - - - - - - - - + android:layout_height="match_parent"> + + + + + + + - + - + - + - - - - + -- 2.50.1