From f18943eabe06cf37964552c7c5a14bb1e5a68eef Mon Sep 17 00:00:00 2001 From: Phillip Thelen Date: Tue, 18 Sep 2018 11:30:15 +0200 Subject: [PATCH] Fix task deserialization issue --- .../com/habitrpg/android/habitica/models/tasks/Task.kt | 4 ++++ .../android/habitica/models/user/SubscriptionPlan.java | 3 ++- .../ui/views/subscriptions/SubscriptionDetailsView.kt | 8 ++++---- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/models/tasks/Task.kt b/Habitica/src/main/java/com/habitrpg/android/habitica/models/tasks/Task.kt index 05732c440b..c4e2422453 100644 --- a/Habitica/src/main/java/com/habitrpg/android/habitica/models/tasks/Task.kt +++ b/Habitica/src/main/java/com/habitrpg/android/habitica/models/tasks/Task.kt @@ -21,6 +21,10 @@ open class Task : RealmObject, Parcelable { @PrimaryKey @SerializedName("_id") var id: String? = null + set(value) { + field = value + repeat?.taskId = value + } var userId: String = "" var priority: Float = 0.0f var text: String = "" diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/models/user/SubscriptionPlan.java b/Habitica/src/main/java/com/habitrpg/android/habitica/models/user/SubscriptionPlan.java index c7cd76085f..630626fb29 100644 --- a/Habitica/src/main/java/com/habitrpg/android/habitica/models/user/SubscriptionPlan.java +++ b/Habitica/src/main/java/com/habitrpg/android/habitica/models/user/SubscriptionPlan.java @@ -29,6 +29,7 @@ public class SubscriptionPlan extends RealmObject { public Integer gemsBought; public Integer extraMonths; public Integer quantity; + @Nullable public SubscriptionPlanConsecutive consecutive; public int mysteryItemCount; @@ -39,7 +40,7 @@ public boolean isActive() { } public int totalNumberOfGems() { - if (customerId == null) { + if (customerId == null || consecutive == null) { return 0; } return 25 + consecutive.getGemCapExtra(); diff --git a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/views/subscriptions/SubscriptionDetailsView.kt b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/views/subscriptions/SubscriptionDetailsView.kt index 39fe12a094..267691df34 100644 --- a/Habitica/src/main/java/com/habitrpg/android/habitica/ui/views/subscriptions/SubscriptionDetailsView.kt +++ b/Habitica/src/main/java/com/habitrpg/android/habitica/ui/views/subscriptions/SubscriptionDetailsView.kt @@ -75,13 +75,13 @@ class SubscriptionDetailsView : LinearLayout { paymentProcessorTextView.text = plan.paymentMethod - if (plan.consecutive.count == 1) { + if (plan.consecutive?.count == 1) { monthsSubscribedTextView.text = resources.getString(R.string.one_month) } else { - monthsSubscribedTextView.text = resources.getString(R.string.months, plan.consecutive.count) + monthsSubscribedTextView.text = resources.getString(R.string.months, plan.consecutive?.count ?: 0) } - gemCapTextView.text = (plan.consecutive.gemCapExtra + 25).toString() - currentHourglassesTextView.text = plan.consecutive.trinkets.toString() + gemCapTextView.text = (plan.consecutive?.gemCapExtra ?: 0 + 25).toString() + currentHourglassesTextView.text = plan.consecutive?.trinkets.toString() if (plan.paymentMethod != null) { if (plan.paymentMethod == "Google") {