From 103c836280c0fd7946a6810f7f755b338e2e33a0 Mon Sep 17 00:00:00 2001 From: Phillip Thelen Date: Sat, 19 Mar 2016 12:55:01 +0100 Subject: [PATCH] fix crash with spring gear --- Habitica/AndroidManifest.xml | 4 ++-- .../ui/adapter/tasks/HabitItemRecyclerViewAdapter.java | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Habitica/AndroidManifest.xml b/Habitica/AndroidManifest.xml index c935332c93..dd1e8d9ce4 100644 --- a/Habitica/AndroidManifest.xml +++ b/Habitica/AndroidManifest.xml @@ -2,8 +2,8 @@ diff --git a/Habitica/src/com/habitrpg/android/habitica/ui/adapter/tasks/HabitItemRecyclerViewAdapter.java b/Habitica/src/com/habitrpg/android/habitica/ui/adapter/tasks/HabitItemRecyclerViewAdapter.java index cfb9bbf3a3..c2cadc4155 100644 --- a/Habitica/src/com/habitrpg/android/habitica/ui/adapter/tasks/HabitItemRecyclerViewAdapter.java +++ b/Habitica/src/com/habitrpg/android/habitica/ui/adapter/tasks/HabitItemRecyclerViewAdapter.java @@ -56,6 +56,7 @@ import com.raizlabs.android.dbflow.sql.builder.Condition; import com.raizlabs.android.dbflow.sql.language.OrderBy; import com.raizlabs.android.dbflow.sql.language.Select; +import com.raizlabs.android.dbflow.structure.BaseModel; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; @@ -212,10 +213,11 @@ public int getItemViewType(int position) { @Override public long getItemId(int position) { Task task = filteredObservableContent.get(position); - if (task.getId() != null && task.getId().length() == 36) { + try { return UUID.fromString(task.getId()).getMostSignificantBits(); + } catch (IllegalArgumentException e) { + return UUID.randomUUID().getMostSignificantBits(); } - return UUID.randomUUID().getMostSignificantBits(); } @Override