From 713e47b20a8124c4d61a22d1e2f1f803bfe021d4 Mon Sep 17 00:00:00 2001 From: "Daniele Verducci (Slimpenguin)" Date: Sun, 20 Feb 2022 07:46:48 +0100 Subject: [PATCH] Fix crash when using corrupted dataset with null category It may happen on imports from Google Maps --- .../it/danieleverducci/nextcloudmaps/model/Geofavorite.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/it/danieleverducci/nextcloudmaps/model/Geofavorite.java b/app/src/main/java/it/danieleverducci/nextcloudmaps/model/Geofavorite.java index f581b6f..a4690f0 100644 --- a/app/src/main/java/it/danieleverducci/nextcloudmaps/model/Geofavorite.java +++ b/app/src/main/java/it/danieleverducci/nextcloudmaps/model/Geofavorite.java @@ -199,7 +199,7 @@ public class Geofavorite implements Serializable { */ public int categoryColor() { // If category is default, return null: will be used Nextcloud's accent - if (this.category.equals(DEFAULT_CATEGORY)) + if (this.category == null || this.category.equals(DEFAULT_CATEGORY) || this.category.length() == 0) return 0; float letter1Index = this.category.toLowerCase().charAt(0); @@ -212,9 +212,7 @@ public class Geofavorite implements Serializable { } public String categoryLetter() { - if (category == null || category.length() == 0) - return ""; - if (category.equals(DEFAULT_CATEGORY)) + if (category == null || category.length() == 0 || category.equals(DEFAULT_CATEGORY)) return "\u2022"; return category.substring(0,1); }