From 1816c10234f62153f442aaad998f21464091bca3 Mon Sep 17 00:00:00 2001 From: Graham Jones Date: Fri, 14 Jun 2024 14:36:22 +0100 Subject: [PATCH] Added check that log manager mLm is not null before using it - FIXES #195 (well prevents it crashing the whole app anyway!) --- CHANGELOG.md | 1 + app/src/main/AndroidManifest.xml | 4 +-- .../LogManagerControlActivity.java | 31 +++++++++++-------- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cbfb158..be6ead9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ OpenSeizureDetector Android App - Change Log ============================================ + V4.2.10 - fixed (infrequent) crash when opening data sharing page. V4.2.9 - fixed crash when using Polish translation. V4.2.8 - - Fixed crash in export data function when using european style comma based decimal separator. diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 903d925..f611cbf 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="144" + android:versionName="4.2.10"> diff --git a/app/src/main/java/uk/org/openseizuredetector/LogManagerControlActivity.java b/app/src/main/java/uk/org/openseizuredetector/LogManagerControlActivity.java index f439649..aeca9dd 100644 --- a/app/src/main/java/uk/org/openseizuredetector/LogManagerControlActivity.java +++ b/app/src/main/java/uk/org/openseizuredetector/LogManagerControlActivity.java @@ -203,19 +203,24 @@ public class LogManagerControlActivity extends AppCompatActivity { ProgressBar pb = (ProgressBar) findViewById(R.id.remoteAccessPb); pb.setIndeterminate(true); pb.setVisibility(View.VISIBLE); - // Populate events list - we only do it once when the activity is created because the query might slow down the UI. - // We could try this code in updateUI() and see though. - // Based on https://www.tutlane.com/tutorial/android/android-sqlite-listview-with-examples - mLm.getEventsList(true, (ArrayList> eventsList) -> { - mEventsList = eventsList; - Log.v(TAG, "initialiseServiceConnection() - set mEventsList - Updating UI"); - updateUi(); - }); - mUtil.getSysLogList((ArrayList> syslogList) -> { - mSysLogList = syslogList; - Log.v(TAG, "initialiseServiceConnection() - set mSysLogList - Updating UI"); - updateUi(); - }); + if (mLm != null) { + // Populate events list - we only do it once when the activity is created because the query might slow down the UI. + // We could try this code in updateUI() and see though. + // Based on https://www.tutlane.com/tutorial/android/android-sqlite-listview-with-examples + mLm.getEventsList(true, (ArrayList> eventsList) -> { + mEventsList = eventsList; + Log.v(TAG, "initialiseServiceConnection() - set mEventsList - Updating UI"); + updateUi(); + }); + mUtil.getSysLogList((ArrayList> syslogList) -> { + mSysLogList = syslogList; + Log.v(TAG, "initialiseServiceConnection() - set mSysLogList - Updating UI"); + updateUi(); + }); + } else { + Log.e(TAG,"ERROR: initialiseServiceConnection() - mLm is null"); + mUtil.showToast("ERROR: Failed to start Log Manager"); + } }