mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-19 04:09:03 +00:00
correct challenge sorting
This commit is contained in:
parent
2239ed50e8
commit
e93cf6e044
4 changed files with 15 additions and 4 deletions
|
|
@ -2,8 +2,8 @@
|
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="com.habitrpg.android.habitica"
|
||||
android:versionCode="1911"
|
||||
android:versionName="1.1.2"
|
||||
android:versionCode="1912"
|
||||
android:versionName="1.1.3"
|
||||
android:screenOrientation="portrait"
|
||||
android:installLocation="auto" >
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ public class RealmChallengeLocalRepository extends RealmBaseLocalRepository impl
|
|||
public Observable<RealmResults<Challenge>> getChallenges() {
|
||||
return realm.where(Challenge.class)
|
||||
.isNotNull("name")
|
||||
.findAllSortedAsync("memberCount", Sort.DESCENDING)
|
||||
.findAllSortedAsync("official", Sort.DESCENDING, "createdAt", Sort.DESCENDING)
|
||||
.asObservable()
|
||||
.filter(RealmResults::isLoaded);
|
||||
}
|
||||
|
|
@ -48,7 +48,7 @@ public class RealmChallengeLocalRepository extends RealmBaseLocalRepository impl
|
|||
return realm.where(Challenge.class)
|
||||
.isNotNull("name")
|
||||
.equalTo("isParticipating", true)
|
||||
.findAllSortedAsync("memberCount", Sort.DESCENDING)
|
||||
.findAllSortedAsync("official", Sort.DESCENDING, "createdAt", Sort.DESCENDING)
|
||||
.asObservable()
|
||||
.filter(RealmResults::isLoaded);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import com.google.gson.annotations.SerializedName;
|
|||
import com.habitrpg.android.habitica.models.tasks.TasksOrder;
|
||||
import com.habitrpg.android.habitica.models.user.User;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
||||
import io.realm.RealmObject;
|
||||
|
|
@ -33,6 +34,8 @@ public class Challenge extends RealmObject {
|
|||
public String habitList;
|
||||
public String dailyList;
|
||||
public String rewardList;
|
||||
public Date createdAt;
|
||||
public Date updatedAt;
|
||||
|
||||
public Group group;
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import com.google.gson.JsonSerializer;
|
|||
import com.habitrpg.android.habitica.models.social.Challenge;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Date;
|
||||
|
||||
public class ChallengeDeserializer implements JsonDeserializer<Challenge>, JsonSerializer<Challenge> {
|
||||
@Override
|
||||
|
|
@ -59,6 +60,13 @@ public class ChallengeDeserializer implements JsonDeserializer<Challenge>, JsonS
|
|||
}
|
||||
}
|
||||
|
||||
if (jsonObject.has("createdAt")) {
|
||||
challenge.createdAt = context.deserialize(jsonObject.get("createdAt"), Date.class);
|
||||
}
|
||||
if (jsonObject.has("updatedAt")) {
|
||||
challenge.updatedAt = context.deserialize(jsonObject.get("updatedAt"), Date.class);
|
||||
}
|
||||
|
||||
JsonElement groupElement = jsonObject.get("group");
|
||||
|
||||
if (groupElement != null && !groupElement.isJsonNull()) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue