Refactor code to abstract realm a bit more

This commit is contained in:
Phillip Thelen 2021-06-02 15:54:26 +02:00
parent af8522b121
commit 428969b03b
153 changed files with 559 additions and 644 deletions

View file

@ -15,7 +15,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.2'
classpath 'com.android.tools.build:gradle:4.2.1'
classpath('com.noveogroup.android:check:1.2.5') {
exclude module: 'checkstyle'
exclude module: 'pmd-java'
@ -41,8 +41,8 @@ repositories {
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
//Networking
implementation 'com.squareup.okhttp3:okhttp:4.9.0'
implementation 'com.squareup.okhttp3:logging-interceptor:4.9.0'
implementation 'com.squareup.okhttp3:okhttp:4.9.1'
implementation 'com.squareup.okhttp3:logging-interceptor:4.9.1'
//REST API handling
implementation('com.squareup.retrofit2:retrofit:2.9.0') {
exclude module: 'okhttp'
@ -53,8 +53,8 @@ dependencies {
implementation 'com.google.firebase:firebase-crashlytics:18.0.0'
//Dependency Injection
implementation 'com.google.dagger:dagger:2.31.2'
kapt 'com.google.dagger:dagger-compiler:2.31.2'
implementation 'com.google.dagger:dagger:2.36'
kapt 'com.google.dagger:dagger-compiler:2.36'
compileOnly 'javax.annotation:javax.annotation-api:1.3.2'
compileOnly 'com.github.pengrad:jdk9-deps:1.0'
//App Compatibility and Material Design
@ -63,15 +63,15 @@ dependencies {
implementation 'androidx.recyclerview:recyclerview:1.2.0'
implementation 'androidx.legacy:legacy-preference-v14:1.0.0'
// Markdown
implementation "io.noties.markwon:core:4.6.1"
implementation "io.noties.markwon:ext-strikethrough:4.6.1"
implementation "io.noties.markwon:image:4.6.1"
implementation "io.noties.markwon:recycler:4.6.1"
implementation "io.noties.markwon:html:4.6.1"
implementation "io.noties.markwon:core:4.6.2"
implementation "io.noties.markwon:ext-strikethrough:4.6.2"
implementation "io.noties.markwon:image:4.6.2"
implementation "io.noties.markwon:recycler:4.6.2"
implementation "io.noties.markwon:html:4.6.2"
//Eventbus
implementation 'org.greenrobot:eventbus:3.2.0'
// IAP Handling / Verification
implementation 'org.solovyev.android:checkout:1.2.2'
implementation 'org.solovyev.android:checkout:1.2.3'
//Facebook
implementation('com.facebook.android:facebook-android-sdk:8.1.0') {
transitive = true
@ -79,9 +79,9 @@ dependencies {
implementation 'fr.avianey.com.viewpagerindicator:library:2.4.1@aar'
//RxJava
implementation 'io.reactivex.rxjava3:rxandroid:3.0.0'
implementation 'io.reactivex.rxjava3:rxjava:3.0.9'
implementation 'io.reactivex.rxjava3:rxjava:3.0.13'
implementation 'io.reactivex.rxjava3:rxkotlin:3.0.1'
implementation 'io.reactivex.rxjava2:rxjava:2.2.19'
implementation 'io.reactivex.rxjava2:rxjava:2.2.21'
implementation "com.github.akarnokd:rxjava3-bridge:3.0.0"
//Analytics
@ -114,7 +114,7 @@ dependencies {
implementation 'com.google.firebase:firebase-config:21.0.0'
implementation 'com.google.firebase:firebase-perf:20.0.0'
implementation 'com.google.android.gms:play-services-auth:19.0.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.32"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.5.10"
implementation 'com.nex3z:flow-layout:1.2.2'
implementation 'androidx.core:core-ktx:1.5.0'
@ -134,7 +134,7 @@ dependencies {
android {
compileSdkVersion 30
buildToolsVersion '29.0.3'
buildToolsVersion '30.0.2'
testOptions {
unitTests {
includeAndroidResources = true
@ -150,7 +150,7 @@ android {
resConfigs "en", "bg", "de", "en-rGB", "es", "fr", "hr-rHR", "in", "it", "iw", "ja", "ko", "lt", "nl", "pl", "pt-rBR", "pt-rPT", "ru", "tr", "zh", "zh-rTW"
versionCode 2960
versionName "3.2.4.1"
versionName "3.3"
}
buildFeatures {

View file

@ -1,6 +1,6 @@
package com.habitrpg.android.habitica.data
import io.realm.RealmObject
import com.habitrpg.android.habitica.models.BaseObject
interface BaseRepository {
@ -8,6 +8,6 @@ interface BaseRepository {
fun close()
fun <T : RealmObject> getUnmanagedCopy(obj: T): T
fun <T : RealmObject> getUnmanagedCopy(list: List<T>): List<T>
fun <T : BaseObject> getUnmanagedCopy(obj: T): T
fun <T : BaseObject> getUnmanagedCopy(list: List<T>): List<T>
}

View file

@ -5,14 +5,13 @@ import com.habitrpg.android.habitica.models.social.ChallengeMembership
import com.habitrpg.android.habitica.models.tasks.Task
import com.habitrpg.android.habitica.models.tasks.TaskList
import io.reactivex.rxjava3.core.Flowable
import io.realm.RealmResults
interface ChallengeRepository : BaseRepository {
fun retrieveChallenges(page: Int = 0, memberOnly: Boolean): Flowable<List<Challenge>>
fun getChallenges(): Flowable<RealmResults<Challenge>>
fun getChallenges(): Flowable<out List<Challenge>>
fun getChallenge(challengeId: String): Flowable<Challenge>
fun getChallengeTasks(challengeId: String): Flowable<RealmResults<Task>>
fun getChallengeTasks(challengeId: String): Flowable<out List<Task>>
fun retrieveChallenge(challengeID: String): Flowable<Challenge>
fun retrieveChallengeTasks(challengeID: String): Flowable<TaskList>
@ -31,7 +30,7 @@ interface ChallengeRepository : BaseRepository {
addedTaskList: List<Task>, updatedTaskList: List<Task>, removedTaskList: List<String>): Flowable<Challenge>
fun deleteChallenge(challengeId: String): Flowable<Void>
fun getUserChallenges(userId: String? = null): Flowable<RealmResults<Challenge>>
fun getUserChallenges(userId: String? = null): Flowable<out List<Challenge>>
fun leaveChallenge(challenge: Challenge, keepTasks: String): Flowable<Void>
@ -39,6 +38,6 @@ interface ChallengeRepository : BaseRepository {
fun joinChallenge(challenge: Challenge): Flowable<Challenge>
fun getChallengepMembership(id: String): Flowable<ChallengeMembership>
fun getChallengeMemberships(): Flowable<RealmResults<ChallengeMembership>>
fun getChallengeMemberships(): Flowable<out List<ChallengeMembership>>
fun isChallengeMember(challengeID: String): Flowable<Boolean>
}

View file

@ -3,8 +3,7 @@ package com.habitrpg.android.habitica.data
import com.habitrpg.android.habitica.models.inventory.Customization
import io.reactivex.rxjava3.core.Flowable
import io.realm.RealmResults
interface CustomizationRepository : BaseRepository {
fun getCustomizations(type: String, category: String?, onlyAvailable: Boolean): Flowable<RealmResults<Customization>>
fun getCustomizations(type: String, category: String?, onlyAvailable: Boolean): Flowable<out List<Customization>>
}

View file

@ -3,9 +3,8 @@ package com.habitrpg.android.habitica.data
import com.habitrpg.android.habitica.models.FAQArticle
import io.reactivex.rxjava3.core.Flowable
import io.realm.RealmResults
interface FAQRepository : BaseRepository {
fun getArticles(): Flowable<RealmResults<FAQArticle>>
fun getArticles(): Flowable<out List<FAQArticle>>
fun getArticle(position: Int): Flowable<FAQArticle>
}

View file

@ -7,33 +7,32 @@ import com.habitrpg.android.habitica.models.shops.Shop
import com.habitrpg.android.habitica.models.shops.ShopItem
import com.habitrpg.android.habitica.models.user.*
import io.reactivex.rxjava3.core.Flowable
import io.realm.RealmResults
interface InventoryRepository : BaseRepository {
fun getArmoireRemainingCount(): Long
fun getInAppRewards(): Flowable<RealmResults<ShopItem>>
fun getOwnedEquipment(): Flowable<RealmResults<Equipment>>
fun getInAppRewards(): Flowable<out List<ShopItem>>
fun getOwnedEquipment(): Flowable<out List<Equipment>>
fun getMounts(): Flowable<RealmResults<Mount>>
fun getMounts(): Flowable<out List<Mount>>
fun getOwnedMounts(): Flowable<RealmResults<OwnedMount>>
fun getOwnedMounts(): Flowable<out List<OwnedMount>>
fun getPets(): Flowable<RealmResults<Pet>>
fun getPets(): Flowable<out List<Pet>>
fun getOwnedPets(): Flowable<RealmResults<OwnedPet>>
fun getOwnedPets(): Flowable<out List<OwnedPet>>
fun getQuestContent(key: String): Flowable<QuestContent>
fun getQuestContent(keys: List<String>): Flowable<RealmResults<QuestContent>>
fun getQuestContent(keys: List<String>): Flowable<out List<QuestContent>>
fun getEquipment(searchedKeys: List<String>): Flowable<RealmResults<Equipment>>
fun getEquipment(searchedKeys: List<String>): Flowable<out List<Equipment>>
fun retrieveInAppRewards(): Flowable<List<ShopItem>>
fun getOwnedEquipment(type: String): Flowable<RealmResults<Equipment>>
fun getEquipmentType(type: String, set: String): Flowable<RealmResults<Equipment>>
fun getOwnedEquipment(type: String): Flowable<out List<Equipment>>
fun getEquipmentType(type: String, set: String): Flowable<out List<Equipment>>
fun getOwnedItems(itemType: String, includeZero: Boolean = false): Flowable<RealmResults<OwnedItem>>
fun getOwnedItems(itemType: String, includeZero: Boolean = false): Flowable<out List<OwnedItem>>
fun getOwnedItems(includeZero: Boolean = false): Flowable<Map<String, OwnedItem>>
fun getEquipment(key: String): Flowable<Equipment>
@ -41,8 +40,8 @@ interface InventoryRepository : BaseRepository {
fun openMysteryItem(user: User?): Flowable<Equipment>
fun saveEquipment(equipment: Equipment)
fun getMounts(type: String?, group: String?, color: String?): Flowable<RealmResults<Mount>>
fun getPets(type: String?, group: String?, color: String?): Flowable<RealmResults<Pet>>
fun getMounts(type: String?, group: String?, color: String?): Flowable<out List<Mount>>
fun getPets(type: String?, group: String?, color: String?): Flowable<out List<Pet>>
fun updateOwnedEquipment(user: User)
@ -75,8 +74,8 @@ interface InventoryRepository : BaseRepository {
fun purchaseItem(purchaseType: String, key: String, purchaseQuantity: Int): Flowable<Void>
fun togglePinnedItem(item: ShopItem): Flowable<List<ShopItem>>
fun getItems(itemClass: Class<out Item>, keys: Array<String>): Flowable<out RealmResults<out Item>>
fun getItems(itemClass: Class<out Item>): Flowable<out RealmResults<out Item>>
fun getItems(itemClass: Class<out Item>, keys: Array<String>): Flowable<out List<Item>>
fun getItems(itemClass: Class<out Item>): Flowable<out List<Item>>
fun getLatestMysteryItem(): Flowable<Equipment>
fun getItem(type: String, key: String): Flowable<Item>
fun getAvailableLimitedItems(): Flowable<List<Item>>

View file

@ -8,15 +8,14 @@ import com.habitrpg.android.habitica.models.social.*
import com.habitrpg.android.habitica.models.user.User
import io.reactivex.rxjava3.core.Flowable
import io.reactivex.rxjava3.core.Single
import io.realm.RealmResults
import java.util.*
interface SocialRepository : BaseRepository {
fun getPublicGuilds(): Flowable<RealmResults<Group>>
fun getPublicGuilds(): Flowable<out List<Group>>
fun getUserGroups(type: String?): Flowable<RealmResults<Group>>
fun getUserGroups(type: String?): Flowable<out List<Group>>
fun retrieveGroupChat(groupId: String): Single<List<ChatMessage>>
fun getGroupChat(groupId: String): Flowable<RealmResults<ChatMessage>>
fun getGroupChat(groupId: String): Flowable<out List<ChatMessage>>
fun markMessagesSeen(seenGroupId: String)
@ -40,18 +39,18 @@ interface SocialRepository : BaseRepository {
fun updateGroup(group: Group?, name: String?, description: String?, leader: String?, leaderCreateChallenge: Boolean?): Flowable<Group>
fun retrieveGroups(type: String): Flowable<List<Group>>
fun getGroups(type: String): Flowable<RealmResults<Group>>
fun getGroups(type: String): Flowable<out List<Group>>
fun getInboxMessages(replyToUserID: String?): Flowable<RealmResults<ChatMessage>>
fun getInboxMessages(replyToUserID: String?): Flowable<out List<ChatMessage>>
fun retrieveInboxMessages(uuid: String, page: Int): Flowable<List<ChatMessage>>
fun retrieveInboxConversations(): Flowable<List<InboxConversation>>
fun getInboxConversations(): Flowable<RealmResults<InboxConversation>>
fun getInboxConversations(): Flowable<out List<InboxConversation>>
fun postPrivateMessage(recipientId: String, messageObject: HashMap<String, String>): Flowable<List<ChatMessage>>
fun postPrivateMessage(recipientId: String, message: String): Flowable<List<ChatMessage>>
fun getGroupMembers(id: String): Flowable<RealmResults<Member>>
fun getGroupMembers(id: String): Flowable<out List<Member>>
fun retrieveGroupMembers(id: String, includeAllPublicFields: Boolean): Flowable<List<Member>>
fun inviteToGroup(id: String, inviteData: Map<String, Any>): Flowable<Void>
@ -85,7 +84,7 @@ interface SocialRepository : BaseRepository {
fun transferGems(giftedID: String, amount: Int): Flowable<Void>
fun getGroupMembership(id: String): Flowable<GroupMembership>
fun getGroupMemberships(): Flowable<RealmResults<GroupMembership>>
fun getGroupMemberships(): Flowable<out List<GroupMembership>>
fun getChatmessage(messageID: String): Flowable<ChatMessage>
fun blockMember(userID: String): Flowable<List<String>>
}

View file

@ -4,12 +4,11 @@ import com.habitrpg.android.habitica.models.Tag
import io.reactivex.rxjava3.core.Flowable
import io.reactivex.rxjava3.core.Single
import io.realm.RealmResults
interface TagRepository : BaseRepository {
fun getTags(): Flowable<RealmResults<Tag>>
fun getTags(userId: String): Flowable<RealmResults<Tag>>
fun getTags(): Flowable<out List<Tag>>
fun getTags(userId: String): Flowable<out List<Tag>>
fun createTag(tag: Tag): Flowable<Tag>
fun updateTag(tag: Tag): Flowable<Tag>

View file

@ -1,5 +1,6 @@
package com.habitrpg.android.habitica.data
import com.habitrpg.android.habitica.models.BaseMainObject
import com.habitrpg.android.habitica.models.BaseObject
import com.habitrpg.android.habitica.models.responses.BulkTaskScoringData
import com.habitrpg.android.habitica.models.responses.TaskScoringResult
@ -11,15 +12,13 @@ import com.habitrpg.android.habitica.models.user.User
import io.reactivex.rxjava3.core.Flowable
import io.reactivex.rxjava3.core.Maybe
import io.reactivex.rxjava3.core.Single
import io.realm.Realm
import io.realm.RealmResults
import java.util.*
interface TaskRepository : BaseRepository {
fun getTasks(taskType: String, userID: String): Flowable<RealmResults<Task>>
fun getTasks(userId: String): Flowable<RealmResults<Task>>
fun getCurrentUserTasks(taskType: String): Flowable<RealmResults<Task>>
fun getTasksOfType(taskType: String): Flowable<RealmResults<Task>>
fun getTasks(taskType: String, userID: String): Flowable<out List<Task>>
fun getTasks(userId: String): Flowable<out List<Task>>
fun getCurrentUserTasks(taskType: String): Flowable<out List<Task>>
fun getTasksOfType(taskType: String): Flowable<out List<Task>>
fun saveTasks(userId: String, order: TasksOrder, tasks: TaskList)
fun retrieveTasks(userId: String, tasksOrder: TasksOrder): Flowable<TaskList>
@ -42,7 +41,7 @@ interface TaskRepository : BaseRepository {
fun saveReminder(remindersItem: RemindersItem)
fun <T: BaseObject> modify(obj: T, transaction: (T) -> Unit)
fun <T: BaseMainObject> modify(obj: T, transaction: (T) -> Unit)
fun swapTaskPosition(firstPosition: Int, secondPosition: Int)
@ -62,6 +61,6 @@ interface TaskRepository : BaseRepository {
fun retrieveCompletedTodos(userId: String): Flowable<TaskList>
fun syncErroredTasks(): Single<List<Task>>
fun unlinkAllTasks(challengeID: String?, keepOption: String): Flowable<Void>
fun getTasksForChallenge(challengeID: String?): Flowable<RealmResults<Task>>
fun getTasksForChallenge(challengeID: String?): Flowable<out List<Task>>
fun bulkScoreTasks(data: List<Map<String, String>>): Flowable<BulkTaskScoringData>
}

View file

@ -2,11 +2,10 @@ package com.habitrpg.android.habitica.data
import com.habitrpg.android.habitica.models.TutorialStep
import io.reactivex.rxjava3.core.Flowable
import io.realm.RealmResults
interface TutorialRepository : BaseRepository {
fun getTutorialStep(key: String): Flowable<TutorialStep>
fun getTutorialSteps(keys: List<String>): Flowable<RealmResults<TutorialStep>>
fun getTutorialSteps(keys: List<String>): Flowable<out List<TutorialStep>>
}

View file

@ -16,7 +16,6 @@ import com.habitrpg.android.habitica.models.user.Stats
import com.habitrpg.android.habitica.models.user.User
import io.reactivex.rxjava3.core.Flowable
import io.reactivex.rxjava3.core.Maybe
import io.realm.RealmResults
interface UserRepository : BaseRepository {
fun getUser(): Flowable<User>
@ -34,9 +33,9 @@ interface UserRepository : BaseRepository {
fun sleep(user: User): Flowable<User>
fun getSkills(user: User): Flowable<RealmResults<Skill>>
fun getSkills(user: User): Flowable<out List<Skill>>
fun getSpecialItems(user: User): Flowable<RealmResults<Skill>>
fun getSpecialItems(user: User): Flowable<out List<Skill>>
fun useSkill(key: String, target: String?, taskId: String): Flowable<SkillResponse>
fun useSkill(key: String, target: String?): Flowable<SkillResponse>
@ -76,14 +75,14 @@ interface UserRepository : BaseRepository {
fun useCustomization(type: String, category: String?, identifier: String): Flowable<User>
fun retrieveAchievements(): Flowable<List<Achievement>>
fun getAchievements(): Flowable<RealmResults<Achievement>>
fun getQuestAchievements(): Flowable<RealmResults<QuestAchievement>>
fun getAchievements(): Flowable<out List<Achievement>>
fun getQuestAchievements(): Flowable<out List<QuestAchievement>>
fun getUserQuestStatus(): Flowable<UserQuestStatus>
fun reroll(): Flowable<User>
fun retrieveTeamPlans(): Flowable<List<TeamPlan>>
fun getTeamPlans(): Flowable<RealmResults<TeamPlan>>
fun getTeamPlans(): Flowable<out List<TeamPlan>>
fun retrieveTeamPlan(teamID: String): Flowable<Group>
fun getTeamPlan(teamID: String): Flowable<Group>
}

View file

@ -3,8 +3,7 @@ package com.habitrpg.android.habitica.data.implementation
import com.habitrpg.android.habitica.data.ApiClient
import com.habitrpg.android.habitica.data.BaseRepository
import com.habitrpg.android.habitica.data.local.BaseLocalRepository
import io.realm.RealmObject
import com.habitrpg.android.habitica.models.BaseObject
abstract class BaseRepositoryImpl<T : BaseLocalRepository>(protected val localRepository: T, protected val apiClient: ApiClient, protected val userID: String = "") : BaseRepository {
@ -12,14 +11,14 @@ abstract class BaseRepositoryImpl<T : BaseLocalRepository>(protected val localRe
this.localRepository.close()
}
override fun <T : RealmObject> getUnmanagedCopy(list: List<T>): List<T> {
override fun <T: BaseObject> getUnmanagedCopy(list: List<T>): List<T> {
return localRepository.getUnmanagedCopy(list)
}
override val isClosed: Boolean
get() = localRepository.isClosed
override fun <T : RealmObject> getUnmanagedCopy(obj: T): T {
override fun <T: BaseObject> getUnmanagedCopy(obj: T): T {
return localRepository.getUnmanagedCopy(obj)
}
}

View file

@ -10,7 +10,6 @@ import com.habitrpg.android.habitica.models.tasks.Task
import com.habitrpg.android.habitica.models.tasks.TaskList
import com.habitrpg.android.habitica.models.tasks.TasksOrder
import io.reactivex.rxjava3.core.Flowable
import io.realm.RealmResults
class ChallengeRepositoryImpl(localRepository: ChallengeLocalRepository, apiClient: ApiClient, userID: String) : BaseRepositoryImpl<ChallengeLocalRepository>(localRepository, apiClient, userID), ChallengeRepository {
@ -23,7 +22,7 @@ class ChallengeRepositoryImpl(localRepository: ChallengeLocalRepository, apiClie
return localRepository.getChallengeMembership(userID, id)
}
override fun getChallengeMemberships(): Flowable<RealmResults<ChallengeMembership>> {
override fun getChallengeMemberships(): Flowable<out List<ChallengeMembership>> {
return localRepository.getChallengeMemberships(userID)
}
@ -31,7 +30,7 @@ class ChallengeRepositoryImpl(localRepository: ChallengeLocalRepository, apiClie
return localRepository.getChallenge(challengeId)
}
override fun getChallengeTasks(challengeId: String): Flowable<RealmResults<Task>> {
override fun getChallengeTasks(challengeId: String): Flowable<out List<Task>> {
return localRepository.getTasks(challengeId)
}
@ -114,11 +113,11 @@ class ChallengeRepositoryImpl(localRepository: ChallengeLocalRepository, apiClie
return apiClient.deleteChallenge(challengeId)
}
override fun getChallenges(): Flowable<RealmResults<Challenge>> {
override fun getChallenges(): Flowable<out List<Challenge>> {
return localRepository.challenges
}
override fun getUserChallenges(userId: String?): Flowable<RealmResults<Challenge>> {
override fun getUserChallenges(userId: String?): Flowable<out List<Challenge>> {
return localRepository.getUserChallenges(userId ?: userID)
}

View file

@ -6,11 +6,10 @@ import com.habitrpg.android.habitica.data.local.CustomizationLocalRepository
import com.habitrpg.android.habitica.models.inventory.Customization
import io.reactivex.rxjava3.core.Flowable
import io.realm.RealmResults
class CustomizationRepositoryImpl(localRepository: CustomizationLocalRepository, apiClient: ApiClient, userID: String) : BaseRepositoryImpl<CustomizationLocalRepository>(localRepository, apiClient, userID), CustomizationRepository {
override fun getCustomizations(type: String, category: String?, onlyAvailable: Boolean): Flowable<RealmResults<Customization>> {
override fun getCustomizations(type: String, category: String?, onlyAvailable: Boolean): Flowable<out List<Customization>> {
return localRepository.getCustomizations(type, category, onlyAvailable)
}
}

View file

@ -6,7 +6,6 @@ import com.habitrpg.android.habitica.data.local.FAQLocalRepository
import com.habitrpg.android.habitica.models.FAQArticle
import io.reactivex.rxjava3.core.Flowable
import io.realm.RealmResults
class FAQRepositoryImpl(localRepository: FAQLocalRepository, apiClient: ApiClient, userID: String) : BaseRepositoryImpl<FAQLocalRepository>(localRepository, apiClient, userID), FAQRepository {
@ -14,7 +13,7 @@ class FAQRepositoryImpl(localRepository: FAQLocalRepository, apiClient: ApiClien
return localRepository.getArticle(position)
}
override fun getArticles(): Flowable<RealmResults<FAQArticle>> {
override fun getArticles(): Flowable<out List<FAQArticle>> {
return localRepository.articles
}
}

View file

@ -11,10 +11,9 @@ import com.habitrpg.android.habitica.models.shops.Shop
import com.habitrpg.android.habitica.models.shops.ShopItem
import com.habitrpg.android.habitica.models.user.*
import io.reactivex.rxjava3.core.Flowable
import io.realm.RealmResults
class InventoryRepositoryImpl(localRepository: InventoryLocalRepository, apiClient: ApiClient, userID: String, var appConfigManager: AppConfigManager) : BaseRepositoryImpl<InventoryLocalRepository>(localRepository, apiClient, userID), InventoryRepository {
override fun getQuestContent(keys: List<String>): Flowable<RealmResults<QuestContent>> {
override fun getQuestContent(keys: List<String>): Flowable<out List<QuestContent>> {
return localRepository.getQuestContent(keys)
}
@ -22,7 +21,7 @@ class InventoryRepositoryImpl(localRepository: InventoryLocalRepository, apiClie
return localRepository.getQuestContent(key)
}
override fun getEquipment(searchedKeys: List<String>): Flowable<RealmResults<Equipment>> {
override fun getEquipment(searchedKeys: List<String>): Flowable<out List<Equipment>> {
return localRepository.getEquipment(searchedKeys)
}
@ -30,7 +29,7 @@ class InventoryRepositoryImpl(localRepository: InventoryLocalRepository, apiClie
return localRepository.getArmoireRemainingCount()
}
override fun getInAppRewards(): Flowable<RealmResults<ShopItem>> {
override fun getInAppRewards(): Flowable<out List<ShopItem>> {
return localRepository.getInAppRewards()
}
@ -38,19 +37,19 @@ class InventoryRepositoryImpl(localRepository: InventoryLocalRepository, apiClie
return apiClient.retrieveInAppRewards().doOnNext { localRepository.saveInAppRewards(it) }
}
override fun getOwnedEquipment(type: String): Flowable<RealmResults<Equipment>> {
override fun getOwnedEquipment(type: String): Flowable<out List<Equipment>> {
return localRepository.getOwnedEquipment(type)
}
override fun getOwnedEquipment(): Flowable<RealmResults<Equipment>> {
override fun getOwnedEquipment(): Flowable<out List<Equipment>> {
return localRepository.getOwnedEquipment()
}
override fun getEquipmentType(type: String, set: String): Flowable<RealmResults<Equipment>> {
override fun getEquipmentType(type: String, set: String): Flowable<out List<Equipment>> {
return localRepository.getEquipmentType(type, set)
}
override fun getOwnedItems(itemType: String, includeZero: Boolean): Flowable<RealmResults<OwnedItem>> {
override fun getOwnedItems(itemType: String, includeZero: Boolean): Flowable<out List<OwnedItem>> {
return localRepository.getOwnedItems(itemType, userID, includeZero)
}
@ -58,11 +57,11 @@ class InventoryRepositoryImpl(localRepository: InventoryLocalRepository, apiClie
return localRepository.getOwnedItems(userID, includeZero)
}
override fun getItems(itemClass: Class<out Item>, keys: Array<String>): Flowable<out RealmResults<out Item>> {
override fun getItems(itemClass: Class<out Item>, keys: Array<String>): Flowable<out List<Item>> {
return localRepository.getItems(itemClass, keys)
}
override fun getItems(itemClass: Class<out Item>): Flowable<out RealmResults<out Item>> {
override fun getItems(itemClass: Class<out Item>): Flowable<out List<Item>> {
return localRepository.getItems(itemClass)
}
@ -86,27 +85,27 @@ class InventoryRepositoryImpl(localRepository: InventoryLocalRepository, apiClie
localRepository.save(equipment)
}
override fun getMounts(): Flowable<RealmResults<Mount>> {
override fun getMounts(): Flowable<out List<Mount>> {
return localRepository.getMounts()
}
override fun getMounts(type: String?, group: String?, color: String?): Flowable<RealmResults<Mount>> {
override fun getMounts(type: String?, group: String?, color: String?): Flowable<out List<Mount>> {
return localRepository.getMounts(type, group, color)
}
override fun getOwnedMounts(): Flowable<RealmResults<OwnedMount>> {
override fun getOwnedMounts(): Flowable<out List<OwnedMount>> {
return localRepository.getOwnedMounts(userID)
}
override fun getPets(): Flowable<RealmResults<Pet>> {
override fun getPets(): Flowable<out List<Pet>> {
return localRepository.getPets()
}
override fun getPets(type: String?, group: String?, color: String?): Flowable<RealmResults<Pet>> {
override fun getPets(type: String?, group: String?, color: String?): Flowable<out List<Pet>> {
return localRepository.getPets(type, group, color)
}
override fun getOwnedPets(): Flowable<RealmResults<OwnedPet>> {
override fun getOwnedPets(): Flowable<out List<OwnedPet>> {
return localRepository.getOwnedPets(userID)
}

View file

@ -13,7 +13,6 @@ import com.habitrpg.android.habitica.models.social.*
import com.habitrpg.android.habitica.models.user.User
import io.reactivex.rxjava3.core.Flowable
import io.reactivex.rxjava3.core.Single
import io.realm.RealmResults
import java.util.*
import kotlin.collections.HashMap
@ -49,7 +48,7 @@ class SocialRepositoryImpl(localRepository: SocialLocalRepository, apiClient: Ap
return localRepository.getGroupMembership(userID, id)
}
override fun getGroupMemberships(): Flowable<RealmResults<GroupMembership>> {
override fun getGroupMemberships(): Flowable<out List<GroupMembership>> {
return localRepository.getGroupMemberships(userID)
}
@ -64,7 +63,7 @@ class SocialRepositoryImpl(localRepository: SocialLocalRepository, apiClient: Ap
.doOnSuccess { localRepository.saveChatMessages(groupId, it) }
}
override fun getGroupChat(groupId: String): Flowable<RealmResults<ChatMessage>> {
override fun getGroupChat(groupId: String): Flowable<out List<ChatMessage>> {
return localRepository.getGroupChat(groupId)
}
@ -199,13 +198,13 @@ class SocialRepositoryImpl(localRepository: SocialLocalRepository, apiClient: Ap
}
}
override fun getGroups(type: String): Flowable<RealmResults<Group>> = localRepository.getGroups(type)
override fun getGroups(type: String): Flowable<out List<Group>> = localRepository.getGroups(type)
override fun getPublicGuilds(): Flowable<RealmResults<Group>> = localRepository.getPublicGuilds()
override fun getPublicGuilds(): Flowable<out List<Group>> = localRepository.getPublicGuilds()
override fun getInboxConversations(): Flowable<RealmResults<InboxConversation>> = localRepository.getInboxConversation(userID)
override fun getInboxConversations(): Flowable<out List<InboxConversation>> = localRepository.getInboxConversation(userID)
override fun getInboxMessages(replyToUserID: String?): Flowable<RealmResults<ChatMessage>> = localRepository.getInboxMessages(userID, replyToUserID)
override fun getInboxMessages(replyToUserID: String?): Flowable<out List<ChatMessage>> = localRepository.getInboxMessages(userID, replyToUserID)
override fun retrieveInboxMessages(uuid: String, page: Int): Flowable<List<ChatMessage>> {
return apiClient.retrieveInboxMessages(uuid, page).doOnNext { messages ->
@ -233,7 +232,7 @@ class SocialRepositoryImpl(localRepository: SocialLocalRepository, apiClient: Ap
return postPrivateMessage(recipientId, messageObject)
}
override fun getGroupMembers(id: String): Flowable<RealmResults<Member>> = localRepository.getGroupMembers(id)
override fun getGroupMembers(id: String): Flowable<out List<Member>> = localRepository.getGroupMembers(id)
override fun retrieveGroupMembers(id: String, includeAllPublicFields: Boolean): Flowable<List<Member>> {
return apiClient.getGroupMembers(id, includeAllPublicFields)
@ -271,7 +270,7 @@ class SocialRepositoryImpl(localRepository: SocialLocalRepository, apiClient: Ap
}
}
override fun getUserGroups(type: String?): Flowable<RealmResults<Group>> = localRepository.getUserGroups(userID, type)
override fun getUserGroups(type: String?): Flowable<out List<Group>> = localRepository.getUserGroups(userID, type)
override fun acceptQuest(user: User?, partyId: String): Flowable<Void> {
return apiClient.acceptQuest(partyId)

View file

@ -6,16 +6,15 @@ import com.habitrpg.android.habitica.data.local.TagLocalRepository
import com.habitrpg.android.habitica.models.Tag
import io.reactivex.rxjava3.core.Flowable
import io.reactivex.rxjava3.core.Single
import io.realm.RealmResults
class TagRepositoryImpl(localRepository: TagLocalRepository, apiClient: ApiClient, userID: String) : BaseRepositoryImpl<TagLocalRepository>(localRepository, apiClient, userID), TagRepository {
override fun getTags(): Flowable<RealmResults<Tag>> {
override fun getTags(): Flowable<out List<Tag>> {
return getTags(userID)
}
override fun getTags(userId: String): Flowable<RealmResults<Tag>> {
override fun getTags(userId: String): Flowable<out List<Tag>> {
return localRepository.getTags(userId)
}

View file

@ -7,6 +7,7 @@ import com.habitrpg.android.habitica.data.local.TaskLocalRepository
import com.habitrpg.android.habitica.helpers.AppConfigManager
import com.habitrpg.android.habitica.helpers.RxErrorHandler
import com.habitrpg.android.habitica.interactors.ScoreTaskLocallyInteractor
import com.habitrpg.android.habitica.models.BaseMainObject
import com.habitrpg.android.habitica.models.BaseObject
import com.habitrpg.android.habitica.models.responses.BulkTaskScoringData
import com.habitrpg.android.habitica.models.responses.TaskDirection
@ -19,27 +20,26 @@ import com.habitrpg.android.habitica.proxy.AnalyticsManager
import io.reactivex.rxjava3.core.Flowable
import io.reactivex.rxjava3.core.Maybe
import io.reactivex.rxjava3.core.Single
import io.realm.RealmResults
import java.text.SimpleDateFormat
import java.util.*
class TaskRepositoryImpl(localRepository: TaskLocalRepository, apiClient: ApiClient, userID: String, val appConfigManager: AppConfigManager, val analyticsManager: AnalyticsManager) : BaseRepositoryImpl<TaskLocalRepository>(localRepository, apiClient, userID), TaskRepository {
override fun getTasksOfType(taskType: String): Flowable<RealmResults<Task>> = getTasks(taskType, userID)
override fun getTasksOfType(taskType: String): Flowable<out List<Task>> = getTasks(taskType, userID)
private var lastTaskAction: Long = 0
override fun getTasks(taskType: String, userID: String): Flowable<RealmResults<Task>> =
override fun getTasks(taskType: String, userID: String): Flowable<out List<Task>> =
this.localRepository.getTasks(taskType, userID)
override fun getTasks(userId: String): Flowable<RealmResults<Task>> =
override fun getTasks(userId: String): Flowable<out List<Task>> =
this.localRepository.getTasks(userId)
override fun getCurrentUserTasks(taskType: String): Flowable<RealmResults<Task>> =
override fun getCurrentUserTasks(taskType: String): Flowable<out List<Task>> =
this.localRepository.getTasks(taskType, userID)
override fun saveTasks(ownerID: String, order: TasksOrder, tasks: TaskList) {
localRepository.saveTasks(ownerID, order, tasks)
override fun saveTasks(userId: String, order: TasksOrder, tasks: TaskList) {
localRepository.saveTasks(userId, order, tasks)
}
override fun retrieveTasks(userId: String, tasksOrder: TasksOrder): Flowable<TaskList> {
@ -154,10 +154,10 @@ class TaskRepositoryImpl(localRepository: TaskLocalRepository, apiClient: ApiCli
}
}
res._tmp?.drop?.key?.let { key ->
val type = when(res._tmp?.drop?.type?.toLowerCase(Locale.US)) {
val type = when(res._tmp?.drop?.type?.lowercase(Locale.US)) {
"hatchingpotion" -> "hatchingPotions"
"egg" -> "eggs"
else -> res._tmp?.drop?.type?.toLowerCase(Locale.US)
else -> res._tmp?.drop?.type?.lowercase(Locale.US)
}
var item = it.where(OwnedItem::class.java).equalTo("itemType", type).equalTo("key", key).findFirst()
if (item == null) {
@ -175,7 +175,7 @@ class TaskRepositoryImpl(localRepository: TaskLocalRepository, apiClient: ApiCli
stats?.exp = res.exp
stats?.mp = res.mp
stats?.gp = res.gp
stats?.lvl = res.lvl.toInt()
stats?.lvl = res.lvl
bgUser.party?.quest?.progress?.up = (bgUser.party?.quest?.progress?.up
?: 0F) + (res._tmp?.quest?.progressDelta?.toFloat() ?: 0F)
bgUser.stats = stats
@ -278,7 +278,7 @@ class TaskRepositoryImpl(localRepository: TaskLocalRepository, apiClient: ApiCli
localRepository.saveReminder(remindersItem)
}
override fun <T: BaseObject> modify(obj: T, transaction: (T) -> Unit) {
override fun <T: BaseMainObject> modify(obj: T, transaction: (T) -> Unit) {
localRepository.modify(obj, transaction)
}
@ -330,7 +330,7 @@ class TaskRepositoryImpl(localRepository: TaskLocalRepository, apiClient: ApiCli
return apiClient.unlinkAllTasks(challengeID, keepOption)
}
override fun getTasksForChallenge(challengeID: String?): Flowable<RealmResults<Task>> {
override fun getTasksForChallenge(challengeID: String?): Flowable<out List<Task>> {
return localRepository.getTasksForChallenge(challengeID, userID)
}
}

View file

@ -5,7 +5,6 @@ import com.habitrpg.android.habitica.data.TutorialRepository
import com.habitrpg.android.habitica.data.local.TutorialLocalRepository
import com.habitrpg.android.habitica.models.TutorialStep
import io.reactivex.rxjava3.core.Flowable
import io.realm.RealmResults
class TutorialRepositoryImpl(localRepository: TutorialLocalRepository, apiClient: ApiClient, userID: String) : BaseRepositoryImpl<TutorialLocalRepository>(localRepository, apiClient, userID), TutorialRepository {
@ -13,6 +12,6 @@ class TutorialRepositoryImpl(localRepository: TutorialLocalRepository, apiClient
override fun getTutorialStep(key: String): Flowable<TutorialStep> =
localRepository.getTutorialStep(key)
override fun getTutorialSteps(keys: List<String>): Flowable<RealmResults<TutorialStep>> =
override fun getTutorialSteps(keys: List<String>): Flowable<out List<TutorialStep>> =
localRepository.getTutorialSteps(keys)
}

View file

@ -25,8 +25,6 @@ import com.habitrpg.android.habitica.models.user.User
import io.reactivex.rxjava3.core.Flowable
import io.reactivex.rxjava3.core.Maybe
import io.reactivex.rxjava3.functions.BiFunction
import io.realm.RealmResults
import org.reactivestreams.Publisher
import java.util.*
import java.util.concurrent.TimeUnit
@ -117,10 +115,10 @@ class UserRepositoryImpl(localRepository: UserLocalRepository, apiClient: ApiCli
return apiClient.sleep().map { user }
}
override fun getSkills(user: User): Flowable<RealmResults<Skill>> =
override fun getSkills(user: User): Flowable<out List<Skill>> =
localRepository.getSkills(user)
override fun getSpecialItems(user: User): Flowable<RealmResults<Skill>> =
override fun getSpecialItems(user: User): Flowable<out List<Skill>> =
localRepository.getSpecialItems(user)
override fun useSkill(key: String, target: String?, taskId: String): Flowable<SkillResponse> {
@ -351,11 +349,11 @@ class UserRepositoryImpl(localRepository: UserLocalRepository, apiClient: ApiCli
}
}
override fun getAchievements(): Flowable<RealmResults<Achievement>> {
override fun getAchievements(): Flowable<out List<Achievement>> {
return localRepository.getAchievements()
}
override fun getQuestAchievements(): Flowable<RealmResults<QuestAchievement>> {
override fun getQuestAchievements(): Flowable<out List<QuestAchievement>> {
return localRepository.getQuestAchievements(userID)
}
@ -366,7 +364,7 @@ class UserRepositoryImpl(localRepository: UserLocalRepository, apiClient: ApiCli
}
}
override fun getTeamPlans(): Flowable<RealmResults<TeamPlan>> {
override fun getTeamPlans(): Flowable<out List<TeamPlan>> {
return localRepository.getTeamPlans(userID)
}

View file

@ -1,10 +1,9 @@
package com.habitrpg.android.habitica.data.local
import android.renderscript.BaseObj
import com.habitrpg.android.habitica.models.BaseMainObject
import com.habitrpg.android.habitica.models.BaseObject
import io.realm.Realm
import io.realm.RealmModel
import io.realm.RealmObject
interface BaseLocalRepository {
@ -17,14 +16,14 @@ interface BaseLocalRepository {
fun executeTransaction(transaction: Realm.Transaction)
fun executeTransactionAsync(transaction: (Realm) -> Unit)
fun executeTransactionAsync(transaction: Realm.Transaction)
fun <T: BaseObject> modify(obj: T, transaction: (T) -> Unit)
fun <T: BaseObject> modifyWithRealm(obj: T, transaction: (Realm, T) -> Unit)
fun <T: RealmModel> getLiveObject(obj: T): T?
fun <T: BaseMainObject> modify(obj: T, transaction: (T) -> Unit)
fun <T: BaseMainObject> modifyWithRealm(obj: T, transaction: (Realm, T) -> Unit)
fun <T: BaseObject> getLiveObject(obj: T): T?
fun <T: RealmObject> getUnmanagedCopy(managedObject: T): T
fun <T: RealmObject> getUnmanagedCopy(list: List<T>): List<T>
fun <T: BaseObject> getUnmanagedCopy(managedObject: T): T
fun <T: BaseObject> getUnmanagedCopy(list: List<T>): List<T>
fun <T: RealmObject> save(objects: List<T>)
fun <T: RealmObject> save(`object`: T)
fun <T: RealmObject> saveSyncronous(`object`: T)
fun <T: BaseObject> save(objects: List<T>)
fun <T: BaseObject> save(`object`: T)
fun <T: BaseObject> saveSyncronous(`object`: T)
}

View file

@ -6,21 +6,20 @@ import com.habitrpg.android.habitica.models.social.ChallengeMembership
import com.habitrpg.android.habitica.models.tasks.Task
import io.reactivex.rxjava3.core.Flowable
import io.realm.RealmResults
interface ChallengeLocalRepository : BaseLocalRepository {
val challenges: Flowable<RealmResults<Challenge>>
val challenges: Flowable<out List<Challenge>>
fun getChallenge(id: String): Flowable<Challenge>
fun getTasks(challengeID: String): Flowable<RealmResults<Task>>
fun getTasks(challengeID: String): Flowable<out List<Task>>
fun getUserChallenges(userId: String): Flowable<RealmResults<Challenge>>
fun getUserChallenges(userId: String): Flowable<out List<Challenge>>
fun setParticipating(userID: String, challengeID: String, isParticipating: Boolean)
fun saveChallenges(challenges: List<Challenge>, clearChallenges: Boolean, memberOnly: Boolean)
fun getChallengeMembership(userId: String, id: String): Flowable<ChallengeMembership>
fun getChallengeMemberships(userId: String): Flowable<RealmResults<ChallengeMembership>>
fun getChallengeMemberships(userId: String): Flowable<out List<ChallengeMembership>>
fun isChallengeMember(userID: String, challengeID: String): Flowable<Boolean>
}

View file

@ -3,8 +3,7 @@ package com.habitrpg.android.habitica.data.local
import com.habitrpg.android.habitica.models.inventory.Customization
import io.reactivex.rxjava3.core.Flowable
import io.realm.RealmResults
interface CustomizationLocalRepository : ContentLocalRepository {
fun getCustomizations(type: String, category: String?, onlyAvailable: Boolean): Flowable<RealmResults<Customization>>
fun getCustomizations(type: String, category: String?, onlyAvailable: Boolean): Flowable<out List<Customization>>
}

View file

@ -3,10 +3,9 @@ package com.habitrpg.android.habitica.data.local
import com.habitrpg.android.habitica.models.FAQArticle
import io.reactivex.rxjava3.core.Flowable
import io.realm.RealmResults
interface FAQLocalRepository : ContentLocalRepository {
fun getArticle(position: Int): Flowable<FAQArticle>
val articles: Flowable<RealmResults<FAQArticle>>
val articles: Flowable<out List<FAQArticle>>
}

View file

@ -7,38 +7,37 @@ import com.habitrpg.android.habitica.models.user.OwnedMount
import com.habitrpg.android.habitica.models.user.OwnedPet
import com.habitrpg.android.habitica.models.user.User
import io.reactivex.rxjava3.core.Flowable
import io.realm.RealmResults
interface InventoryLocalRepository : ContentLocalRepository {
fun getArmoireRemainingCount(): Long
fun getOwnedEquipment(): Flowable<RealmResults<Equipment>>
fun getOwnedEquipment(): Flowable<out List<Equipment>>
fun getMounts(): Flowable<RealmResults<Mount>>
fun getMounts(): Flowable<out List<Mount>>
fun getOwnedMounts(userID: String): Flowable<RealmResults<OwnedMount>>
fun getOwnedMounts(userID: String): Flowable<out List<OwnedMount>>
fun getPets(): Flowable<RealmResults<Pet>>
fun getPets(): Flowable<out List<Pet>>
fun getOwnedPets(userID: String): Flowable<RealmResults<OwnedPet>>
fun getOwnedPets(userID: String): Flowable<out List<OwnedPet>>
fun getInAppRewards(): Flowable<RealmResults<ShopItem>>
fun getInAppRewards(): Flowable<out List<ShopItem>>
fun getQuestContent(key: String): Flowable<QuestContent>
fun getQuestContent(keys: List<String>): Flowable<RealmResults<QuestContent>>
fun getQuestContent(keys: List<String>): Flowable<out List<QuestContent>>
fun getEquipment(searchedKeys: List<String>): Flowable<RealmResults<Equipment>>
fun getEquipment(searchedKeys: List<String>): Flowable<out List<Equipment>>
fun getOwnedEquipment(type: String): Flowable<RealmResults<Equipment>>
fun getOwnedEquipment(type: String): Flowable<out List<Equipment>>
fun getItems(itemClass: Class<out Item>, keys: Array<String>): Flowable<out RealmResults<out Item>>
fun getItems(itemClass: Class<out Item>): Flowable<out RealmResults<out Item>>
fun getOwnedItems(itemType: String, userID: String, includeZero: Boolean): Flowable<RealmResults<OwnedItem>>
fun getItems(itemClass: Class<out Item>, keys: Array<String>): Flowable<out List<Item>>
fun getItems(itemClass: Class<out Item>): Flowable<out List<Item>>
fun getOwnedItems(itemType: String, userID: String, includeZero: Boolean): Flowable<out List<OwnedItem>>
fun getOwnedItems(userID: String, includeZero: Boolean): Flowable<Map<String, OwnedItem>>
fun getEquipmentType(type: String, set: String): Flowable<RealmResults<Equipment>>
fun getEquipmentType(type: String, set: String): Flowable<out List<Equipment>>
fun getEquipment(key: String): Flowable<Equipment>
fun getMounts(type: String?, group: String?, color: String?): Flowable<RealmResults<Mount>>
fun getPets(type: String?, group: String?, color: String?): Flowable<RealmResults<Pet>>
fun getMounts(type: String?, group: String?, color: String?): Flowable<out List<Mount>>
fun getPets(type: String?, group: String?, color: String?): Flowable<out List<Pet>>
fun updateOwnedEquipment(user: User)

View file

@ -7,22 +7,21 @@ import com.habitrpg.android.habitica.models.social.GroupMembership
import com.habitrpg.android.habitica.models.social.InboxConversation
import com.habitrpg.android.habitica.models.user.User
import io.reactivex.rxjava3.core.Flowable
import io.realm.RealmResults
interface SocialLocalRepository : BaseLocalRepository {
fun getPublicGuilds(): Flowable<RealmResults<Group>>
fun getPublicGuilds(): Flowable<out List<Group>>
fun getUserGroups(userID: String, type: String?): Flowable<RealmResults<Group>>
fun getGroups(type: String): Flowable<RealmResults<Group>>
fun getUserGroups(userID: String, type: String?): Flowable<out List<Group>>
fun getGroups(type: String): Flowable<out List<Group>>
fun getGroup(id: String): Flowable<Group>
fun saveGroup(group: Group)
fun getGroupChat(groupId: String): Flowable<RealmResults<ChatMessage>>
fun getGroupChat(groupId: String): Flowable<out List<ChatMessage>>
fun deleteMessage(id: String)
fun getGroupMembers(partyId: String): Flowable<RealmResults<Member>>
fun getGroupMembers(partyId: String): Flowable<out List<Member>>
fun updateRSVPNeeded(user: User?, newValue: Boolean)
@ -39,12 +38,12 @@ interface SocialLocalRepository : BaseLocalRepository {
fun doesGroupExist(id: String): Boolean
fun updateMembership(userId: String, id: String, isMember: Boolean)
fun getGroupMembership(userId: String, id: String): Flowable<GroupMembership>
fun getGroupMemberships(userId: String): Flowable<RealmResults<GroupMembership>>
fun getGroupMemberships(userId: String): Flowable<out List<GroupMembership>>
fun rejectGroupInvitation(userID: String, groupID: String)
fun getInboxMessages(userId: String, replyToUserID: String?): Flowable<RealmResults<ChatMessage>>
fun getInboxMessages(userId: String, replyToUserID: String?): Flowable<out List<ChatMessage>>
fun getInboxConversation(userId: String): Flowable<RealmResults<InboxConversation>>
fun getInboxConversation(userId: String): Flowable<out List<InboxConversation>>
fun saveGroupMemberships(userID: String?, memberships: List<GroupMembership>)
fun saveInboxMessages(userID: String, recipientID: String, messages: List<ChatMessage>, page: Int)
fun saveInboxConversations(userID: String, conversations: List<InboxConversation>)

View file

@ -3,10 +3,9 @@ package com.habitrpg.android.habitica.data.local
import com.habitrpg.android.habitica.models.Tag
import io.reactivex.rxjava3.core.Flowable
import io.realm.RealmResults
interface TagLocalRepository : BaseLocalRepository {
fun getTags(userId: String): Flowable<RealmResults<Tag>>
fun getTags(userId: String): Flowable<out List<Tag>>
fun removeOldTags(onlineTags: List<Tag>, userID: String)
fun deleteTag(tagID: String)

View file

@ -7,12 +7,11 @@ import com.habitrpg.android.habitica.models.tasks.TasksOrder
import com.habitrpg.android.habitica.models.user.User
import io.reactivex.rxjava3.core.Flowable
import io.reactivex.rxjava3.core.Maybe
import io.realm.RealmResults
interface TaskLocalRepository : BaseLocalRepository {
fun getTasks(taskType: String, userID: String): Flowable<RealmResults<Task>>
fun getTasks(userId: String): Flowable<RealmResults<Task>>
fun getTasks(taskType: String, userID: String): Flowable<out List<Task>>
fun getTasks(userId: String): Flowable<out List<Task>>
fun saveTasks(userId: String, tasksOrder: TasksOrder, tasks: TaskList)
@ -33,7 +32,7 @@ interface TaskLocalRepository : BaseLocalRepository {
fun updateTaskPositions(taskOrder: List<String>)
fun saveCompletedTodos(userId: String, tasks: MutableCollection<Task>)
fun getErroredTasks(userID: String): Flowable<RealmResults<Task>>
fun getErroredTasks(userID: String): Flowable<out List<Task>>
fun getUser(userID: String): Flowable<User>
fun getTasksForChallenge(challengeID: String?, userID: String?): Flowable<RealmResults<Task>>
fun getTasksForChallenge(challengeID: String?, userID: String?): Flowable<out List<Task>>
}

View file

@ -2,10 +2,9 @@ package com.habitrpg.android.habitica.data.local
import com.habitrpg.android.habitica.models.TutorialStep
import io.reactivex.rxjava3.core.Flowable
import io.realm.RealmResults
interface TutorialLocalRepository : BaseLocalRepository {
fun getTutorialStep(key: String): Flowable<TutorialStep>
fun getTutorialSteps(keys: List<String>): Flowable<RealmResults<TutorialStep>>
fun getTutorialSteps(keys: List<String>): Flowable<out List<TutorialStep>>
}

View file

@ -5,7 +5,6 @@ import com.habitrpg.android.habitica.models.social.ChatMessage
import com.habitrpg.android.habitica.models.social.Group
import com.habitrpg.android.habitica.models.user.User
import io.reactivex.rxjava3.core.Flowable
import io.realm.RealmResults
enum class UserQuestStatus {
NO_QUEST,
@ -16,7 +15,7 @@ enum class UserQuestStatus {
interface UserLocalRepository : BaseLocalRepository {
fun getTutorialSteps(): Flowable<RealmResults<TutorialStep>>
fun getTutorialSteps(): Flowable<List<TutorialStep>>
fun getUser(userID: String): Flowable<User>
@ -24,12 +23,12 @@ interface UserLocalRepository : BaseLocalRepository {
fun saveMessages(messages: List<ChatMessage>)
fun getSkills(user: User): Flowable<RealmResults<Skill>>
fun getSkills(user: User): Flowable<out List<Skill>>
fun getSpecialItems(user: User): Flowable<RealmResults<Skill>>
fun getAchievements(): Flowable<RealmResults<Achievement>>
fun getQuestAchievements(userID: String): Flowable<RealmResults<QuestAchievement>>
fun getSpecialItems(user: User): Flowable<out List<Skill>>
fun getAchievements(): Flowable<out List<Achievement>>
fun getQuestAchievements(userID: String): Flowable<out List<QuestAchievement>>
fun getUserQuestStatus(userID: String): Flowable<UserQuestStatus>
fun getTeamPlans(userID: String): Flowable<RealmResults<TeamPlan>>
fun getTeamPlans(userID: String): Flowable<out List<TeamPlan>>
fun getTeamPlan(teamID: String): Flowable<Group>
}

View file

@ -2,13 +2,11 @@ package com.habitrpg.android.habitica.data.local.implementation
import android.renderscript.BaseObj
import com.habitrpg.android.habitica.data.local.BaseLocalRepository
import com.habitrpg.android.habitica.models.BaseMainObject
import com.habitrpg.android.habitica.models.BaseObject
import io.realm.Realm
import io.realm.RealmModel
import io.realm.RealmObject
import io.realm.kotlin.isManaged
import io.realm.kotlin.where
abstract class RealmBaseLocalRepository internal constructor(override var realm: Realm) : BaseLocalRepository {
@ -43,35 +41,35 @@ abstract class RealmBaseLocalRepository internal constructor(override var realm:
realm.executeTransactionAsync(transaction)
}
override fun <T : RealmObject> getUnmanagedCopy(managedObject: T): T {
return if (managedObject.isManaged && managedObject.isValid) {
override fun <T : BaseObject> getUnmanagedCopy(managedObject: T): T {
return if (managedObject is RealmObject && managedObject.isManaged && managedObject.isValid) {
realm.copyFromRealm(managedObject)
} else {
managedObject
}
}
override fun <T : RealmObject> getUnmanagedCopy(list: List<T>): List<T> {
override fun <T : BaseObject> getUnmanagedCopy(list: List<T>): List<T> {
if (isClosed) { return emptyList() }
return realm.copyFromRealm(list)
}
override fun <T : RealmObject> save(`object`: T) {
override fun <T : BaseObject> save(`object`: T) {
if (isClosed) { return }
realm.executeTransactionAsync { realm1 -> realm1.insertOrUpdate(`object`) }
}
override fun <T : RealmObject> save(objects: List<T>) {
override fun <T : BaseObject> save(objects: List<T>) {
if (isClosed) { return }
realm.executeTransactionAsync { realm1 -> realm1.insertOrUpdate(objects) }
}
override fun <T : RealmObject> saveSyncronous(`object`: T) {
override fun <T : BaseObject> saveSyncronous(`object`: T) {
if (isClosed) { return }
realm.executeTransaction { realm1 -> realm1.insertOrUpdate(`object`) }
}
override fun <T: BaseObject> modify(obj: T, transaction: (T) -> Unit) {
override fun <T: BaseMainObject> modify(obj: T, transaction: (T) -> Unit) {
if (isClosed) { return }
val liveObject = getLiveObject(obj) ?: return
realm.executeTransaction {
@ -79,7 +77,7 @@ abstract class RealmBaseLocalRepository internal constructor(override var realm:
}
}
override fun <T: BaseObject> modifyWithRealm(obj: T, transaction: (Realm, T) -> Unit) {
override fun <T: BaseMainObject> modifyWithRealm(obj: T, transaction: (Realm, T) -> Unit) {
if (isClosed) { return }
val liveObject = getLiveObject(obj) ?: return
realm.executeTransaction {
@ -87,10 +85,10 @@ abstract class RealmBaseLocalRepository internal constructor(override var realm:
}
}
override fun <T: RealmModel> getLiveObject(obj: T): T? {
override fun <T: BaseObject> getLiveObject(obj: T): T? {
if (isClosed) return null
if (!obj.isManaged()) return obj
val baseObject = obj as? BaseObject ?: return null
if (!(obj is RealmObject) || !obj.isManaged) return obj
val baseObject = obj as? BaseMainObject ?: return null
return realm.where(baseObject.realmClass).equalTo(baseObject.primaryIdentifierName, baseObject.primaryIdentifier).findFirst() as? T
}
}

View file

@ -7,7 +7,6 @@ import com.habitrpg.android.habitica.models.tasks.Task
import hu.akarnokd.rxjava3.bridge.RxJavaBridge
import io.reactivex.rxjava3.core.Flowable
import io.realm.Realm
import io.realm.RealmResults
import io.realm.Sort
import java.util.*
@ -27,7 +26,7 @@ class RealmChallengeLocalRepository(realm: Realm) : RealmBaseLocalRepository(rea
.asFlowable()
.filter { it.isLoaded }).map { it.first() }
override fun getChallengeMemberships(userId: String): Flowable<RealmResults<ChallengeMembership>> = RxJavaBridge.toV3Flowable(realm.where(ChallengeMembership::class.java)
override fun getChallengeMemberships(userId: String): Flowable<out List<ChallengeMembership>> = RxJavaBridge.toV3Flowable(realm.where(ChallengeMembership::class.java)
.equalTo("userID", userId)
.findAll()
.asFlowable()
@ -42,7 +41,7 @@ class RealmChallengeLocalRepository(realm: Realm) : RealmBaseLocalRepository(rea
.map { it.first() })
}
override fun getTasks(challengeID: String): Flowable<RealmResults<Task>> {
override fun getTasks(challengeID: String): Flowable<out List<Task>> {
return RxJavaBridge.toV3Flowable(realm.where(Task::class.java)
.equalTo("userId", challengeID)
.findAll()
@ -50,7 +49,7 @@ class RealmChallengeLocalRepository(realm: Realm) : RealmBaseLocalRepository(rea
.filter { realmObject -> realmObject.isLoaded })
}
override val challenges: Flowable<RealmResults<Challenge>>
override val challenges: Flowable<out List<Challenge>>
get() = RxJavaBridge.toV3Flowable(realm.where(Challenge::class.java)
.isNotNull("name")
.sort("official", Sort.DESCENDING, "createdAt", Sort.DESCENDING)
@ -58,7 +57,7 @@ class RealmChallengeLocalRepository(realm: Realm) : RealmBaseLocalRepository(rea
.asFlowable()
.filter { it.isLoaded })
override fun getUserChallenges(userId: String): Flowable<RealmResults<Challenge>> {
override fun getUserChallenges(userId: String): Flowable<out List<Challenge>> {
return RxJavaBridge.toV3Flowable(realm.where(ChallengeMembership::class.java)
.equalTo("userID", userId)
.findAll()

View file

@ -5,13 +5,12 @@ import com.habitrpg.android.habitica.models.inventory.Customization
import hu.akarnokd.rxjava3.bridge.RxJavaBridge
import io.reactivex.rxjava3.core.Flowable
import io.realm.Realm
import io.realm.RealmResults
import java.util.*
class RealmCustomizationLocalRepository(realm: Realm) : RealmContentLocalRepository(realm), CustomizationLocalRepository {
override fun getCustomizations(type: String, category: String?, onlyAvailable: Boolean): Flowable<RealmResults<Customization>> {
override fun getCustomizations(type: String, category: String?, onlyAvailable: Boolean): Flowable<out List<Customization>> {
var query = realm.where(Customization::class.java)
.equalTo("type", type)
.equalTo("category", category)
@ -34,6 +33,7 @@ class RealmCustomizationLocalRepository(realm: Realm) : RealmContentLocalReposit
.sort("customizationSetName")
.findAll()
.asFlowable()
.filter { it.isLoaded })
.filter { it.isLoaded }
.map { it })
}
}

View file

@ -5,7 +5,6 @@ import com.habitrpg.android.habitica.models.FAQArticle
import hu.akarnokd.rxjava3.bridge.RxJavaBridge
import io.reactivex.rxjava3.core.Flowable
import io.realm.Realm
import io.realm.RealmResults
class RealmFAQLocalRepository(realm: Realm) : RealmContentLocalRepository(realm), FAQLocalRepository {
override fun getArticle(position: Int): Flowable<FAQArticle> {
@ -17,7 +16,7 @@ class RealmFAQLocalRepository(realm: Realm) : RealmContentLocalRepository(realm)
.map { it.first() })
}
override val articles: Flowable<RealmResults<FAQArticle>>
override val articles: Flowable<out List<FAQArticle>>
get() = RxJavaBridge.toV3Flowable(realm.where(FAQArticle::class.java)
.findAll()
.asFlowable()

View file

@ -12,7 +12,6 @@ import hu.akarnokd.rxjava3.bridge.RxJavaBridge
import io.reactivex.rxjava3.core.Flowable
import io.realm.Realm
import io.realm.RealmObject
import io.realm.RealmResults
import io.realm.Sort
import java.text.SimpleDateFormat
import java.util.*
@ -20,7 +19,7 @@ import kotlin.collections.HashMap
class RealmInventoryLocalRepository(realm: Realm) : RealmContentLocalRepository(realm), InventoryLocalRepository {
override fun getQuestContent(keys: List<String>): Flowable<RealmResults<QuestContent>> {
override fun getQuestContent(keys: List<String>): Flowable<out List<QuestContent>> {
return RxJavaBridge.toV3Flowable(realm.where(QuestContent::class.java)
.`in`("key", keys.toTypedArray())
.findAll()
@ -36,7 +35,7 @@ class RealmInventoryLocalRepository(realm: Realm) : RealmContentLocalRepository(
.map { content -> content.first() })
}
override fun getEquipment(searchedKeys: List<String>): Flowable<RealmResults<Equipment>> {
override fun getEquipment(searchedKeys: List<String>): Flowable<out List<Equipment>> {
return RxJavaBridge.toV3Flowable(realm.where(Equipment::class.java)
.`in`("key", searchedKeys.toTypedArray())
.findAll()
@ -55,7 +54,7 @@ class RealmInventoryLocalRepository(realm: Realm) : RealmContentLocalRepository(
.count()
}
override fun getOwnedEquipment(type: String): Flowable<RealmResults<Equipment>> {
override fun getOwnedEquipment(type: String): Flowable<out List<Equipment>> {
return RxJavaBridge.toV3Flowable(realm.where(Equipment::class.java)
.equalTo("type", type)
.equalTo("owned", true)
@ -64,7 +63,7 @@ class RealmInventoryLocalRepository(realm: Realm) : RealmContentLocalRepository(
.filter { it.isLoaded })
}
override fun getOwnedEquipment(): Flowable<RealmResults<Equipment>> {
override fun getOwnedEquipment(): Flowable<out List<Equipment>> {
return RxJavaBridge.toV3Flowable(realm.where(Equipment::class.java)
.equalTo("owned", true)
.findAll()
@ -72,7 +71,7 @@ class RealmInventoryLocalRepository(realm: Realm) : RealmContentLocalRepository(
.filter { it.isLoaded })
}
override fun getEquipmentType(type: String, set: String): Flowable<RealmResults<Equipment>> {
override fun getEquipmentType(type: String, set: String): Flowable<out List<Equipment>> {
return RxJavaBridge.toV3Flowable(realm.where(Equipment::class.java)
.equalTo("type", type)
.equalTo("gearSet", set)
@ -81,7 +80,7 @@ class RealmInventoryLocalRepository(realm: Realm) : RealmContentLocalRepository(
.filter { it.isLoaded })
}
override fun getOwnedItems(itemType: String, userID: String, includeZero: Boolean): Flowable<RealmResults<OwnedItem>> {
override fun getOwnedItems(itemType: String, userID: String, includeZero: Boolean): Flowable<out List<OwnedItem>> {
var query = realm.where(OwnedItem::class.java)
if (!includeZero) {
query = query.greaterThan("numberOwned", 0)
@ -94,12 +93,12 @@ class RealmInventoryLocalRepository(realm: Realm) : RealmContentLocalRepository(
.filter { it.isLoaded })
}
override fun getItems(itemClass: Class<out Item>, keys: Array<String>): Flowable<out RealmResults<out Item>> {
override fun getItems(itemClass: Class<out Item>, keys: Array<String>): Flowable<out List<Item>> {
return RxJavaBridge.toV3Flowable(realm.where(itemClass).`in`("key", keys).findAll().asFlowable()
.filter { it.isLoaded })
}
override fun getItems(itemClass: Class<out Item>): Flowable<out RealmResults<out Item>> {
override fun getItems(itemClass: Class<out Item>): Flowable<out List<Item>> {
return RxJavaBridge.toV3Flowable(realm.where(itemClass).findAll().asFlowable()
.filter { it.isLoaded })
}
@ -130,7 +129,7 @@ class RealmInventoryLocalRepository(realm: Realm) : RealmContentLocalRepository(
.cast(Equipment::class.java))
}
override fun getMounts(): Flowable<RealmResults<Mount>> {
override fun getMounts(): Flowable<out List<Mount>> {
return RxJavaBridge.toV3Flowable(realm.where(Mount::class.java)
.sort("type", Sort.ASCENDING, "animal", Sort.ASCENDING)
.findAll()
@ -138,7 +137,7 @@ class RealmInventoryLocalRepository(realm: Realm) : RealmContentLocalRepository(
.filter { it.isLoaded })
}
override fun getMounts(type: String?, group: String?, color: String?): Flowable<RealmResults<Mount>> {
override fun getMounts(type: String?, group: String?, color: String?): Flowable<out List<Mount>> {
var query = realm.where(Mount::class.java)
.sort("type", Sort.ASCENDING, if (color == null) "color" else "animal", Sort.ASCENDING)
if (type != null) {
@ -155,7 +154,7 @@ class RealmInventoryLocalRepository(realm: Realm) : RealmContentLocalRepository(
.filter { it.isLoaded })
}
override fun getOwnedMounts(userID: String): Flowable<RealmResults<OwnedMount>> {
override fun getOwnedMounts(userID: String): Flowable<out List<OwnedMount>> {
return RxJavaBridge.toV3Flowable(realm.where(OwnedMount::class.java)
.equalTo("owned", true)
.equalTo("userID", userID)
@ -164,7 +163,7 @@ class RealmInventoryLocalRepository(realm: Realm) : RealmContentLocalRepository(
.filter { it.isLoaded })
}
override fun getPets(): Flowable<RealmResults<Pet>> {
override fun getPets(): Flowable<out List<Pet>> {
return RxJavaBridge.toV3Flowable(realm.where(Pet::class.java)
.sort("type", Sort.ASCENDING, "animal", Sort.ASCENDING)
.findAll()
@ -172,7 +171,7 @@ class RealmInventoryLocalRepository(realm: Realm) : RealmContentLocalRepository(
.filter { it.isLoaded })
}
override fun getPets(type: String?, group: String?, color: String?): Flowable<RealmResults<Pet>> {
override fun getPets(type: String?, group: String?, color: String?): Flowable<out List<Pet>> {
var query = realm.where(Pet::class.java)
.sort("type", Sort.ASCENDING, if (color == null) "color" else "animal", Sort.ASCENDING)
if (type != null) {
@ -189,7 +188,7 @@ class RealmInventoryLocalRepository(realm: Realm) : RealmContentLocalRepository(
.filter { it.isLoaded })
}
override fun getOwnedPets(userID: String): Flowable<RealmResults<OwnedPet>> {
override fun getOwnedPets(userID: String): Flowable<out List<OwnedPet>> {
return RxJavaBridge.toV3Flowable(realm.where(OwnedPet::class.java)
.greaterThan("trained", 0)
.equalTo("userID", userID)
@ -256,7 +255,7 @@ class RealmInventoryLocalRepository(realm: Realm) : RealmContentLocalRepository(
}
}
override fun getInAppRewards(): Flowable<RealmResults<ShopItem>> {
override fun getInAppRewards(): Flowable<out List<ShopItem>> {
return RxJavaBridge.toV3Flowable(realm.where(ShopItem::class.java)
.findAll()
.asFlowable()

View file

@ -9,7 +9,6 @@ import com.habitrpg.android.habitica.models.user.User
import hu.akarnokd.rxjava3.bridge.RxJavaBridge
import io.reactivex.rxjava3.core.Flowable
import io.realm.Realm
import io.realm.RealmResults
import io.realm.Sort
import java.util.*
@ -30,7 +29,7 @@ class RealmSocialLocalRepository(realm: Realm) : RealmBaseLocalRepository(realm)
.filter { it.isLoaded && it.isNotEmpty() }
.map { it.first() })
override fun getGroupMemberships(userId: String): Flowable<RealmResults<GroupMembership>> = RxJavaBridge.toV3Flowable(realm.where(GroupMembership::class.java)
override fun getGroupMemberships(userId: String): Flowable<out List<GroupMembership>> = RxJavaBridge.toV3Flowable(realm.where(GroupMembership::class.java)
.equalTo("userID", userId)
.findAll()
.asFlowable()
@ -109,7 +108,7 @@ class RealmSocialLocalRepository(realm: Realm) : RealmBaseLocalRepository(realm)
}
}
override fun getPublicGuilds(): Flowable<RealmResults<Group>> = RxJavaBridge.toV3Flowable(realm.where(Group::class.java)
override fun getPublicGuilds(): Flowable<out List<Group>> = RxJavaBridge.toV3Flowable(realm.where(Group::class.java)
.equalTo("type", "guild")
.equalTo("privacy", "public")
.notEqualTo("id", Group.TAVERN_ID)
@ -118,7 +117,7 @@ class RealmSocialLocalRepository(realm: Realm) : RealmBaseLocalRepository(realm)
.asFlowable()
.filter { it.isLoaded })
override fun getUserGroups(userID: String, type: String?): Flowable<RealmResults<Group>> = RxJavaBridge.toV3Flowable(realm.where(GroupMembership::class.java)
override fun getUserGroups(userID: String, type: String?): Flowable<out List<Group>> = RxJavaBridge.toV3Flowable(realm.where(GroupMembership::class.java)
.equalTo("userID", userID)
.findAll()
.asFlowable()
@ -138,7 +137,7 @@ class RealmSocialLocalRepository(realm: Realm) : RealmBaseLocalRepository(realm)
override fun getGroups(type: String): Flowable<RealmResults<Group>> {
override fun getGroups(type: String): Flowable<out List<Group>> {
return RxJavaBridge.toV3Flowable(realm.where(Group::class.java)
.equalTo("type", type)
.findAll()
@ -155,7 +154,7 @@ class RealmSocialLocalRepository(realm: Realm) : RealmBaseLocalRepository(realm)
.map { groups -> groups.first() })
}
override fun getGroupChat(groupId: String): Flowable<RealmResults<ChatMessage>> {
override fun getGroupChat(groupId: String): Flowable<out List<ChatMessage>> {
return RxJavaBridge.toV3Flowable(realm.where(ChatMessage::class.java)
.equalTo("groupId", groupId)
.sort("timestamp", Sort.DESCENDING)
@ -169,7 +168,7 @@ class RealmSocialLocalRepository(realm: Realm) : RealmBaseLocalRepository(realm)
executeTransaction { chatMessage?.deleteFromRealm() }
}
override fun getGroupMembers(partyId: String): Flowable<RealmResults<Member>> {
override fun getGroupMembers(partyId: String): Flowable<out List<Member>> {
return RxJavaBridge.toV3Flowable(realm.where(Member::class.java)
.equalTo("party.id", partyId)
.findAll()
@ -276,7 +275,7 @@ class RealmSocialLocalRepository(realm: Realm) : RealmBaseLocalRepository(realm)
return party != null && party.isValid
}
override fun getInboxMessages(userId: String, replyToUserID: String?): Flowable<RealmResults<ChatMessage>> {
override fun getInboxMessages(userId: String, replyToUserID: String?): Flowable<out List<ChatMessage>> {
return RxJavaBridge.toV3Flowable(realm.where(ChatMessage::class.java)
.equalTo("isInboxMessage", true)
.equalTo("uuid", replyToUserID)
@ -287,7 +286,7 @@ class RealmSocialLocalRepository(realm: Realm) : RealmBaseLocalRepository(realm)
.filter { it.isLoaded })
}
override fun getInboxConversation(userId: String): Flowable<RealmResults<InboxConversation>> {
override fun getInboxConversation(userId: String): Flowable<out List<InboxConversation>> {
return RxJavaBridge.toV3Flowable(realm.where(InboxConversation::class.java)
.equalTo("userID", userId)
.sort("timestamp", Sort.DESCENDING)

View file

@ -5,7 +5,6 @@ import com.habitrpg.android.habitica.models.Tag
import hu.akarnokd.rxjava3.bridge.RxJavaBridge
import io.reactivex.rxjava3.core.Flowable
import io.realm.Realm
import io.realm.RealmResults
class RealmTagLocalRepository(realm: Realm) : RealmBaseLocalRepository(realm), TagLocalRepository {
@ -14,7 +13,7 @@ class RealmTagLocalRepository(realm: Realm) : RealmBaseLocalRepository(realm), T
executeTransaction { tag?.deleteFromRealm() }
}
override fun getTags(userId: String): Flowable<RealmResults<Tag>> {
override fun getTags(userId: String): Flowable<out List<Tag>> {
return RxJavaBridge.toV3Flowable(realm.where(Tag::class.java).equalTo("userId", userId).findAll().asFlowable())
}

View file

@ -8,12 +8,11 @@ import io.reactivex.rxjava3.core.Flowable
import io.reactivex.rxjava3.core.Maybe
import io.realm.Realm
import io.realm.RealmObject
import io.realm.RealmResults
import io.realm.Sort
class RealmTaskLocalRepository(realm: Realm) : RealmBaseLocalRepository(realm), TaskLocalRepository {
override fun getTasks(taskType: String, userID: String): Flowable<RealmResults<Task>> {
override fun getTasks(taskType: String, userID: String): Flowable<out List<Task>> {
if (realm.isClosed) {
return Flowable.empty()
}
@ -26,7 +25,7 @@ class RealmTaskLocalRepository(realm: Realm) : RealmBaseLocalRepository(realm),
.filter { it.isLoaded }).retry(1)
}
override fun getTasks(userId: String): Flowable<RealmResults<Task>> {
override fun getTasks(userId: String): Flowable<out List<Task>> {
if (realm.isClosed) {
return Flowable.empty()
}
@ -219,7 +218,7 @@ class RealmTaskLocalRepository(realm: Realm) : RealmBaseLocalRepository(realm),
}
}
override fun getErroredTasks(userID: String): Flowable<RealmResults<Task>> {
override fun getErroredTasks(userID: String): Flowable<out List<Task>> {
return RxJavaBridge.toV3Flowable(realm.where(Task::class.java)
.equalTo("userId", userID)
.equalTo("hasErrored", true)
@ -238,7 +237,7 @@ class RealmTaskLocalRepository(realm: Realm) : RealmBaseLocalRepository(realm),
.map { users -> users.first() })
}
override fun getTasksForChallenge(challengeID: String?, userID: String?): Flowable<RealmResults<Task>> {
override fun getTasksForChallenge(challengeID: String?, userID: String?): Flowable<out List<Task>> {
return RxJavaBridge.toV3Flowable(realm.where(Task::class.java)
.equalTo("challengeID", challengeID)
.equalTo("userId", userID)

View file

@ -5,7 +5,6 @@ import com.habitrpg.android.habitica.models.TutorialStep
import hu.akarnokd.rxjava3.bridge.RxJavaBridge
import io.reactivex.rxjava3.core.Flowable
import io.realm.Realm
import io.realm.RealmResults
class RealmTutorialLocalRepository(realm: Realm) : RealmBaseLocalRepository(realm), TutorialLocalRepository {
@ -31,7 +30,7 @@ class RealmTutorialLocalRepository(realm: Realm) : RealmBaseLocalRepository(real
.cast(TutorialStep::class.java))
}
override fun getTutorialSteps(keys: List<String>): Flowable<RealmResults<TutorialStep>> {
override fun getTutorialSteps(keys: List<String>): Flowable<out List<TutorialStep>> {
if (realm.isClosed) return Flowable.empty()
return RxJavaBridge.toV3Flowable(realm.where(TutorialStep::class.java)
.`in`("identifier", keys.toTypedArray())

View file

@ -12,7 +12,6 @@ import com.habitrpg.android.habitica.models.user.User
import hu.akarnokd.rxjava3.bridge.RxJavaBridge
import io.reactivex.rxjava3.core.Flowable
import io.realm.Realm
import io.realm.RealmResults
class RealmUserLocalRepository(realm: Realm) : RealmBaseLocalRepository(realm), UserLocalRepository {
override fun getUserQuestStatus(userID: String): Flowable<UserQuestStatus> {
@ -35,7 +34,7 @@ class RealmUserLocalRepository(realm: Realm) : RealmBaseLocalRepository(realm),
}}
}
override fun getAchievements(): Flowable<RealmResults<Achievement>> {
override fun getAchievements(): Flowable<out List<Achievement>> {
return RxJavaBridge.toV3Flowable(realm.where(Achievement::class.java)
.sort("index")
.findAll()
@ -43,7 +42,7 @@ class RealmUserLocalRepository(realm: Realm) : RealmBaseLocalRepository(realm),
.filter { it.isLoaded })
}
override fun getQuestAchievements(userID: String): Flowable<RealmResults<QuestAchievement>> {
override fun getQuestAchievements(userID: String): Flowable<out List<QuestAchievement>> {
return RxJavaBridge.toV3Flowable(realm.where(QuestAchievement::class.java)
.equalTo("userID", userID)
.findAll()
@ -51,8 +50,8 @@ class RealmUserLocalRepository(realm: Realm) : RealmBaseLocalRepository(realm),
.filter { it.isLoaded })
}
override fun getTutorialSteps(): Flowable<RealmResults<TutorialStep>> = RxJavaBridge.toV3Flowable(realm.where(TutorialStep::class.java).findAll().asFlowable()
.filter { it.isLoaded })
override fun getTutorialSteps(): Flowable<List<TutorialStep>> = RxJavaBridge.toV3Flowable(realm.where(TutorialStep::class.java).findAll().asFlowable()
.filter { it.isLoaded }.map { it })
override fun getUser(userID: String): Flowable<User> {
if (realm.isClosed) return Flowable.empty()
@ -135,7 +134,7 @@ class RealmUserLocalRepository(realm: Realm) : RealmBaseLocalRepository(realm),
}
}
override fun getTeamPlans(userID: String): Flowable<RealmResults<TeamPlan>> {
override fun getTeamPlans(userID: String): Flowable<out List<TeamPlan>> {
return RxJavaBridge.toV3Flowable(realm.where(TeamPlan::class.java)
.equalTo("userID", userID)
.findAll()
@ -153,7 +152,7 @@ class RealmUserLocalRepository(realm: Realm) : RealmBaseLocalRepository(realm),
.map { teams -> teams.first() })
}
override fun getSkills(user: User): Flowable<RealmResults<Skill>> {
override fun getSkills(user: User): Flowable<out List<Skill>> {
val habitClass = if (user.preferences?.disableClasses == true) "none" else user.stats?.habitClass
return RxJavaBridge.toV3Flowable(realm.where(Skill::class.java)
.equalTo("habitClass", habitClass)
@ -163,7 +162,7 @@ class RealmUserLocalRepository(realm: Realm) : RealmBaseLocalRepository(realm),
.filter { it.isLoaded })
}
override fun getSpecialItems(user: User): Flowable<RealmResults<Skill>> {
override fun getSpecialItems(user: User): Flowable<out List<Skill>> {
val specialItems = user.items?.special
val ownedItems = ArrayList<String>()
if (specialItems != null) {

View file

@ -3,7 +3,7 @@ package com.habitrpg.android.habitica.models
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
open class Achievement : RealmObject() {
open class Achievement : RealmObject(), BaseObject {
@PrimaryKey
var key: String? = null
var type: String? = null

View file

@ -2,8 +2,9 @@ package com.habitrpg.android.habitica.models
import io.realm.RealmModel
interface BaseObject: RealmModel
interface BaseObject: RealmModel {
interface BaseMainObject: BaseObject {
val realmClass: Class<out RealmModel>
val primaryIdentifier: String?
val primaryIdentifierName: String

View file

@ -3,7 +3,7 @@ package com.habitrpg.android.habitica.models
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
open class FAQArticle : RealmObject() {
open class FAQArticle : RealmObject(), BaseObject {
@PrimaryKey
var position: Int? = null

View file

@ -4,7 +4,7 @@ import io.realm.RealmObject
import io.realm.annotations.Ignore
import io.realm.annotations.PrimaryKey
open class QuestAchievement: RealmObject() {
open class QuestAchievement: RealmObject(), BaseObject {
@PrimaryKey
var combinedKey: String? = null

View file

@ -5,7 +5,7 @@ import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
open class Skill : RealmObject() {
open class Skill : RealmObject(), BaseObject {
@PrimaryKey
var key: String = ""

View file

@ -6,7 +6,7 @@ import io.realm.RealmList
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
open class Tag : RealmObject() {
open class Tag : RealmObject(), BaseObject {
@PrimaryKey
var id: String = ""

View file

@ -5,7 +5,7 @@ import io.realm.RealmList
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
open class TeamPlan : RealmObject() {
open class TeamPlan : RealmObject(), BaseObject {
@PrimaryKey
var id: String = ""

View file

@ -5,7 +5,7 @@ import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
import java.util.*
open class TutorialStep: RealmObject(), BaseObject {
open class TutorialStep: RealmObject(), BaseMainObject {
@PrimaryKey
var key: String? = null

View file

@ -9,7 +9,7 @@ import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
import java.util.*
open class WorldState: RealmObject() {
open class WorldState: RealmObject(), BaseObject {
@PrimaryKey
var id = "habitica"
var worldBossKey: String = ""

View file

@ -6,7 +6,7 @@ import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
import java.util.*
open class WorldStateEvent: RealmObject(), BaseObject {
open class WorldStateEvent: RealmObject(), BaseMainObject {
val isCurrentlyActive: Boolean
get() {
val now = Date()

View file

@ -1,32 +0,0 @@
package com.habitrpg.android.habitica.models.auth;
import io.realm.RealmObject;
import io.realm.annotations.PrimaryKey;
/**
* Created by admin on 18/11/15.
*/
public class LocalAuthentication extends RealmObject {
@PrimaryKey
public String userID;
String username;
String email;
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
}

View file

@ -0,0 +1,12 @@
package com.habitrpg.android.habitica.models.auth
import com.habitrpg.android.habitica.models.BaseObject
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
open class LocalAuthentication : RealmObject(), BaseObject {
@PrimaryKey
var userID: String? = null
var username: String? = null
var email: String? = null
}

View file

@ -1,10 +1,11 @@
package com.habitrpg.android.habitica.models.inventory
import com.habitrpg.android.habitica.models.BaseObject
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
import java.util.*
open class Customization : RealmObject() {
open class Customization : RealmObject(), BaseObject {
@PrimaryKey
var id: String? = null
var identifier: String? = null

View file

@ -1,11 +1,12 @@
package com.habitrpg.android.habitica.models.inventory
import com.google.gson.annotations.SerializedName
import com.habitrpg.android.habitica.models.BaseObject
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
open class Equipment : RealmObject() {
open class Equipment : RealmObject(), BaseObject {
var value: Double = 0.toDouble()
var type: String? = ""

View file

@ -1,10 +1,11 @@
package com.habitrpg.android.habitica.models.inventory
import com.habitrpg.android.habitica.models.BaseObject
import io.realm.RealmModel
import io.realm.RealmObject
import java.util.*
open class ItemEvent : RealmObject() {
open class ItemEvent : RealmObject(), BaseObject {
var start: Date? = null
var end: Date? = null
}

View file

@ -1,12 +1,13 @@
package com.habitrpg.android.habitica.models.inventory
import com.habitrpg.android.habitica.models.BaseObject
import com.habitrpg.android.habitica.models.members.Member
import io.realm.RealmList
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
open class Quest : RealmObject() {
open class Quest : RealmObject(), BaseObject {
@PrimaryKey
var id: String? = null
set(value) {

View file

@ -1,10 +1,11 @@
package com.habitrpg.android.habitica.models.inventory
import com.habitrpg.android.habitica.models.BaseObject
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
open class QuestBoss : RealmObject() {
open class QuestBoss : RealmObject(), BaseObject {
@PrimaryKey
var key: String? = null

View file

@ -1,9 +1,10 @@
package com.habitrpg.android.habitica.models.inventory
import com.habitrpg.android.habitica.models.BaseObject
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
open class QuestBossRage : RealmObject() {
open class QuestBossRage : RealmObject(), BaseObject {
@PrimaryKey
var key: String? = null

View file

@ -1,13 +0,0 @@
package com.habitrpg.android.habitica.models.inventory;
import io.realm.RealmObject;
import io.realm.annotations.PrimaryKey;
public class QuestCollect extends RealmObject {
@PrimaryKey
public String key;
public String text;
public int count;
}

View file

@ -0,0 +1,12 @@
package com.habitrpg.android.habitica.models.inventory
import com.habitrpg.android.habitica.models.BaseObject
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
open class QuestCollect : RealmObject(), BaseObject {
@PrimaryKey
var key: String? = null
var text: String? = null
var count = 0
}

View file

@ -1,6 +1,7 @@
package com.habitrpg.android.habitica.models.inventory
import android.graphics.Color
import com.habitrpg.android.habitica.models.BaseObject
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
@ -8,7 +9,7 @@ import io.realm.annotations.PrimaryKey
* Created by phillip on 31.01.18.
*/
open class QuestColors : RealmObject() {
open class QuestColors : RealmObject(), BaseObject {
@PrimaryKey
var key: String? = null

View file

@ -53,7 +53,7 @@ open class QuestContent : RealmObject(), Item {
override val type: String
get() = "quests"
fun getCollectWithKey(key: String): QuestCollect? {
fun getCollectWithKey(key: String?): QuestCollect? {
for (collect in this.collect ?: emptyList<QuestCollect>()) {
if (collect.key == key) {
return collect

View file

@ -1,9 +1,10 @@
package com.habitrpg.android.habitica.models.inventory
import com.habitrpg.android.habitica.models.BaseObject
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
open class QuestDropItem : RealmObject() {
open class QuestDropItem : RealmObject(), BaseObject {
@PrimaryKey
var combinedKey: String? = null
var questKey: String? = null

View file

@ -1,5 +1,6 @@
package com.habitrpg.android.habitica.models.inventory
import com.habitrpg.android.habitica.models.BaseObject
import io.realm.RealmList
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
@ -7,7 +8,7 @@ import io.realm.annotations.PrimaryKey
/**
* Created by phillip on 25.07.17.
*/
open class QuestDrops : RealmObject() {
open class QuestDrops : RealmObject(), BaseObject {
@PrimaryKey
var key: String? = null
set(value) {

View file

@ -1,9 +1,10 @@
package com.habitrpg.android.habitica.models.inventory
import com.habitrpg.android.habitica.models.BaseObject
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
open class QuestMember : RealmObject() {
open class QuestMember : RealmObject(), BaseObject {
@PrimaryKey
var key: String? = null
var isParticipating: Boolean? = null

View file

@ -1,10 +1,11 @@
package com.habitrpg.android.habitica.models.inventory
import com.habitrpg.android.habitica.models.BaseObject
import io.realm.RealmList
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
open class QuestProgress : RealmObject() {
open class QuestProgress : RealmObject(), BaseObject {
@PrimaryKey
var id: String? = null

View file

@ -1,13 +0,0 @@
package com.habitrpg.android.habitica.models.inventory;
import io.realm.RealmObject;
import io.realm.annotations.PrimaryKey;
public class QuestProgressCollect extends RealmObject {
@PrimaryKey
public
String key;
public int count;
}

View file

@ -0,0 +1,11 @@
package com.habitrpg.android.habitica.models.inventory
import com.habitrpg.android.habitica.models.BaseObject
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
open class QuestProgressCollect : RealmObject(), BaseObject {
@PrimaryKey
var key: String? = null
var count = 0
}

View file

@ -1,9 +1,10 @@
package com.habitrpg.android.habitica.models.inventory
import com.habitrpg.android.habitica.models.BaseObject
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
open class QuestRageStrike() : RealmObject() {
open class QuestRageStrike() : RealmObject(), BaseObject {
@PrimaryKey
var key = ""

View file

@ -5,7 +5,6 @@ import android.content.Context
import com.habitrpg.android.habitica.R
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
import java.util.*
open class SpecialItem : RealmObject(), Item {
override val type: String

View file

@ -1,9 +1,10 @@
package com.habitrpg.android.habitica.models.inventory.owned
import com.habitrpg.android.habitica.models.BaseObject
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
open class OwnedEquipment : RealmObject() {
open class OwnedEquipment : RealmObject(), BaseObject {
@PrimaryKey
var combinedKey: String? = ""

View file

@ -1,12 +1,13 @@
package com.habitrpg.android.habitica.models.invitations
import com.habitrpg.android.habitica.models.BaseObject
import com.habitrpg.android.habitica.models.user.User
import io.realm.RealmList
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
open class Invitations : RealmObject() {
open class Invitations : RealmObject(), BaseObject {
@PrimaryKey
var userId: String? = null

View file

@ -2,13 +2,14 @@ package com.habitrpg.android.habitica.models.members
import com.google.gson.annotations.SerializedName
import com.habitrpg.android.habitica.models.Avatar
import com.habitrpg.android.habitica.models.BaseObject
import com.habitrpg.android.habitica.models.social.UserParty
import com.habitrpg.android.habitica.models.user.*
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
open class Member : RealmObject(), Avatar {
open class Member : RealmObject(), Avatar, BaseObject {
@PrimaryKey
@SerializedName("_id")

View file

@ -5,13 +5,14 @@ import android.content.res.Resources
import com.google.gson.annotations.SerializedName
import com.habitrpg.android.habitica.R
import com.habitrpg.android.habitica.models.BaseObject
import com.habitrpg.android.habitica.models.inventory.ItemEvent
import com.habitrpg.android.habitica.models.user.User
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
open class ShopItem : RealmObject() {
open class ShopItem : RealmObject(), BaseObject {
@PrimaryKey
var key: String = ""
set(value) {

View file

@ -2,11 +2,12 @@ package com.habitrpg.android.habitica.models.shops
import android.content.Context
import com.habitrpg.android.habitica.R
import com.habitrpg.android.habitica.models.BaseObject
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
open class ShopItemUnlockCondition : RealmObject() {
open class ShopItemUnlockCondition : RealmObject(), BaseObject {
@PrimaryKey
var questKey: String? = null

View file

@ -1,5 +1,6 @@
package com.habitrpg.android.habitica.models.social
import com.habitrpg.android.habitica.models.BaseObject
import com.habitrpg.android.habitica.models.tasks.TasksOrder
import com.habitrpg.android.habitica.models.user.User
import io.realm.RealmObject
@ -7,7 +8,7 @@ import io.realm.annotations.Ignore
import io.realm.annotations.PrimaryKey
import java.util.*
open class Challenge : RealmObject() {
open class Challenge : RealmObject(), BaseObject {
@PrimaryKey
var id: String? = null

View file

@ -1,9 +1,10 @@
package com.habitrpg.android.habitica.models.social
import com.habitrpg.android.habitica.models.BaseObject
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
open class ChallengeMembership : RealmObject {
open class ChallengeMembership : RealmObject, BaseObject {
@PrimaryKey
var combinedID: String = ""

View file

@ -1,17 +1,15 @@
package com.habitrpg.android.habitica.models.social
import android.renderscript.BaseObj
import android.text.Spanned
import com.habitrpg.android.habitica.models.BaseObject
import com.habitrpg.android.habitica.models.BaseMainObject
import com.habitrpg.android.habitica.models.user.Backer
import com.habitrpg.android.habitica.models.user.ContributorInfo
import com.habitrpg.android.habitica.models.user.User
import io.realm.RealmList
import io.realm.RealmObject
import io.realm.annotations.Ignore
import io.realm.annotations.PrimaryKey
open class ChatMessage : RealmObject(), BaseObject {
open class ChatMessage : RealmObject(), BaseMainObject {
override val realmClass: Class<ChatMessage>
get() = ChatMessage::class.java

View file

@ -1,5 +1,6 @@
package com.habitrpg.android.habitica.models.social
import com.habitrpg.android.habitica.models.BaseObject
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
@ -7,7 +8,7 @@ import io.realm.annotations.PrimaryKey
* Created by phillip on 30.06.17.
*/
open class ChatMessageLike : RealmObject {
open class ChatMessageLike : RealmObject, BaseObject {
@PrimaryKey
var key: String = ""

View file

@ -1,7 +1,7 @@
package com.habitrpg.android.habitica.models.social
import com.google.gson.annotations.SerializedName
import com.habitrpg.android.habitica.models.BaseObject
import com.habitrpg.android.habitica.models.BaseMainObject
import com.habitrpg.android.habitica.models.inventory.Quest
import com.habitrpg.android.habitica.models.tasks.TaskList
import com.habitrpg.android.habitica.models.tasks.TasksOrder
@ -12,7 +12,7 @@ import io.realm.RealmObject
import io.realm.annotations.Ignore
import io.realm.annotations.PrimaryKey
open class Group : RealmObject(), BaseObject {
open class Group : RealmObject(), BaseMainObject {
override val realmClass: Class<Group>
get() = Group::class.java

View file

@ -1,12 +1,12 @@
package com.habitrpg.android.habitica.models.social
import com.google.gson.annotations.SerializedName
import com.habitrpg.android.habitica.models.BaseObject
import com.habitrpg.android.habitica.models.BaseMainObject
import io.realm.RealmModel
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
open class GroupCategory : RealmObject(), BaseObject {
open class GroupCategory : RealmObject(), BaseMainObject {
override val realmClass: Class<out RealmModel>
get() = Group::class.java
override val primaryIdentifier: String?

View file

@ -1,9 +1,10 @@
package com.habitrpg.android.habitica.models.social
import com.habitrpg.android.habitica.models.BaseObject
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
open class GroupMembership : RealmObject {
open class GroupMembership : RealmObject, BaseObject {
@PrimaryKey
var combinedID: String = ""

View file

@ -1,11 +1,12 @@
package com.habitrpg.android.habitica.models.social
import com.habitrpg.android.habitica.models.BaseObject
import com.habitrpg.android.habitica.models.user.ContributorInfo
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
import java.util.*
open class InboxConversation : RealmObject() {
open class InboxConversation : RealmObject(), BaseObject {
@PrimaryKey
var combinedID: String = ""

View file

@ -1,12 +1,13 @@
package com.habitrpg.android.habitica.models.social
import com.google.gson.annotations.SerializedName
import com.habitrpg.android.habitica.models.BaseObject
import com.habitrpg.android.habitica.models.inventory.Quest
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
open class UserParty : RealmObject() {
open class UserParty : RealmObject(), BaseObject {
@PrimaryKey
var userId: String? = null
@SerializedName("_id")

View file

@ -2,13 +2,14 @@ package com.habitrpg.android.habitica.models.tasks
import android.os.Parcel
import android.os.Parcelable
import com.habitrpg.android.habitica.models.BaseMainObject
import com.habitrpg.android.habitica.models.BaseObject
import io.realm.RealmModel
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
import java.util.*
open class ChecklistItem : RealmObject, BaseObject, Parcelable {
open class ChecklistItem : RealmObject, BaseMainObject, Parcelable {
override val realmClass: Class<ChecklistItem>
get() = ChecklistItem::class.java

View file

@ -6,6 +6,7 @@ import android.text.Spanned
import androidx.annotation.StringDef
import com.google.gson.annotations.SerializedName
import com.habitrpg.android.habitica.R
import com.habitrpg.android.habitica.models.BaseMainObject
import com.habitrpg.android.habitica.models.BaseObject
import com.habitrpg.android.habitica.models.Tag
import com.habitrpg.android.habitica.models.user.Stats
@ -18,7 +19,7 @@ import org.json.JSONArray
import org.json.JSONException
import java.util.*
open class Task : RealmObject, BaseObject, Parcelable {
open class Task : RealmObject, BaseMainObject, Parcelable {
override val realmClass: Class<Task>
get() = Task::class.java

View file

@ -2,12 +2,13 @@ package com.habitrpg.android.habitica.models.tasks
import com.google.gson.annotations.SerializedName
import com.habitrpg.android.habitica.models.BaseObject
import io.realm.RealmList
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
import java.util.*
open class TaskGroupPlan : RealmObject() {
open class TaskGroupPlan : RealmObject(), BaseObject {
@PrimaryKey
internal var taskID: String? = null

View file

@ -1,10 +1,11 @@
package com.habitrpg.android.habitica.models.tasks
import com.habitrpg.android.habitica.models.BaseObject
import com.habitrpg.android.habitica.models.Tag
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
open class TaskTag : RealmObject() {
open class TaskTag : RealmObject(), BaseObject {
var tag: Tag? = null
set(value) {
field = value

View file

@ -1,9 +1,10 @@
package com.habitrpg.android.habitica.models.user
import com.habitrpg.android.habitica.models.BaseObject
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
open class ABTest: RealmObject() {
open class ABTest: RealmObject(), BaseObject {
@PrimaryKey
var userID: String? = null

View file

@ -1,12 +1,13 @@
package com.habitrpg.android.habitica.models.user
import com.google.gson.annotations.SerializedName
import com.habitrpg.android.habitica.models.BaseObject
import com.habitrpg.android.habitica.models.auth.LocalAuthentication
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
open class Authentication : RealmObject() {
open class Authentication : RealmObject(), BaseObject {
@PrimaryKey
var userId: String? = null

View file

@ -1,11 +1,12 @@
package com.habitrpg.android.habitica.models.user
import com.google.gson.annotations.SerializedName
import com.habitrpg.android.habitica.models.BaseObject
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
import java.util.*
open class AuthenticationTimestamps : RealmObject() {
open class AuthenticationTimestamps : RealmObject(), BaseObject {
@PrimaryKey
var userId: String? = null

View file

@ -1,8 +1,9 @@
package com.habitrpg.android.habitica.models.user
import com.habitrpg.android.habitica.models.BaseObject
import io.realm.RealmObject
open class Backer : RealmObject() {
open class Backer : RealmObject(), BaseObject {
var id: String? = null
var npc: String? = null
var tier: Int? = null

View file

@ -1,10 +1,11 @@
package com.habitrpg.android.habitica.models.user
import com.google.gson.annotations.SerializedName
import com.habitrpg.android.habitica.models.BaseObject
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
open class Buffs : RealmObject() {
open class Buffs : RealmObject(), BaseObject {
@PrimaryKey
var userId: String? = null
var con: Float? = null

View file

@ -4,9 +4,10 @@ import io.realm.RealmObject
import android.util.SparseIntArray
import com.habitrpg.android.habitica.models.user.ContributorInfo
import com.habitrpg.android.habitica.R
import com.habitrpg.android.habitica.models.BaseObject
import io.realm.annotations.PrimaryKey
open class ContributorInfo : RealmObject() {
open class ContributorInfo : RealmObject(), BaseObject {
companion object {
val CONTRIBUTOR_COLOR_DICT: SparseIntArray = SparseIntArray()

View file

@ -1,8 +1,9 @@
package com.habitrpg.android.habitica.models.user
import com.habitrpg.android.habitica.models.BaseObject
import io.realm.RealmObject
open class EmailNotificationsPreference : RealmObject() {
open class EmailNotificationsPreference : RealmObject(), BaseObject {
var unsubscribeFromAll: Boolean = false
var invitedParty: Boolean = false
var invitedQuest: Boolean = false

View file

@ -1,11 +1,12 @@
package com.habitrpg.android.habitica.models.user
import com.habitrpg.android.habitica.models.BaseObject
import com.habitrpg.android.habitica.models.TutorialStep
import io.realm.RealmList
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
open class Flags : RealmObject() {
open class Flags : RealmObject(), BaseObject {
@PrimaryKey
var userId: String? = null
var tutorial: RealmList<TutorialStep>? = null

View file

@ -1,48 +0,0 @@
package com.habitrpg.android.habitica.models.user;
import com.habitrpg.android.habitica.models.inventory.Equipment;
import io.realm.RealmList;
import io.realm.RealmObject;
import io.realm.annotations.PrimaryKey;
public class Gear extends RealmObject {
@PrimaryKey
private String userId;
public RealmList<Equipment> owned;
Items items;
private Outfit equipped;
private Outfit costume;
public Outfit getCostume() {
return costume;
}
public void setCostume(Outfit costume) {
this.costume = costume;
}
public Outfit getEquipped() {
return equipped;
}
public void setEquipped(Outfit equipped) {
this.equipped = equipped;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
if (costume != null && !costume.isManaged()) {
costume.setUserId(userId);
}
if (equipped != null && !equipped.isManaged()) {
equipped.setUserId(userId+"equipped");
}
}
}

View file

@ -0,0 +1,25 @@
package com.habitrpg.android.habitica.models.user
import com.habitrpg.android.habitica.models.BaseObject
import com.habitrpg.android.habitica.models.inventory.Equipment
import io.realm.RealmList
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
open class Gear : RealmObject(), BaseObject {
@PrimaryKey
var userId: String? = null
set(value) {
field = value
if (costume != null && costume?.isManaged == false) {
costume?.userId = userId
}
if (equipped != null && equipped?.isManaged == false) {
equipped?.userId = userId + "equipped"
}
}
var owned: RealmList<Equipment>? = null
var items: Items? = null
var equipped: Outfit? = null
var costume: Outfit? = null
}

View file

@ -1,9 +1,10 @@
package com.habitrpg.android.habitica.models.user
import com.habitrpg.android.habitica.models.BaseObject
import io.realm.RealmObject
import io.realm.annotations.PrimaryKey
open class Hair : RealmObject {
open class Hair : RealmObject, BaseObject {
@PrimaryKey
var userId: String? = null

Some files were not shown because too many files have changed in this diff Show more