fix challenge loading.

This commit is contained in:
Phillip Thelen 2018-03-12 13:22:11 +01:00
parent ed38ca6000
commit afd3303256
3 changed files with 12 additions and 3 deletions

View file

@ -2,7 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
package="com.habitrpg.android.habitica" package="com.habitrpg.android.habitica"
android:versionCode="1974" android:versionCode="1975"
android:versionName="1.4.3" android:versionName="1.4.3"
android:screenOrientation="portrait" android:screenOrientation="portrait"
android:installLocation="auto" > android:installLocation="auto" >

View file

@ -42,7 +42,7 @@ class RealmUserLocalRepository(realm: Realm) : RealmBaseLocalRepository(realm),
removeOldTags(user.id, user.tags) removeOldTags(user.id, user.tags)
} }
if (user.challenges != null) { if (user.challenges != null) {
removeOldChallenges(user.id, user.challenges) removeOldChallenges(user.challenges)
} }
} }
@ -56,7 +56,7 @@ class RealmUserLocalRepository(realm: Realm) : RealmBaseLocalRepository(realm),
} }
} }
private fun removeOldChallenges(userId: String, onlineChallenges: List<Challenge>) { private fun removeOldChallenges(onlineChallenges: List<Challenge>) {
val challenges = realm.where(Challenge::class.java).equalTo("isParticipating", true).findAll().createSnapshot() val challenges = realm.where(Challenge::class.java).equalTo("isParticipating", true).findAll().createSnapshot()
val challengesToDelete = challenges.filterNot { onlineChallenges.contains(it) } val challengesToDelete = challenges.filterNot { onlineChallenges.contains(it) }
realm.executeTransaction { realm.executeTransaction {

View file

@ -1,5 +1,6 @@
package com.habitrpg.android.habitica.models.social; package com.habitrpg.android.habitica.models.social;
import com.habitrpg.android.habitica.models.tasks.ChecklistItem;
import com.habitrpg.android.habitica.models.tasks.TasksOrder; import com.habitrpg.android.habitica.models.tasks.TasksOrder;
import com.habitrpg.android.habitica.models.user.User; import com.habitrpg.android.habitica.models.user.User;
@ -64,4 +65,12 @@ public class Challenge extends RealmObject {
return map; return map;
} }
@Override
public boolean equals(Object obj) {
if (obj.getClass().equals(Challenge.class) && this.id != null) {
return this.id.equals(((Challenge)obj).id);
}
return super.equals(obj);
}
} }