Added check that log manager mLm is not null before using it - FIXES #195 (well prevents it crashing the whole app anyway!)

This commit is contained in:
Graham Jones
2024-06-14 14:36:22 +01:00
parent 7871de926c
commit 1816c10234
3 changed files with 21 additions and 15 deletions

View File

@@ -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.

View File

@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:versionCode="143"
android:versionName="4.2.9">
android:versionCode="144"
android:versionName="4.2.10">
<!-- android:allowBackup="false" -->
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>

View File

@@ -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<HashMap<String, String>> eventsList) -> {
mEventsList = eventsList;
Log.v(TAG, "initialiseServiceConnection() - set mEventsList - Updating UI");
updateUi();
});
mUtil.getSysLogList((ArrayList<HashMap<String, String>> 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<HashMap<String, String>> eventsList) -> {
mEventsList = eventsList;
Log.v(TAG, "initialiseServiceConnection() - set mEventsList - Updating UI");
updateUi();
});
mUtil.getSysLogList((ArrayList<HashMap<String, String>> 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");
}
}