Fix crash when using corrupted dataset with null category

It may happen on imports from Google Maps
This commit is contained in:
Daniele Verducci (Slimpenguin) 2022-02-20 07:46:48 +01:00
parent 9dfcfa064a
commit 713e47b20a

View File

@ -199,7 +199,7 @@ public class Geofavorite implements Serializable {
*/ */
public int categoryColor() { public int categoryColor() {
// If category is default, return null: will be used Nextcloud's accent // 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; return 0;
float letter1Index = this.category.toLowerCase().charAt(0); float letter1Index = this.category.toLowerCase().charAt(0);
@ -212,9 +212,7 @@ public class Geofavorite implements Serializable {
} }
public String categoryLetter() { public String categoryLetter() {
if (category == null || category.length() == 0) if (category == null || category.length() == 0 || category.equals(DEFAULT_CATEGORY))
return "";
if (category.equals(DEFAULT_CATEGORY))
return "\u2022"; return "\u2022";
return category.substring(0,1); return category.substring(0,1);
} }