From 3b7b61482e782688b359a3bc2bc371857a9cec03 Mon Sep 17 00:00:00 2001 From: CrazyDude1994 Date: Fri, 30 Apr 2021 00:20:10 +0300 Subject: [PATCH] Crash fix on empty log file list --- .../main/java/crazydude/com/telemetry/ui/MapsActivity.kt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/crazydude/com/telemetry/ui/MapsActivity.kt b/app/src/main/java/crazydude/com/telemetry/ui/MapsActivity.kt index 0751068a..65ff0eed 100644 --- a/app/src/main/java/crazydude/com/telemetry/ui/MapsActivity.kt +++ b/app/src/main/java/crazydude/com/telemetry/ui/MapsActivity.kt @@ -432,8 +432,11 @@ class MapsActivity : AppCompatActivity(), DataDecoder.Listener { val dir = Environment.getExternalStoragePublicDirectory("TelemetryLogs") if (dir.exists()) { val files = - dir.listFiles { file -> file.extension == "log" && file.length() > 0 } - .reversed() + dir.listFiles { file -> file.extension == "log" && file.length() > 0 }?.reversed() + if (files == null) { + Toast.makeText(this, "No log files available", Toast.LENGTH_SHORT).show() + return + } AlertDialog.Builder(this) .setAdapter( ArrayAdapter(