mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-21 21:29:00 +00:00
Fix realm issue
This commit is contained in:
parent
0bc8e3a85a
commit
5992065a53
89 changed files with 141 additions and 812 deletions
|
|
@ -210,7 +210,6 @@ class InventoryRepositoryImpl(localRepository: InventoryLocalRepository, apiClie
|
|||
}
|
||||
return apiClient.hatchPet(egg.key, hatchingPotion.key)
|
||||
.doOnNext {
|
||||
it.userId = userID
|
||||
localRepository.save(it)
|
||||
if (!appConfigManager.enableLocalChanges()) {
|
||||
successFunction()
|
||||
|
|
@ -231,7 +230,6 @@ class InventoryRepositoryImpl(localRepository: InventoryLocalRepository, apiClie
|
|||
}
|
||||
val copiedUser = localRepository.getUnmanagedCopy(user)
|
||||
if (buyResponse.items != null) {
|
||||
buyResponse.items.userId = user.id
|
||||
copiedUser.items = buyResponse.items
|
||||
}
|
||||
if (buyResponse.hp != null) {
|
||||
|
|
|
|||
|
|
@ -63,8 +63,8 @@ class RealmChallengeLocalRepository(realm: Realm) : RealmBaseLocalRepository(rea
|
|||
.findAll()
|
||||
.asFlowable()
|
||||
.filter { it.isLoaded })
|
||||
.flatMap {
|
||||
val ids = it.map {
|
||||
.flatMap { it ->
|
||||
val ids = it.map {
|
||||
return@map it.challengeID
|
||||
}.toTypedArray()
|
||||
realm.where(Challenge::class.java)
|
||||
|
|
|
|||
|
|
@ -366,13 +366,11 @@ class RealmInventoryLocalRepository(realm: Realm) : RealmContentLocalRepository(
|
|||
executeTransaction {
|
||||
val items = updatedUser.items
|
||||
if (items != null) {
|
||||
items.userId = user.id
|
||||
val newItems = realm.copyToRealmOrUpdate(items)
|
||||
user.items = newItems
|
||||
}
|
||||
val stats = updatedUser.stats
|
||||
if (stats != null) {
|
||||
stats.userId = user.id
|
||||
val newStats = realm.copyToRealmOrUpdate(stats)
|
||||
user.stats = newStats
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ class RealmSocialLocalRepository(realm: Realm) : RealmBaseLocalRepository(realm)
|
|||
val existingMemberships = realm.where(GroupMembership::class.java).equalTo("userID", userID).findAll()
|
||||
val membersToRemove = ArrayList<GroupMembership>()
|
||||
for (existingMembership in existingMemberships) {
|
||||
val isStillMember = memberships.any { existingMembership.combinedID == it.combinedID }
|
||||
val isStillMember = memberships.any { existingMembership.groupID == it.groupID }
|
||||
if (!isStillMember) {
|
||||
membersToRemove.add(existingMembership)
|
||||
}
|
||||
|
|
@ -187,7 +187,7 @@ class RealmSocialLocalRepository(realm: Realm) : RealmBaseLocalRepository(realm)
|
|||
val liveMessage = getLiveObject(chatMessage)
|
||||
if (liked) {
|
||||
executeTransaction {
|
||||
liveMessage?.likes?.add(ChatMessageLike(userId, chatMessage.id))
|
||||
liveMessage?.likes?.add(ChatMessageLike(userId))
|
||||
}
|
||||
} else {
|
||||
liveMessage?.likes?.filter { userId == it.id }?.forEach { like ->
|
||||
|
|
|
|||
|
|
@ -1,12 +0,0 @@
|
|||
package com.habitrpg.android.habitica.events;
|
||||
|
||||
/**
|
||||
* Created by Negue on 29.11.2015.
|
||||
*/
|
||||
public class BoughtGemsEvent {
|
||||
public int NewGemsToAdd;
|
||||
|
||||
public BoughtGemsEvent(int newGemsToAdd) {
|
||||
NewGemsToAdd = newGemsToAdd;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
package com.habitrpg.android.habitica.events
|
||||
|
||||
/**
|
||||
* Created by Negue on 29.11.2015.
|
||||
*/
|
||||
class BoughtGemsEvent(var NewGemsToAdd: Int)
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
package com.habitrpg.android.habitica.events;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
|
||||
public class ShareEvent {
|
||||
public String identifier;
|
||||
public String sharedMessage;
|
||||
public Bitmap shareImage;
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package com.habitrpg.android.habitica.events
|
||||
|
||||
import android.graphics.Bitmap
|
||||
|
||||
class ShareEvent {
|
||||
var identifier: String? = null
|
||||
var sharedMessage: String? = null
|
||||
var shareImage: Bitmap? = null
|
||||
}
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
package com.habitrpg.android.habitica.events;
|
||||
|
||||
public class UserSubscribedEvent {
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
package com.habitrpg.android.habitica.events
|
||||
|
||||
class UserSubscribedEvent
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
package com.habitrpg.android.habitica.events.commands;
|
||||
|
||||
import com.habitrpg.android.habitica.models.inventory.Food;
|
||||
import com.habitrpg.android.habitica.models.inventory.Pet;
|
||||
|
||||
public class FeedCommand {
|
||||
|
||||
public Pet usingPet;
|
||||
public Food usingFood;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
package com.habitrpg.android.habitica.events.commands
|
||||
|
||||
import com.habitrpg.android.habitica.models.inventory.Food
|
||||
import com.habitrpg.android.habitica.models.inventory.Pet
|
||||
|
||||
class FeedCommand(val usingPet: Pet?, val usingFood: Food?) {
|
||||
}
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
package com.habitrpg.android.habitica.executors;
|
||||
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
public class JobExecutor implements ThreadExecutor {
|
||||
|
||||
private static final int INITIAL_POOL_SIZE = 3;
|
||||
private static final int MAX_POOL_SIZE = 5;
|
||||
|
||||
// Sets the amount of time an idle thread waits before terminating
|
||||
private static final int KEEP_ALIVE_TIME = 10;
|
||||
|
||||
// Sets the Time Unit to seconds
|
||||
private static final TimeUnit KEEP_ALIVE_TIME_UNIT = TimeUnit.SECONDS;
|
||||
|
||||
private final ThreadPoolExecutor threadPoolExecutor;
|
||||
|
||||
@Inject
|
||||
public JobExecutor() {
|
||||
BlockingQueue<Runnable> workQueue = new LinkedBlockingQueue<>();
|
||||
ThreadFactory threadFactory = new JobThreadFactory();
|
||||
this.threadPoolExecutor = new ThreadPoolExecutor(INITIAL_POOL_SIZE, MAX_POOL_SIZE,
|
||||
KEEP_ALIVE_TIME, KEEP_ALIVE_TIME_UNIT, workQueue, threadFactory);
|
||||
}
|
||||
|
||||
@Override public void execute(Runnable runnable) {
|
||||
if (runnable == null) {
|
||||
throw new IllegalArgumentException("Runnable to execute cannot be null");
|
||||
}
|
||||
this.threadPoolExecutor.execute(runnable);
|
||||
}
|
||||
|
||||
private static class JobThreadFactory implements ThreadFactory {
|
||||
private static final String THREAD_NAME = "android_";
|
||||
private int counter = 0;
|
||||
|
||||
@Override public Thread newThread(Runnable runnable) {
|
||||
return new Thread(runnable, THREAD_NAME + counter++);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
package com.habitrpg.android.habitica.executors;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
public interface ThreadExecutor extends Executor {}
|
||||
|
|
@ -2,7 +2,6 @@ package com.habitrpg.android.habitica.interactors
|
|||
|
||||
import com.habitrpg.android.habitica.data.TaskRepository
|
||||
import com.habitrpg.android.habitica.executors.PostExecutionThread
|
||||
import com.habitrpg.android.habitica.executors.ThreadExecutor
|
||||
import com.habitrpg.android.habitica.helpers.SoundManager
|
||||
import com.habitrpg.android.habitica.models.responses.TaskScoringResult
|
||||
import com.habitrpg.android.habitica.models.tasks.Task
|
||||
|
|
@ -13,8 +12,7 @@ import javax.inject.Inject
|
|||
import io.reactivex.rxjava3.core.Flowable
|
||||
|
||||
class BuyRewardUseCase @Inject
|
||||
constructor(private val taskRepository: TaskRepository, private val soundManager: SoundManager,
|
||||
threadExecutor: ThreadExecutor, postExecutionThread: PostExecutionThread) : UseCase<BuyRewardUseCase.RequestValues, TaskScoringResult>(threadExecutor, postExecutionThread) {
|
||||
constructor(private val taskRepository: TaskRepository, private val soundManager: SoundManager, postExecutionThread: PostExecutionThread) : UseCase<BuyRewardUseCase.RequestValues, TaskScoringResult>(postExecutionThread) {
|
||||
|
||||
override fun buildUseCaseObservable(requestValues: RequestValues): Flowable<TaskScoringResult?> {
|
||||
return taskRepository
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import android.content.Intent
|
|||
import android.os.Bundle
|
||||
|
||||
import com.habitrpg.android.habitica.executors.PostExecutionThread
|
||||
import com.habitrpg.android.habitica.executors.ThreadExecutor
|
||||
import com.habitrpg.android.habitica.models.user.User
|
||||
import com.habitrpg.android.habitica.ui.activities.ClassSelectionActivity
|
||||
|
||||
|
|
@ -15,8 +14,7 @@ import io.reactivex.rxjava3.core.Flowable
|
|||
|
||||
import com.habitrpg.android.habitica.ui.activities.MainActivity.Companion.SELECT_CLASS_RESULT
|
||||
|
||||
class CheckClassSelectionUseCase @Inject
|
||||
constructor(threadExecutor: ThreadExecutor, postExecutionThread: PostExecutionThread) : UseCase<CheckClassSelectionUseCase.RequestValues, Void>(threadExecutor, postExecutionThread) {
|
||||
class CheckClassSelectionUseCase @Inject constructor(postExecutionThread: PostExecutionThread) : UseCase<CheckClassSelectionUseCase.RequestValues, Void>(postExecutionThread) {
|
||||
|
||||
override fun buildUseCaseObservable(requestValues: RequestValues): Flowable<Void> {
|
||||
return Flowable.defer {
|
||||
|
|
|
|||
|
|
@ -1,22 +1,21 @@
|
|||
package com.habitrpg.android.habitica.interactors
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Handler
|
||||
import android.provider.Settings.Global.getString
|
||||
import android.view.ViewGroup
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.android.habitica.executors.PostExecutionThread
|
||||
import com.habitrpg.android.habitica.executors.ThreadExecutor
|
||||
import com.habitrpg.android.habitica.helpers.SoundManager
|
||||
import com.habitrpg.android.habitica.models.responses.TaskScoringResult
|
||||
import com.habitrpg.android.habitica.ui.views.HabiticaSnackbar
|
||||
import io.reactivex.rxjava3.core.Flowable
|
||||
import java.lang.StringBuilder
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import javax.inject.Inject
|
||||
|
||||
class DisplayItemDropUseCase @Inject
|
||||
constructor(private val soundManager: SoundManager, threadExecutor: ThreadExecutor, postExecutionThread: PostExecutionThread) : UseCase<DisplayItemDropUseCase.RequestValues, Void>(threadExecutor, postExecutionThread) {
|
||||
constructor(private val soundManager: SoundManager, postExecutionThread: PostExecutionThread) : UseCase<DisplayItemDropUseCase.RequestValues, Void>(postExecutionThread) {
|
||||
|
||||
override fun buildUseCaseObservable(requestValues: RequestValues): Flowable<Void> {
|
||||
return Flowable.defer {
|
||||
|
|
@ -30,11 +29,12 @@ constructor(private val soundManager: SoundManager, threadExecutor: ThreadExecut
|
|||
}
|
||||
|
||||
if (snackbarText.isNotEmpty()) {
|
||||
Handler().postDelayed({
|
||||
GlobalScope.launch(context = Dispatchers.Main) {
|
||||
delay(3000L)
|
||||
HabiticaSnackbar.showSnackbar(requestValues.snackbarTargetView,
|
||||
snackbarText, HabiticaSnackbar.SnackbarDisplayType.DROP, true)
|
||||
snackbarText, HabiticaSnackbar.SnackbarDisplayType.DROP, true)
|
||||
soundManager.loadAndPlayAudio(SoundManager.SoundItemDrop)
|
||||
}, 3000L)
|
||||
}
|
||||
}
|
||||
|
||||
Flowable.empty()
|
||||
|
|
|
|||
|
|
@ -1,13 +1,11 @@
|
|||
package com.habitrpg.android.habitica.interactors
|
||||
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.android.habitica.databinding.DialogLevelup10Binding
|
||||
import com.habitrpg.android.habitica.events.ShareEvent
|
||||
import com.habitrpg.android.habitica.executors.PostExecutionThread
|
||||
import com.habitrpg.android.habitica.executors.ThreadExecutor
|
||||
import com.habitrpg.android.habitica.helpers.RxErrorHandler
|
||||
import com.habitrpg.android.habitica.helpers.SoundManager
|
||||
import com.habitrpg.android.habitica.models.user.Stats
|
||||
|
|
@ -21,8 +19,8 @@ import org.greenrobot.eventbus.EventBus
|
|||
import javax.inject.Inject
|
||||
|
||||
class LevelUpUseCase @Inject
|
||||
constructor(private val soundManager: SoundManager, threadExecutor: ThreadExecutor, postExecutionThread: PostExecutionThread,
|
||||
private val checkClassSelectionUseCase: CheckClassSelectionUseCase) : UseCase<LevelUpUseCase.RequestValues, Stats>(threadExecutor, postExecutionThread) {
|
||||
constructor(private val soundManager: SoundManager, postExecutionThread: PostExecutionThread,
|
||||
private val checkClassSelectionUseCase: CheckClassSelectionUseCase) : UseCase<LevelUpUseCase.RequestValues, Stats>(postExecutionThread) {
|
||||
|
||||
override fun buildUseCaseObservable(requestValues: RequestValues): Flowable<Stats> {
|
||||
return Flowable.defer {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ import androidx.core.util.Pair
|
|||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.android.habitica.data.UserRepository
|
||||
import com.habitrpg.android.habitica.executors.PostExecutionThread
|
||||
import com.habitrpg.android.habitica.executors.ThreadExecutor
|
||||
import com.habitrpg.android.habitica.extensions.round
|
||||
import com.habitrpg.android.habitica.models.user.Stats
|
||||
import com.habitrpg.android.habitica.models.user.User
|
||||
|
|
@ -27,8 +26,8 @@ import javax.inject.Inject
|
|||
import kotlin.math.abs
|
||||
|
||||
class NotifyUserUseCase @Inject
|
||||
constructor(threadExecutor: ThreadExecutor, postExecutionThread: PostExecutionThread,
|
||||
private val levelUpUseCase: LevelUpUseCase, private val userRepository: UserRepository) : UseCase<NotifyUserUseCase.RequestValues, Stats>(threadExecutor, postExecutionThread) {
|
||||
constructor(postExecutionThread: PostExecutionThread,
|
||||
private val levelUpUseCase: LevelUpUseCase, private val userRepository: UserRepository) : UseCase<NotifyUserUseCase.RequestValues, Stats>(postExecutionThread) {
|
||||
|
||||
override fun buildUseCaseObservable(requestValues: RequestValues): Flowable<Stats> {
|
||||
return Flowable.defer {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package com.habitrpg.android.habitica.interactors;
|
||||
|
||||
import com.habitrpg.android.habitica.executors.PostExecutionThread;
|
||||
import com.habitrpg.android.habitica.executors.ThreadExecutor;
|
||||
|
||||
import io.reactivex.rxjava3.core.Flowable;
|
||||
|
||||
|
|
@ -9,8 +8,7 @@ public abstract class UseCase<Q extends UseCase.RequestValues, T> {
|
|||
|
||||
private final PostExecutionThread postExecutionThread;
|
||||
|
||||
protected UseCase(ThreadExecutor threadExecutor,
|
||||
PostExecutionThread postExecutionThread) {
|
||||
protected UseCase(PostExecutionThread postExecutionThread) {
|
||||
this.postExecutionThread = postExecutionThread;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
package com.habitrpg.android.habitica.models
|
||||
|
||||
import java.util.*
|
||||
|
||||
class AchievementGroup {
|
||||
var label: String? = null
|
||||
var achievements: HashMap<String, Achievement>? = null
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
package com.habitrpg.android.habitica.models
|
||||
|
||||
class AchievementResult {
|
||||
var basic: AchievementGroup? = null
|
||||
var seasonal: AchievementGroup? = null
|
||||
var special: AchievementGroup? = null
|
||||
}
|
||||
|
|
@ -3,7 +3,6 @@ package com.habitrpg.android.habitica.models
|
|||
import com.habitrpg.android.habitica.models.user.Hair
|
||||
|
||||
interface AvatarPreferences {
|
||||
val userId: String?
|
||||
val hair: Hair?
|
||||
val costume: Boolean
|
||||
val sleep: Boolean
|
||||
|
|
|
|||
|
|
@ -5,7 +5,5 @@ import com.habitrpg.android.habitica.models.inventory.Equipment
|
|||
import io.realm.RealmList
|
||||
|
||||
class ContentGear {
|
||||
|
||||
var flat: RealmList<Equipment>? = null
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,27 +7,18 @@ import io.realm.RealmList
|
|||
* Created by Negue on 15.07.2015.
|
||||
*/
|
||||
class ContentResult {
|
||||
|
||||
var potion: Equipment? = null
|
||||
|
||||
var armoire: Equipment? = null
|
||||
|
||||
var gear: ContentGear? = null
|
||||
|
||||
var quests = RealmList<QuestContent>()
|
||||
var eggs = RealmList<Egg>()
|
||||
var food = RealmList<Food>()
|
||||
var hatchingPotions = RealmList<HatchingPotion>()
|
||||
|
||||
var pets = RealmList<Pet>()
|
||||
|
||||
var mounts = RealmList<Mount>()
|
||||
|
||||
var spells = RealmList<Skill>()
|
||||
|
||||
var appearances = RealmList<Customization>()
|
||||
var backgrounds = RealmList<Customization>()
|
||||
|
||||
var faq = RealmList<FAQArticle>()
|
||||
var special = RealmList<SpecialItem>()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import java.util.*
|
|||
@RealmClass(embedded = true)
|
||||
open class TutorialStep: RealmObject(), BaseMainObject {
|
||||
|
||||
@PrimaryKey
|
||||
var key: String? = null
|
||||
var tutorialGroup: String? = null
|
||||
set(group) {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ open class WorldStateEvent: RealmObject(), BaseMainObject {
|
|||
return (start?.before(now) == true) && (end?.after(now) == true)
|
||||
}
|
||||
|
||||
@PrimaryKey
|
||||
@SerializedName("event")
|
||||
var eventKey: String? = null
|
||||
var start: Date? = null
|
||||
|
|
|
|||
|
|
@ -7,8 +7,6 @@ import io.realm.annotations.RealmClass
|
|||
|
||||
@RealmClass(embedded = true)
|
||||
open class LocalAuthentication : RealmObject(), BaseObject {
|
||||
@PrimaryKey
|
||||
var userID: String? = null
|
||||
var username: String? = null
|
||||
var email: String? = null
|
||||
}
|
||||
|
|
@ -9,7 +9,6 @@ import io.realm.annotations.RealmClass
|
|||
@RealmClass(embedded = true)
|
||||
open class QuestProgress : RealmObject(), BaseObject {
|
||||
|
||||
@PrimaryKey
|
||||
var id: String? = null
|
||||
var key: String? = null
|
||||
var hp: Double = 0.0
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import io.realm.annotations.RealmClass
|
|||
|
||||
@RealmClass(embedded = true)
|
||||
open class QuestProgressCollect : RealmObject(), BaseObject {
|
||||
@PrimaryKey
|
||||
var key: String? = null
|
||||
var count = 0
|
||||
}
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
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(), BaseObject {
|
||||
|
||||
@PrimaryKey
|
||||
var combinedKey: String? = ""
|
||||
var userID: String? = ""
|
||||
var key: String? = ""
|
||||
}
|
||||
|
|
@ -2,10 +2,11 @@ package com.habitrpg.android.habitica.models.invitations
|
|||
|
||||
import io.realm.RealmObject
|
||||
import io.realm.annotations.PrimaryKey
|
||||
import io.realm.annotations.RealmClass
|
||||
|
||||
@RealmClass(embedded = true)
|
||||
open class GuildInvite : RealmObject(), GenericInvitation {
|
||||
|
||||
@PrimaryKey
|
||||
override var id: String? = null
|
||||
override var inviter: String? = null
|
||||
override var name: String? = null
|
||||
|
|
|
|||
|
|
@ -6,14 +6,10 @@ import com.habitrpg.android.habitica.models.user.User
|
|||
import io.realm.RealmList
|
||||
import io.realm.RealmObject
|
||||
import io.realm.annotations.PrimaryKey
|
||||
import io.realm.annotations.RealmClass
|
||||
|
||||
@RealmClass(embedded = true)
|
||||
open class Invitations : RealmObject(), BaseObject {
|
||||
|
||||
@PrimaryKey
|
||||
var userId: String? = null
|
||||
|
||||
internal var user: User? = null
|
||||
|
||||
var party: PartyInvite? = null
|
||||
var parties: RealmList<PartyInvite>? = null
|
||||
var guilds: RealmList<GuildInvite>? = null
|
||||
|
|
|
|||
|
|
@ -2,10 +2,11 @@ package com.habitrpg.android.habitica.models.invitations
|
|||
|
||||
import io.realm.RealmObject
|
||||
import io.realm.annotations.PrimaryKey
|
||||
import io.realm.annotations.RealmClass
|
||||
|
||||
@RealmClass(embedded = true)
|
||||
open class PartyInvite : RealmObject(), GenericInvitation {
|
||||
|
||||
@PrimaryKey
|
||||
override var id: String? = null
|
||||
override var name: String? = null
|
||||
override var inviter: String? = null
|
||||
|
|
|
|||
|
|
@ -14,118 +14,21 @@ open class Member : RealmObject(), Avatar, BaseObject {
|
|||
@PrimaryKey
|
||||
@SerializedName("_id")
|
||||
var id: String? = null
|
||||
set(id) {
|
||||
field = id
|
||||
val subID = "m$id" // Do this to prevent the member object from overwriting the user ones
|
||||
if (stats != null && stats?.isManaged != true) {
|
||||
stats?.userId = subID
|
||||
}
|
||||
if (items != null && items?.isManaged != true) {
|
||||
items?.userId = subID
|
||||
}
|
||||
if (this.inbox != null && this.inbox?.isManaged != true) {
|
||||
this.inbox?.userId = subID
|
||||
}
|
||||
if (preferences != null && preferences?.isManaged != true) {
|
||||
preferences?.userId = subID
|
||||
}
|
||||
if (this.profile != null && this.profile?.isManaged != true) {
|
||||
this.profile?.userId = subID
|
||||
}
|
||||
if (this.contributor != null && this.contributor?.isManaged != true) {
|
||||
this.contributor?.userId = subID
|
||||
}
|
||||
if (costume != null && costume?.isManaged != true) {
|
||||
costume?.userId = subID + "costume"
|
||||
}
|
||||
if (equipped != null && equipped?.isManaged != true) {
|
||||
equipped?.userId = subID + "equipped"
|
||||
}
|
||||
if (this.authentication != null && this.authentication?.isManaged != true) {
|
||||
this.authentication?.userId = subID
|
||||
}
|
||||
}
|
||||
override var stats: Stats? = null
|
||||
set(value) {
|
||||
field = value
|
||||
if (value != null && this.id != null && !value.isManaged) {
|
||||
field?.userId = this.id
|
||||
}
|
||||
}
|
||||
var inbox: Inbox? = null
|
||||
set(inbox) {
|
||||
field = inbox
|
||||
if (inbox != null && this.id != null && !inbox.isManaged) {
|
||||
inbox.userId = this.id
|
||||
}
|
||||
}
|
||||
override var preferences: MemberPreferences? = null
|
||||
set(value) {
|
||||
field = value
|
||||
if (value != null && this.id != null && !value.isManaged) {
|
||||
field?.userId = this.id
|
||||
}
|
||||
}
|
||||
override val gemCount: Int
|
||||
get() = 0
|
||||
override val hourglassCount: Int
|
||||
get() = 0
|
||||
var profile: Profile? = null
|
||||
set(profile) {
|
||||
field = profile
|
||||
if (profile != null && this.id != null && !profile.isManaged) {
|
||||
profile.userId = this.id
|
||||
}
|
||||
}
|
||||
var party: UserParty? = null
|
||||
set(party) {
|
||||
field = party
|
||||
if (party != null && this.id != null && !party.isManaged) {
|
||||
party.userId = this.id
|
||||
}
|
||||
}
|
||||
var contributor: ContributorInfo? = null
|
||||
set(contributor) {
|
||||
field = contributor
|
||||
if (contributor != null && this.id != null && !contributor.isManaged) {
|
||||
contributor.userId = this.id
|
||||
}
|
||||
}
|
||||
var backer: Backer? = null
|
||||
set(backer) {
|
||||
field = backer
|
||||
if (backer != null && this.id != null && !backer.isManaged) {
|
||||
backer.id = this.id
|
||||
}
|
||||
}
|
||||
var authentication: Authentication? = null
|
||||
set(authentication) {
|
||||
field = authentication
|
||||
if (authentication != null && this.id != null) {
|
||||
authentication.userId = this.id
|
||||
}
|
||||
}
|
||||
var items: Items? = null
|
||||
set(items) {
|
||||
field = items
|
||||
if (items != null && this.id != null && !items.isManaged) {
|
||||
items.userId = this.id
|
||||
}
|
||||
}
|
||||
override var costume: Outfit? = null
|
||||
set(value) {
|
||||
field = value
|
||||
if (value != null && this.id != null) {
|
||||
field?.userId = this.id + "costume"
|
||||
}
|
||||
}
|
||||
override var equipped: Outfit? = null
|
||||
set(value) {
|
||||
field = value
|
||||
if (value != null && this.id != null) {
|
||||
field?.userId = this.id + "equipped"
|
||||
}
|
||||
}
|
||||
|
||||
override var currentMount: String? = null
|
||||
override var currentPet: String? = null
|
||||
|
|
|
|||
|
|
@ -11,15 +11,6 @@ import io.realm.annotations.RealmClass
|
|||
@RealmClass(embedded = true)
|
||||
open class MemberPreferences : RealmObject(), AvatarPreferences {
|
||||
|
||||
@PrimaryKey
|
||||
override var userId: String? = null
|
||||
set(value) {
|
||||
field = value
|
||||
if (hair?.isManaged != true) {
|
||||
hair?.userId = userId
|
||||
}
|
||||
}
|
||||
|
||||
override var hair: Hair? = null
|
||||
override var costume: Boolean = false
|
||||
override var disableClasses: Boolean = false
|
||||
|
|
|
|||
|
|
@ -15,10 +15,6 @@ import io.realm.annotations.PrimaryKey
|
|||
open class ShopItem : RealmObject(), BaseObject {
|
||||
@PrimaryKey
|
||||
var key: String = ""
|
||||
set(value) {
|
||||
field = value
|
||||
unlockCondition?.questKey = key
|
||||
}
|
||||
var text: String? = ""
|
||||
var notes: String? = ""
|
||||
@SerializedName("class")
|
||||
|
|
@ -43,12 +39,6 @@ open class ShopItem : RealmObject(), BaseObject {
|
|||
var categoryIdentifier: String = ""
|
||||
var limitedNumberLeft: Int? = null
|
||||
var unlockCondition: ShopItemUnlockCondition? = null
|
||||
set(value) {
|
||||
field = value
|
||||
if (key.isNotEmpty()) {
|
||||
field?.questKey = key
|
||||
}
|
||||
}
|
||||
var path: String? = null
|
||||
var isSuggested: String? = null
|
||||
var pinType: String? = null
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@ import io.realm.annotations.RealmClass
|
|||
@RealmClass(embedded = true)
|
||||
open class ShopItemUnlockCondition : RealmObject(), BaseObject {
|
||||
|
||||
@PrimaryKey
|
||||
var questKey: String? = null
|
||||
private var condition: String? = null
|
||||
var incentiveThreshold: Int? = null
|
||||
|
||||
|
|
|
|||
|
|
@ -7,19 +7,8 @@ import io.realm.annotations.RealmClass
|
|||
|
||||
@RealmClass(embedded = true)
|
||||
open class ChallengeMembership : RealmObject, BaseObject {
|
||||
@PrimaryKey
|
||||
var combinedID: String = ""
|
||||
|
||||
var userID: String = ""
|
||||
set(value) {
|
||||
field = value
|
||||
combinedID = userID + challengeID
|
||||
}
|
||||
var challengeID: String = ""
|
||||
set(value) {
|
||||
field = value
|
||||
combinedID = userID + challengeID
|
||||
}
|
||||
|
||||
constructor(userID: String, challengeID: String) : super() {
|
||||
this.userID = userID
|
||||
|
|
@ -29,14 +18,13 @@ open class ChallengeMembership : RealmObject, BaseObject {
|
|||
constructor() : super()
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
return if (other?.javaClass == ChallengeMembership::class.java) {
|
||||
this.combinedID == (other as ChallengeMembership).combinedID
|
||||
return if (other is ChallengeMembership) {
|
||||
this.userID == other.userID && challengeID == other.challengeID
|
||||
} else super.equals(other)
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = combinedID.hashCode()
|
||||
result = 31 * result + userID.hashCode()
|
||||
var result = userID.hashCode()
|
||||
result = 31 * result + challengeID.hashCode()
|
||||
return result
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,13 +20,6 @@ open class ChatMessage : RealmObject(), BaseMainObject {
|
|||
|
||||
@PrimaryKey
|
||||
var id: String = ""
|
||||
set(value) {
|
||||
field = value
|
||||
likes?.forEach { it.messageId = value }
|
||||
userStyles?.id = id
|
||||
contributor?.userId = id
|
||||
backer?.id = id
|
||||
}
|
||||
|
||||
var text: String? = null
|
||||
|
||||
|
|
|
|||
|
|
@ -6,25 +6,4 @@ import io.realm.annotations.PrimaryKey
|
|||
import io.realm.annotations.RealmClass
|
||||
|
||||
@RealmClass(embedded = true)
|
||||
open class ChatMessageLike : RealmObject, BaseObject {
|
||||
|
||||
@PrimaryKey
|
||||
var key: String = ""
|
||||
|
||||
var messageId: String = ""
|
||||
set(value) {
|
||||
field = value
|
||||
key = messageId + id
|
||||
}
|
||||
var id: String = ""
|
||||
set(value) {
|
||||
field = value
|
||||
key = messageId + id
|
||||
}
|
||||
constructor(id: String, messageId: String) : super() {
|
||||
this.id = id
|
||||
this.key = messageId + id
|
||||
}
|
||||
|
||||
constructor() : super()
|
||||
}
|
||||
open class ChatMessageLike(var id: String = "") : RealmObject(), BaseObject
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ import io.realm.RealmObject
|
|||
import io.realm.annotations.PrimaryKey
|
||||
import io.realm.annotations.RealmClass
|
||||
|
||||
@RealmClass(embedded = true)
|
||||
open class GroupCategory : RealmObject(), BaseMainObject {
|
||||
override val realmClass: Class<out RealmModel>
|
||||
get() = Group::class.java
|
||||
|
|
|
|||
|
|
@ -7,19 +7,8 @@ import io.realm.annotations.RealmClass
|
|||
|
||||
@RealmClass(embedded = true)
|
||||
open class GroupMembership : RealmObject, BaseObject {
|
||||
@PrimaryKey
|
||||
var combinedID: String = ""
|
||||
|
||||
var userID: String = ""
|
||||
set(value) {
|
||||
field = value
|
||||
combinedID = userID + groupID
|
||||
}
|
||||
var groupID: String = ""
|
||||
set(value) {
|
||||
field = value
|
||||
combinedID = userID + groupID
|
||||
}
|
||||
|
||||
constructor(userID: String, groupID: String) : super() {
|
||||
this.userID = userID
|
||||
|
|
|
|||
|
|
@ -10,11 +10,6 @@ open class InboxConversation : RealmObject(), BaseObject {
|
|||
|
||||
@PrimaryKey
|
||||
var combinedID: String = ""
|
||||
set(value) {
|
||||
field = value
|
||||
userStyles?.id = value
|
||||
contributor?.userId = value
|
||||
}
|
||||
var uuid: String = ""
|
||||
set(value) {
|
||||
field = value
|
||||
|
|
|
|||
|
|
@ -10,8 +10,6 @@ import io.realm.annotations.RealmClass
|
|||
|
||||
@RealmClass(embedded = true)
|
||||
open class UserParty : RealmObject(), BaseObject {
|
||||
@PrimaryKey
|
||||
var userId: String? = null
|
||||
@SerializedName("_id")
|
||||
var id: String = ""
|
||||
var quest: Quest? = null
|
||||
|
|
|
|||
|
|
@ -11,15 +11,6 @@ import io.realm.annotations.RealmClass
|
|||
|
||||
@RealmClass(embedded = true)
|
||||
open class UserStyles : RealmObject(), Avatar {
|
||||
@PrimaryKey
|
||||
var id: String? = null
|
||||
set(value) {
|
||||
field = value
|
||||
stats?.userId = id
|
||||
preferences?.userId = id
|
||||
items?.userId = id
|
||||
}
|
||||
|
||||
override val currentMount: String?
|
||||
get() = items?.currentMount
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ open class ChecklistItem : RealmObject, BaseMainObject, Parcelable {
|
|||
override val primaryIdentifierName: String
|
||||
get() = "id"
|
||||
|
||||
@PrimaryKey
|
||||
var id: String? = null
|
||||
var text: String? = null
|
||||
var completed: Boolean = false
|
||||
|
|
|
|||
|
|
@ -8,8 +8,6 @@ import io.realm.annotations.RealmClass
|
|||
|
||||
@RealmClass(embedded = true)
|
||||
open class Days() : RealmObject(), Parcelable {
|
||||
@PrimaryKey
|
||||
var taskId: String? = null
|
||||
var m: Boolean = true
|
||||
var t: Boolean = true
|
||||
var w: Boolean = true
|
||||
|
|
@ -19,7 +17,6 @@ open class Days() : RealmObject(), Parcelable {
|
|||
var su: Boolean = true
|
||||
|
||||
override fun writeToParcel(dest: Parcel, flags: Int) {
|
||||
dest.writeString(taskId)
|
||||
dest.writeByte(if (m) 1.toByte() else 0.toByte())
|
||||
dest.writeByte(if (t) 1.toByte() else 0.toByte())
|
||||
dest.writeByte(if (w) 1.toByte() else 0.toByte())
|
||||
|
|
@ -30,7 +27,6 @@ open class Days() : RealmObject(), Parcelable {
|
|||
}
|
||||
|
||||
protected constructor(`in`: Parcel) : this() {
|
||||
taskId = `in`.readString()
|
||||
m = `in`.readByte().toInt() != 0
|
||||
t = `in`.readByte().toInt() != 0
|
||||
w = `in`.readByte().toInt() != 0
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import io.realm.annotations.RealmClass
|
|||
|
||||
@RealmClass(embedded = true)
|
||||
open class RemindersItem : RealmObject, Parcelable {
|
||||
@PrimaryKey
|
||||
var id: String? = null
|
||||
var startDate: Date? = null
|
||||
var time: Date? = null
|
||||
|
|
|
|||
|
|
@ -31,10 +31,6 @@ open class Task : RealmObject, BaseMainObject, Parcelable {
|
|||
@PrimaryKey
|
||||
@SerializedName("_id")
|
||||
var id: String? = null
|
||||
set(value) {
|
||||
field = value
|
||||
repeat?.taskId = value
|
||||
}
|
||||
var userId: String = ""
|
||||
var priority: Float = 0.0f
|
||||
var text: String = ""
|
||||
|
|
@ -64,10 +60,6 @@ open class Task : RealmObject, BaseMainObject, Parcelable {
|
|||
var streak: Int? = 0
|
||||
var startDate: Date? = null
|
||||
var repeat: Days? = null
|
||||
set(value) {
|
||||
field = value
|
||||
field?.taskId = id
|
||||
}
|
||||
//todos
|
||||
@SerializedName("date")
|
||||
var dueDate: Date? = null
|
||||
|
|
|
|||
|
|
@ -12,9 +12,6 @@ import java.util.*
|
|||
@RealmClass(embedded = true)
|
||||
open class TaskGroupPlan : RealmObject(), BaseObject {
|
||||
|
||||
@PrimaryKey
|
||||
internal var taskID: String? = null
|
||||
|
||||
@SerializedName("id")
|
||||
var groupID: String? = null
|
||||
var managerNotes: String? = null
|
||||
|
|
|
|||
|
|
@ -9,24 +9,5 @@ import io.realm.annotations.RealmClass
|
|||
@RealmClass(embedded = true)
|
||||
open class TaskTag : RealmObject(), BaseObject {
|
||||
var tag: Tag? = null
|
||||
set(value) {
|
||||
field = value
|
||||
tagId = tag?.id ?: ""
|
||||
updatePrimaryKey()
|
||||
}
|
||||
var task: Task? = null
|
||||
set(value) {
|
||||
field = value
|
||||
taskId = task?.id ?: ""
|
||||
updatePrimaryKey()
|
||||
}
|
||||
|
||||
@PrimaryKey
|
||||
var id: String? = null
|
||||
private var tagId = ""
|
||||
private var taskId: String? = ""
|
||||
|
||||
private fun updatePrimaryKey() {
|
||||
id = taskId + "_" + tagId
|
||||
}
|
||||
}
|
||||
|
|
@ -3,12 +3,10 @@ package com.habitrpg.android.habitica.models.user
|
|||
import com.habitrpg.android.habitica.models.BaseObject
|
||||
import io.realm.RealmObject
|
||||
import io.realm.annotations.PrimaryKey
|
||||
import io.realm.annotations.RealmClass
|
||||
|
||||
@RealmClass(embedded = true)
|
||||
open class ABTest: RealmObject(), BaseObject {
|
||||
|
||||
@PrimaryKey
|
||||
var userID: String? = null
|
||||
|
||||
var name: String = ""
|
||||
var group: String = ""
|
||||
}
|
||||
|
|
@ -10,15 +10,6 @@ import io.realm.annotations.RealmClass
|
|||
|
||||
@RealmClass(embedded = true)
|
||||
open class Authentication : RealmObject(), BaseObject {
|
||||
|
||||
@PrimaryKey
|
||||
var userId: String? = null
|
||||
set(value) {
|
||||
field = value
|
||||
timestamps?.userId = value
|
||||
localAuthentication?.userID = value
|
||||
}
|
||||
|
||||
@SerializedName("local")
|
||||
var localAuthentication: LocalAuthentication? = null
|
||||
|
||||
|
|
|
|||
|
|
@ -9,10 +9,6 @@ import java.util.*
|
|||
|
||||
@RealmClass(embedded = true)
|
||||
open class AuthenticationTimestamps : RealmObject(), BaseObject {
|
||||
|
||||
@PrimaryKey
|
||||
var userId: String? = null
|
||||
|
||||
@SerializedName("loggedin")
|
||||
var lastLoggedIn: Date? = null
|
||||
@SerializedName("created")
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import io.realm.annotations.RealmClass
|
|||
|
||||
@RealmClass(embedded = true)
|
||||
open class Backer : RealmObject(), BaseObject {
|
||||
var id: String? = null
|
||||
var npc: String? = null
|
||||
var tier: Int? = null
|
||||
}
|
||||
|
|
@ -8,8 +8,6 @@ import io.realm.annotations.RealmClass
|
|||
|
||||
@RealmClass(embedded = true)
|
||||
open class Buffs : RealmObject(), BaseObject {
|
||||
@PrimaryKey
|
||||
var userId: String? = null
|
||||
var con: Float? = null
|
||||
var str: Float? = null
|
||||
var per: Float? = null
|
||||
|
|
|
|||
|
|
@ -27,9 +27,6 @@ open class ContributorInfo : RealmObject(), BaseObject {
|
|||
}
|
||||
}
|
||||
|
||||
@PrimaryKey
|
||||
var userId: String? = null
|
||||
var user: User? = null
|
||||
var admin = false
|
||||
var contributions: String? = null
|
||||
var level = 0
|
||||
|
|
|
|||
|
|
@ -9,8 +9,6 @@ import io.realm.annotations.RealmClass
|
|||
|
||||
@RealmClass(embedded = true)
|
||||
open class Flags : RealmObject(), BaseObject {
|
||||
@PrimaryKey
|
||||
var userId: String? = null
|
||||
var tutorial: RealmList<TutorialStep>? = null
|
||||
var showTour = false
|
||||
var dropsEnabled = false
|
||||
|
|
|
|||
|
|
@ -9,19 +9,7 @@ import io.realm.annotations.RealmClass
|
|||
|
||||
@RealmClass(embedded = true)
|
||||
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
|
||||
}
|
||||
|
|
@ -7,11 +7,6 @@ import io.realm.annotations.RealmClass
|
|||
|
||||
@RealmClass(embedded = true)
|
||||
open class Hair : RealmObject, BaseObject {
|
||||
|
||||
@PrimaryKey
|
||||
var userId: String? = null
|
||||
|
||||
var preferences: Preferences? = null
|
||||
var mustache: Int = 0
|
||||
var beard: Int = 0
|
||||
var bangs: Int = 0
|
||||
|
|
|
|||
|
|
@ -8,11 +8,6 @@ import io.realm.annotations.RealmClass
|
|||
|
||||
@RealmClass(embedded = true)
|
||||
open class Inbox : RealmObject(), BaseObject {
|
||||
|
||||
@PrimaryKey
|
||||
var userId: String? = null
|
||||
|
||||
internal var user: User? = null
|
||||
var optOut: Boolean = false
|
||||
var blocks: RealmList<String> = RealmList()
|
||||
var newMessages: Int = 0
|
||||
|
|
|
|||
|
|
@ -9,56 +9,26 @@ import java.util.*
|
|||
|
||||
@RealmClass(embedded = true)
|
||||
open class Items : RealmObject, BaseObject {
|
||||
|
||||
@PrimaryKey
|
||||
var userId: String? = null
|
||||
set(userId) {
|
||||
field = userId
|
||||
if (gear != null && gear?.isManaged == false) {
|
||||
gear?.userId = userId
|
||||
}
|
||||
if (special != null && special?.isManaged == false) {
|
||||
special?.userId = userId
|
||||
}
|
||||
eggs?.forEach {
|
||||
if (!it.isManaged) {
|
||||
it.userID = userId
|
||||
it.itemType = "eggs"
|
||||
}
|
||||
}
|
||||
food?.forEach {
|
||||
if (!it.isManaged) {
|
||||
it.userID = userId
|
||||
it.itemType = "food"
|
||||
}
|
||||
}
|
||||
hatchingPotions?.forEach {
|
||||
if (!it.isManaged) {
|
||||
it.userID = userId
|
||||
it.itemType = "hatchingPotions"
|
||||
}
|
||||
}
|
||||
quests?.forEach {
|
||||
if (!it.isManaged) {
|
||||
it.userID = userId
|
||||
it.itemType = "quests"
|
||||
}
|
||||
}
|
||||
pets?.forEach {
|
||||
if (!it.isManaged) {
|
||||
it.userID = userId
|
||||
}
|
||||
}
|
||||
mounts?.forEach {
|
||||
if (!it.isManaged) {
|
||||
it.userID = userId
|
||||
}
|
||||
}
|
||||
}
|
||||
var eggs: RealmList<OwnedItem>? = null
|
||||
set(value) {
|
||||
field = value
|
||||
field?.forEach { it.itemType = "eggs" }
|
||||
}
|
||||
var food: RealmList<OwnedItem>? = null
|
||||
set(value) {
|
||||
field = value
|
||||
field?.forEach { it.itemType = "food" }
|
||||
}
|
||||
var hatchingPotions: RealmList<OwnedItem>? = null
|
||||
set(value) {
|
||||
field = value
|
||||
field?.forEach { it.itemType = "hatchingPotions" }
|
||||
}
|
||||
var quests: RealmList<OwnedItem>? = null
|
||||
set(value) {
|
||||
field = value
|
||||
field?.forEach { it.itemType = "quests" }
|
||||
}
|
||||
var pets: RealmList<OwnedPet>? = null
|
||||
var mounts: RealmList<OwnedMount>? = null
|
||||
var currentMount: String? = null
|
||||
|
|
|
|||
|
|
@ -11,11 +11,6 @@ import io.realm.annotations.RealmClass
|
|||
|
||||
@RealmClass(embedded = true)
|
||||
open class Outfit : RealmObject(), BaseObject {
|
||||
|
||||
@PrimaryKey
|
||||
var userId: String? = null
|
||||
|
||||
internal var gear: Gear? = null
|
||||
var armor: String = ""
|
||||
var back: String = ""
|
||||
var body: String = ""
|
||||
|
|
|
|||
|
|
@ -6,29 +6,10 @@ import io.realm.annotations.RealmClass
|
|||
|
||||
@RealmClass(embedded = true)
|
||||
open class OwnedCustomization : RealmObject(), OwnedObject {
|
||||
|
||||
@PrimaryKey
|
||||
override var combinedKey: String? = null
|
||||
override var userID: String? = null
|
||||
set(value) {
|
||||
field = value
|
||||
combinedKey = field + type + category + key
|
||||
}
|
||||
override var key: String? = null
|
||||
set(value) {
|
||||
field = value
|
||||
combinedKey = userID + type + category +field
|
||||
}
|
||||
|
||||
var type: String? = null
|
||||
set(value) {
|
||||
field = value
|
||||
combinedKey = userID + field + category +key
|
||||
}
|
||||
var category: String? = null
|
||||
set(value) {
|
||||
field = value
|
||||
combinedKey = userID + type + field + key
|
||||
}
|
||||
var purchased = false
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,27 +12,27 @@ open class OwnedItem : RealmObject(), BaseMainObject, OwnedObject {
|
|||
override val realmClass: Class<OwnedItem>
|
||||
get() = OwnedItem::class.java
|
||||
override val primaryIdentifier: String?
|
||||
get() = combinedKey
|
||||
get() = key
|
||||
override val primaryIdentifierName: String
|
||||
get() = "combinedKey"
|
||||
|
||||
@PrimaryKey
|
||||
override var combinedKey: String? = null
|
||||
override var userID: String? = null
|
||||
set(value) {
|
||||
field = value
|
||||
combinedKey = field + itemType + key
|
||||
}
|
||||
|
||||
override var key: String? = null
|
||||
set(value) {
|
||||
field = value
|
||||
combinedKey = userID + itemType + field
|
||||
}
|
||||
|
||||
var itemType: String? = null
|
||||
set(value) {
|
||||
field = value
|
||||
combinedKey = userID + field + key
|
||||
}
|
||||
var numberOwned = 0
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
return if (other is OwnedItem) {
|
||||
userID == other.userID && key == other.key && itemType == other.itemType
|
||||
} else super.equals(other)
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = userID?.hashCode() ?: 0
|
||||
result = 31 * result + (key?.hashCode() ?: 0)
|
||||
result = 31 * result + (itemType?.hashCode() ?: 0)
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,31 +7,22 @@ import io.realm.annotations.RealmClass
|
|||
@RealmClass(embedded = true)
|
||||
open class OwnedMount : RealmObject(), OwnedObject {
|
||||
|
||||
@PrimaryKey
|
||||
override var combinedKey: String? = null
|
||||
override var userID: String? = null
|
||||
set(value) {
|
||||
field = value
|
||||
combinedKey = field + key
|
||||
}
|
||||
override var key: String? = null
|
||||
set(value) {
|
||||
field = value
|
||||
combinedKey = field + key
|
||||
}
|
||||
|
||||
|
||||
var owned = false
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
return if (other?.javaClass == OwnedMount::class.java) {
|
||||
this.combinedKey == (other as OwnedMount).combinedKey
|
||||
return if (other is OwnedMount) {
|
||||
userID == other.userID && key == other.key
|
||||
} else super.equals(other)
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = combinedKey.hashCode()
|
||||
result = 31 * result + userID.hashCode()
|
||||
result = 31 * result + key.hashCode()
|
||||
var result = userID?.hashCode() ?: 0
|
||||
result = 31 * result + (key?.hashCode() ?: 0)
|
||||
result = 31 * result + owned.hashCode()
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package com.habitrpg.android.habitica.models.user
|
|||
import com.habitrpg.android.habitica.models.BaseObject
|
||||
|
||||
interface OwnedObject: BaseObject {
|
||||
var combinedKey: String?
|
||||
var userID: String?
|
||||
var key: String?
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,32 +7,19 @@ import io.realm.annotations.RealmClass
|
|||
|
||||
@RealmClass(embedded = true)
|
||||
open class OwnedPet : RealmObject(), OwnedObject {
|
||||
|
||||
@PrimaryKey
|
||||
override var combinedKey: String? = null
|
||||
override var userID: String? = null
|
||||
set(value) {
|
||||
field = value
|
||||
combinedKey = field + key
|
||||
}
|
||||
override var key: String? = null
|
||||
set(value) {
|
||||
field = value
|
||||
combinedKey = field + key
|
||||
}
|
||||
|
||||
var trained = 0
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
return if (other?.javaClass == OwnedPet::class.java) {
|
||||
this.combinedKey == (other as OwnedPet).combinedKey
|
||||
return if (other is OwnedPet) {
|
||||
userID == other.userID && key == other.key
|
||||
} else super.equals(other)
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = combinedKey.hashCode()
|
||||
result = 31 * result + userID.hashCode()
|
||||
result = 31 * result + key.hashCode()
|
||||
var result = userID?.hashCode() ?: 0
|
||||
result = 31 * result + (key?.hashCode() ?: 0)
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,19 +12,6 @@ import java.util.*
|
|||
|
||||
@RealmClass(embedded = true)
|
||||
open class Preferences : RealmObject(), AvatarPreferences, BaseObject {
|
||||
|
||||
@PrimaryKey
|
||||
override var userId: String? = null
|
||||
set(value) {
|
||||
field = value
|
||||
if (hair?.isManaged == false) {
|
||||
hair?.userId = value
|
||||
}
|
||||
if (suppressModals?.isManaged == false) {
|
||||
suppressModals?.userId = value
|
||||
}
|
||||
}
|
||||
|
||||
override var hair: Hair? = null
|
||||
var suppressModals: SuppressedModals? = null
|
||||
override var costume: Boolean = false
|
||||
|
|
|
|||
|
|
@ -7,10 +7,6 @@ import io.realm.annotations.RealmClass
|
|||
|
||||
@RealmClass(embedded = true)
|
||||
open class Profile : RealmObject, BaseObject {
|
||||
|
||||
@PrimaryKey
|
||||
var userId: String? = null
|
||||
|
||||
internal var user: User? = null
|
||||
var name: String? = null
|
||||
var blurb: String? = null
|
||||
|
|
|
|||
|
|
@ -8,12 +8,6 @@ import io.realm.annotations.RealmClass
|
|||
|
||||
@RealmClass(embedded = true)
|
||||
open class Purchases : RealmObject(), BaseObject {
|
||||
@PrimaryKey
|
||||
var userId: String? = null
|
||||
set(value) {
|
||||
field = value
|
||||
customizations?.forEach { it.userID = value }
|
||||
}
|
||||
@JvmField
|
||||
var customizations: RealmList<OwnedCustomization>? = null
|
||||
var user: User? = null
|
||||
|
|
|
|||
|
|
@ -9,18 +9,6 @@ import io.realm.annotations.RealmClass
|
|||
|
||||
@RealmClass(embedded = true)
|
||||
open class SpecialItems : RealmObject(), BaseObject {
|
||||
|
||||
@PrimaryKey
|
||||
var userId: String? = null
|
||||
set(userId) {
|
||||
field = userId
|
||||
ownedItems?.forEach {
|
||||
if (!it.isManaged) {
|
||||
it.userID = userId
|
||||
it.itemType = "special"
|
||||
}
|
||||
}
|
||||
}
|
||||
var ownedItems: RealmList<OwnedItem>? = null
|
||||
var seafoam: Int = 0
|
||||
var shinySeed: Int = 0
|
||||
|
|
|
|||
|
|
@ -11,20 +11,6 @@ import io.realm.annotations.RealmClass
|
|||
|
||||
@RealmClass(embedded = true)
|
||||
open class Stats : RealmObject(), BaseObject {
|
||||
|
||||
@PrimaryKey
|
||||
var userId: String? = null
|
||||
set(userId) {
|
||||
field = userId
|
||||
if (buffs?.isManaged == false) {
|
||||
buffs?.userId = userId
|
||||
}
|
||||
if (training?.isManaged == false) {
|
||||
training?.userId = userId
|
||||
}
|
||||
}
|
||||
|
||||
internal var user: User? = null
|
||||
@SerializedName("con")
|
||||
var constitution: Int? = null
|
||||
@SerializedName("str")
|
||||
|
|
|
|||
|
|
@ -9,14 +9,7 @@ import java.util.*
|
|||
|
||||
@RealmClass(embedded = true)
|
||||
open class SubscriptionPlan : RealmObject(), BaseObject {
|
||||
@PrimaryKey
|
||||
var customerId: String? = null
|
||||
set(value) {
|
||||
field = value
|
||||
if (consecutive != null && consecutive?.isManaged == true) {
|
||||
consecutive?.customerId = value
|
||||
}
|
||||
}
|
||||
var dateCreated: Date? = null
|
||||
var dateUpdated: Date? = null
|
||||
@JvmField
|
||||
|
|
|
|||
|
|
@ -7,9 +7,6 @@ import io.realm.annotations.RealmClass
|
|||
|
||||
@RealmClass(embedded = true)
|
||||
open class SubscriptionPlanConsecutive : RealmObject(), BaseObject {
|
||||
@PrimaryKey
|
||||
var customerId: String? = null
|
||||
var subscriptionPlan: SubscriptionPlan? = null
|
||||
var trinkets = 0
|
||||
var gemCapExtra = 0
|
||||
var offset = 0
|
||||
|
|
|
|||
|
|
@ -7,9 +7,6 @@ import io.realm.annotations.RealmClass
|
|||
|
||||
@RealmClass(embedded = true)
|
||||
open class SuppressedModals : RealmObject(), BaseObject {
|
||||
@PrimaryKey
|
||||
var userId: String? = null
|
||||
var preferences: Preferences? = null
|
||||
var streak: Boolean? = null
|
||||
var raisePet: Boolean? = null
|
||||
var hatchPet: Boolean? = null
|
||||
|
|
|
|||
|
|
@ -8,9 +8,6 @@ import io.realm.annotations.RealmClass
|
|||
|
||||
@RealmClass(embedded = true)
|
||||
open class Training : RealmObject(), BaseObject {
|
||||
@PrimaryKey
|
||||
var userId: String? = null
|
||||
var stats: Stats? = null
|
||||
var con: Float = 0f
|
||||
var str: Float = 0f
|
||||
var per: Float = 0f
|
||||
|
|
|
|||
|
|
@ -29,128 +29,23 @@ open class User : RealmObject(), BaseMainObject, Avatar, VersionedObject {
|
|||
@PrimaryKey
|
||||
@SerializedName("_id")
|
||||
var id: String? = null
|
||||
set(id) {
|
||||
field = id
|
||||
if (stats?.isManaged != true) {
|
||||
stats?.userId = id
|
||||
}
|
||||
if (inbox?.isManaged != true) {
|
||||
this.inbox?.userId = id
|
||||
}
|
||||
if (preferences?.isManaged != true) {
|
||||
preferences?.userId = id
|
||||
}
|
||||
if (purchased?.isManaged != true) {
|
||||
purchased?.userId = id
|
||||
}
|
||||
if (this.profile?.isManaged != true) {
|
||||
this.profile?.userId = id
|
||||
}
|
||||
if (this.items?.isManaged != true) {
|
||||
this.items?.userId = id
|
||||
}
|
||||
if (this.authentication?.isManaged != true) {
|
||||
this.authentication?.userId = id
|
||||
}
|
||||
if (this.flags?.isManaged != true) {
|
||||
this.flags?.userId = id
|
||||
}
|
||||
if (this.contributor?.isManaged != true) {
|
||||
this.contributor?.userId = id
|
||||
}
|
||||
if (this.invitations?.isManaged != true) {
|
||||
this.invitations?.userId = id
|
||||
}
|
||||
for (test in abTests ?: emptyList<ABTest>()) {
|
||||
test.userID = id
|
||||
}
|
||||
for (achievement in achievements) {
|
||||
achievement.userId = id
|
||||
}
|
||||
}
|
||||
|
||||
@SerializedName("_v")
|
||||
override var versionNumber: Int = 0
|
||||
|
||||
var balance: Double = 0.toDouble()
|
||||
override var stats: Stats? = null
|
||||
set(value) {
|
||||
field = value
|
||||
if (value != null && this.id != null && !value.isManaged) {
|
||||
field?.userId = this.id
|
||||
}
|
||||
}
|
||||
var inbox: Inbox? = null
|
||||
set(inbox) {
|
||||
field = inbox
|
||||
if (inbox != null && this.id != null && !inbox.isManaged) {
|
||||
inbox.userId = this.id
|
||||
}
|
||||
}
|
||||
override var preferences: Preferences? = null
|
||||
set(value) {
|
||||
field = value
|
||||
if (value != null && this.id != null && !value.isManaged) {
|
||||
field?.userId = this.id
|
||||
}
|
||||
}
|
||||
var profile: Profile? = null
|
||||
set(profile) {
|
||||
field = profile
|
||||
if (profile != null && this.id != null && !profile.isManaged) {
|
||||
profile.userId = this.id
|
||||
}
|
||||
}
|
||||
var party: UserParty? = null
|
||||
set(party) {
|
||||
field = party
|
||||
if (party != null && this.id != null && !party.isManaged) {
|
||||
party.userId = this.id
|
||||
}
|
||||
}
|
||||
var items: Items? = null
|
||||
set(items) {
|
||||
field = items
|
||||
if (items != null && this.id != null && !items.isManaged) {
|
||||
items.userId = this.id
|
||||
}
|
||||
}
|
||||
@SerializedName("auth")
|
||||
var authentication: Authentication? = null
|
||||
set(authentication) {
|
||||
field = authentication
|
||||
if (authentication != null && this.id != null) {
|
||||
authentication.userId = this.id
|
||||
}
|
||||
}
|
||||
var flags: Flags? = null
|
||||
set(flags) {
|
||||
field = flags
|
||||
if (flags != null && this.id != null) {
|
||||
flags.userId = this.id
|
||||
}
|
||||
}
|
||||
var contributor: ContributorInfo? = null
|
||||
set(contributor) {
|
||||
field = contributor
|
||||
if (contributor != null && this.id != null && !contributor.isManaged) {
|
||||
contributor.userId = this.id
|
||||
}
|
||||
}
|
||||
var backer: Backer? = null
|
||||
set(backer) {
|
||||
field = backer
|
||||
if (backer != null && this.id != null && !backer.isManaged) {
|
||||
backer.id = this.id
|
||||
}
|
||||
}
|
||||
var invitations: Invitations? = null
|
||||
set(invitations) {
|
||||
field = invitations
|
||||
if (invitations != null && this.id != null && !invitations.isManaged) {
|
||||
invitations.userId = this.id
|
||||
}
|
||||
}
|
||||
|
||||
var tags = RealmList<Tag>()
|
||||
var achievements = RealmList<UserAchievement>()
|
||||
|
|
@ -165,12 +60,6 @@ open class User : RealmObject(), BaseMainObject, Avatar, VersionedObject {
|
|||
var pushDevices: List<PushDevice>? = null
|
||||
|
||||
var purchased: Purchases? = null
|
||||
set(purchased) {
|
||||
field = purchased
|
||||
if (purchased != null && this.id != null) {
|
||||
purchased.userId = this.id
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore
|
||||
var tasksOrder: TasksOrder? = null
|
||||
|
|
|
|||
|
|
@ -7,19 +7,7 @@ import io.realm.annotations.RealmClass
|
|||
|
||||
@RealmClass(embedded = true)
|
||||
open class UserAchievement : RealmObject(), BaseObject {
|
||||
|
||||
@PrimaryKey
|
||||
var combinedKey: String? = null
|
||||
var userId: String? = null
|
||||
set(value) {
|
||||
field = value
|
||||
combinedKey = field + key
|
||||
}
|
||||
var key: String? = null
|
||||
set(value) {
|
||||
field = value
|
||||
combinedKey = userId + field
|
||||
}
|
||||
var earned: Boolean = false
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,9 +7,7 @@ import android.content.res.Resources
|
|||
import androidx.preference.PreferenceManager
|
||||
import com.habitrpg.android.habitica.data.ApiClient
|
||||
import com.habitrpg.android.habitica.data.ContentRepository
|
||||
import com.habitrpg.android.habitica.executors.JobExecutor
|
||||
import com.habitrpg.android.habitica.executors.PostExecutionThread
|
||||
import com.habitrpg.android.habitica.executors.ThreadExecutor
|
||||
import com.habitrpg.android.habitica.executors.UIThread
|
||||
import com.habitrpg.android.habitica.helpers.*
|
||||
import com.habitrpg.android.habitica.helpers.KeyHelper.Companion.getInstance
|
||||
|
|
@ -56,10 +54,10 @@ class AppModule(private val application: Application) {
|
|||
}
|
||||
|
||||
@Provides
|
||||
fun provideKeyHelper(context: Context?, sharedPreferences: SharedPreferences?, keyStore: KeyStore?): KeyHelper? {
|
||||
fun provideKeyHelper(context: Context, sharedPreferences: SharedPreferences, keyStore: KeyStore?): KeyHelper? {
|
||||
return if (keyStore == null) {
|
||||
null
|
||||
} else getInstance(context!!, sharedPreferences!!, keyStore)
|
||||
} else getInstance(context, sharedPreferences, keyStore)
|
||||
}
|
||||
|
||||
@Provides
|
||||
|
|
@ -84,12 +82,6 @@ class AppModule(private val application: Application) {
|
|||
return SoundManager()
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideThreadExecutor(jobExecutor: JobExecutor): ThreadExecutor {
|
||||
return jobExecutor
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun providePostExecutionThread(uiThread: UIThread): PostExecutionThread {
|
||||
|
|
|
|||
|
|
@ -715,7 +715,11 @@ open class MainActivity : BaseActivity(), TutorialView.OnTutorialReaction {
|
|||
sharingIntent.type = "*/*"
|
||||
sharingIntent.putExtra(Intent.EXTRA_TEXT, event.sharedMessage)
|
||||
BitmapUtils.clearDirectoryContent("$filesDir/shared_images")
|
||||
val f = BitmapUtils.saveToShareableFile("$filesDir/shared_images", "${Date()}.png", event.shareImage)
|
||||
val f = event.shareImage?.let {
|
||||
BitmapUtils.saveToShareableFile("$filesDir/shared_images", "${Date()}.png",
|
||||
it
|
||||
)
|
||||
}
|
||||
val fileUri = f?.let { FileProvider.getUriForFile(this, getString(R.string.content_provider), it) }
|
||||
if (fileUri != null) {
|
||||
sharingIntent.putExtra(Intent.EXTRA_STREAM, fileUri)
|
||||
|
|
|
|||
|
|
@ -167,9 +167,7 @@ class ItemRecyclerAdapter(val context: Context) : BaseRecyclerViewAdapter<OwnedI
|
|||
when (selectedItem) {
|
||||
is Egg -> item?.let { startHatchingSubject.onNext(it) }
|
||||
is Food -> {
|
||||
val event = FeedCommand()
|
||||
event.usingFood = selectedItem
|
||||
EventBus.getDefault().post(event)
|
||||
EventBus.getDefault().post(FeedCommand(null, selectedItem))
|
||||
}
|
||||
is HatchingPotion -> startHatchingSubject.onNext(selectedItem)
|
||||
is QuestContent -> {
|
||||
|
|
@ -203,10 +201,7 @@ class ItemRecyclerAdapter(val context: Context) : BaseRecyclerViewAdapter<OwnedI
|
|||
return@let
|
||||
}
|
||||
} else if (isFeeding) {
|
||||
val event = FeedCommand()
|
||||
event.usingPet = feedingPet
|
||||
event.usingFood = item as? Food
|
||||
EventBus.getDefault().post(event)
|
||||
EventBus.getDefault().post(FeedCommand(feedingPet, item as? Food))
|
||||
fragment?.dismiss()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ open class TaskRecyclerViewFragment : BaseFragment<FragmentRefreshRecyclerviewBi
|
|||
return FragmentRefreshRecyclerviewBinding.inflate(inflater, container, false)
|
||||
}
|
||||
|
||||
protected var recyclerSubscription: CompositeDisposable = CompositeDisposable()
|
||||
private var recyclerSubscription: CompositeDisposable = CompositeDisposable()
|
||||
var recyclerAdapter: TaskRecyclerViewAdapter? = null
|
||||
var itemAnimator = SafeDefaultItemAnimator()
|
||||
var ownerID: String = ""
|
||||
|
|
@ -79,7 +79,6 @@ open class TaskRecyclerViewFragment : BaseFragment<FragmentRefreshRecyclerviewBi
|
|||
internal val className: String
|
||||
get() = this.taskType
|
||||
|
||||
// TODO needs a bit of cleanup
|
||||
private fun setInnerAdapter() {
|
||||
if (binding?.recyclerView?.adapter != null && binding?.recyclerView?.adapter == recyclerAdapter && !recyclerSubscription.isDisposed) {
|
||||
return
|
||||
|
|
@ -177,31 +176,22 @@ open class TaskRecyclerViewFragment : BaseFragment<FragmentRefreshRecyclerviewBi
|
|||
context?.let { binding?.recyclerView?.setBackgroundColor(ContextCompat.getColor(it, R.color.content_background)) }
|
||||
savedInstanceState?.let { this.taskType = savedInstanceState.getString(CLASS_TYPE_KEY, "") }
|
||||
|
||||
when (taskType) {
|
||||
Task.TYPE_TODO -> taskFilterHelper.setActiveFilter(Task.TYPE_TODO, Task.FILTER_ACTIVE)
|
||||
Task.TYPE_DAILY -> {
|
||||
val user = (activity as? MainActivity)?.user
|
||||
if (user?.isValid == true && user.preferences?.dailyDueDefaultView == true) {
|
||||
taskFilterHelper.setActiveFilter(Task.TYPE_DAILY, Task.FILTER_ACTIVE)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.setInnerAdapter()
|
||||
recyclerAdapter?.filter()
|
||||
|
||||
itemTouchCallback = object : ItemTouchHelper.Callback() {
|
||||
override fun onSelectedChanged(viewHolder: RecyclerView.ViewHolder?, actionState: Int) {
|
||||
super.onSelectedChanged(viewHolder, actionState)
|
||||
if (viewHolder == null || viewHolder.adapterPosition == NO_POSITION) return
|
||||
if (viewHolder == null || viewHolder.absoluteAdapterPosition == NO_POSITION) return
|
||||
val taskViewHolder = viewHolder as? BaseTaskViewHolder
|
||||
if (taskViewHolder != null) {
|
||||
taskViewHolder.movingFromPosition = viewHolder.adapterPosition
|
||||
taskViewHolder.movingFromPosition = viewHolder.absoluteAdapterPosition
|
||||
}
|
||||
binding?.refreshLayout?.isEnabled = false
|
||||
}
|
||||
|
||||
override fun onMove(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder, target: RecyclerView.ViewHolder): Boolean {
|
||||
recyclerAdapter?.notifyItemMoved(viewHolder.adapterPosition, target.adapterPosition)
|
||||
recyclerAdapter?.notifyItemMoved(viewHolder.absoluteAdapterPosition, target.absoluteAdapterPosition)
|
||||
return true
|
||||
}
|
||||
|
||||
|
|
@ -209,7 +199,7 @@ open class TaskRecyclerViewFragment : BaseFragment<FragmentRefreshRecyclerviewBi
|
|||
|
||||
//defines the enabled move directions in each state (idle, swiping, dragging).
|
||||
override fun getMovementFlags(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder): Int {
|
||||
return if (recyclerAdapter?.getItemViewType(viewHolder.adapterPosition) ?: 0 == 2) {
|
||||
return if (recyclerAdapter?.getItemViewType(viewHolder.absoluteAdapterPosition) ?: 0 == 2) {
|
||||
makeFlag(ItemTouchHelper.ACTION_STATE_IDLE, 0)
|
||||
} else {
|
||||
makeFlag(ItemTouchHelper.ACTION_STATE_DRAG,
|
||||
|
|
@ -225,10 +215,10 @@ open class TaskRecyclerViewFragment : BaseFragment<FragmentRefreshRecyclerviewBi
|
|||
super.clearView(recyclerView, viewHolder)
|
||||
binding?.refreshLayout?.isEnabled = true
|
||||
|
||||
if (viewHolder.adapterPosition == NO_POSITION) return
|
||||
if (viewHolder.absoluteAdapterPosition == NO_POSITION) return
|
||||
val taskViewHolder = viewHolder as? BaseTaskViewHolder
|
||||
val validTaskId = taskViewHolder?.task?.takeIf { it.isValid }?.id
|
||||
if (viewHolder.adapterPosition != taskViewHolder?.movingFromPosition) {
|
||||
if (viewHolder.absoluteAdapterPosition != taskViewHolder?.movingFromPosition) {
|
||||
taskViewHolder?.movingFromPosition = null
|
||||
updateTaskInRepository(validTaskId, viewHolder)
|
||||
}
|
||||
|
|
@ -238,7 +228,7 @@ open class TaskRecyclerViewFragment : BaseFragment<FragmentRefreshRecyclerviewBi
|
|||
if (validTaskId != null) {
|
||||
recyclerAdapter?.ignoreUpdates = true
|
||||
compositeSubscription.add(taskRepository.updateTaskPosition(
|
||||
taskType, validTaskId, viewHolder.adapterPosition
|
||||
taskType, validTaskId, viewHolder.absoluteAdapterPosition
|
||||
)
|
||||
.delay(1, TimeUnit.SECONDS)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
|
|
@ -255,8 +245,6 @@ open class TaskRecyclerViewFragment : BaseFragment<FragmentRefreshRecyclerviewBi
|
|||
layoutManager?.isItemPrefetchEnabled = false
|
||||
binding?.recyclerView?.layoutManager = layoutManager
|
||||
|
||||
this.setInnerAdapter()
|
||||
|
||||
allowReordering()
|
||||
|
||||
val bottomPadding = ((binding?.recyclerView?.paddingBottom ?: 0) + TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 60f, resources.displayMetrics)).toInt()
|
||||
|
|
@ -298,7 +286,10 @@ open class TaskRecyclerViewFragment : BaseFragment<FragmentRefreshRecyclerviewBi
|
|||
.flatMap { userRepository.retrieveUser(true, forced = true) }
|
||||
.subscribe({}, RxErrorHandler.handleEmptyError())
|
||||
}
|
||||
dialog.addButton(it.getString(R.string.delete_x_tasks, taskCount), false, true) { _, _ ->
|
||||
dialog.addButton(it.getString(R.string.delete_x_tasks, taskCount),
|
||||
isPrimary = false,
|
||||
isDestructive = true
|
||||
) { _, _ ->
|
||||
if (!task.isValid) return@addButton
|
||||
taskRepository.unlinkAllTasks(task.challengeID, "remove-all")
|
||||
.flatMap { userRepository.retrieveUser(true, forced = true) }
|
||||
|
|
@ -383,8 +374,14 @@ open class TaskRecyclerViewFragment : BaseFragment<FragmentRefreshRecyclerviewBi
|
|||
|
||||
override fun onStart() {
|
||||
super.onStart()
|
||||
if (binding?.recyclerView?.adapter == null || recyclerAdapter == null) {
|
||||
setInnerAdapter()
|
||||
when (taskType) {
|
||||
Task.TYPE_TODO -> taskFilterHelper.setActiveFilter(Task.TYPE_TODO, Task.FILTER_ACTIVE)
|
||||
Task.TYPE_DAILY -> {
|
||||
val user = (activity as? MainActivity)?.user
|
||||
if (user?.isValid == true && user.preferences?.dailyDueDefaultView == true) {
|
||||
taskFilterHelper.setActiveFilter(Task.TYPE_DAILY, Task.FILTER_ACTIVE)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -429,7 +426,6 @@ open class TaskRecyclerViewFragment : BaseFragment<FragmentRefreshRecyclerviewBi
|
|||
|
||||
fun newInstance(context: Context?, classType: String): TaskRecyclerViewFragment {
|
||||
val fragment = TaskRecyclerViewFragment()
|
||||
fragment.retainInstance = true
|
||||
fragment.taskType = classType
|
||||
var tutorialTexts: List<String>? = null
|
||||
if (context != null) {
|
||||
|
|
|
|||
|
|
@ -53,7 +53,6 @@ class AutocompleteAdapter(val context: Context, val socialRepository: SocialRepo
|
|||
val result = FindUsernameResult()
|
||||
result.authentication = Authentication()
|
||||
result.authentication?.localAuthentication = LocalAuthentication()
|
||||
result.authentication?.localAuthentication?.userID = message.uuid
|
||||
result.authentication?.localAuthentication?.username = message.username
|
||||
result.contributor = message.contributor
|
||||
result.profile = Profile()
|
||||
|
|
|
|||
|
|
@ -136,17 +136,12 @@ class PetViewHolder(parent: ViewGroup, private val equipEvents: PublishSubject<S
|
|||
}
|
||||
}
|
||||
1 -> {
|
||||
val event = FeedCommand()
|
||||
event.usingPet = animal
|
||||
EventBus.getDefault().post(event)
|
||||
EventBus.getDefault().post(FeedCommand(animal, null))
|
||||
}
|
||||
2 -> {
|
||||
val event = FeedCommand()
|
||||
event.usingPet = animal
|
||||
val saddle = Food()
|
||||
saddle.key = "Saddle"
|
||||
event.usingFood = saddle
|
||||
EventBus.getDefault().post(event)
|
||||
EventBus.getDefault().post(FeedCommand(animal, saddle))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import androidx.core.content.ContextCompat
|
|||
import androidx.core.widget.CompoundButtonCompat
|
||||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.android.habitica.components.UserComponent
|
||||
import com.habitrpg.android.habitica.data.TagRepository
|
||||
import com.habitrpg.android.habitica.extensions.OnChangeTextWatcher
|
||||
import com.habitrpg.android.habitica.extensions.getThemeColor
|
||||
import com.habitrpg.android.habitica.helpers.RxErrorHandler
|
||||
|
|
@ -29,6 +30,9 @@ class TaskFilterDialog(context: Context, component: UserComponent?) : HabiticaAl
|
|||
|
||||
private var clearButton: Button
|
||||
|
||||
@Inject
|
||||
lateinit var repository: TagRepository
|
||||
|
||||
private var taskTypeTitle: TextView
|
||||
private var taskFilters: RadioGroup
|
||||
private var allTaskFilter: RadioButton
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class ChatMessageDeserializer : JsonDeserializer<ChatMessage> {
|
|||
message.likes = RealmList()
|
||||
for ((key, value) in obj.getAsJsonObject("likes").entrySet()) {
|
||||
if (value.asBoolean) {
|
||||
message.likes?.add(ChatMessageLike(key, message.id))
|
||||
message.likes?.add(ChatMessageLike(key))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -49,7 +49,6 @@ class ChatMessageDeserializer : JsonDeserializer<ChatMessage> {
|
|||
contributor.text = obj.get("contributor").asString
|
||||
message.contributor = contributor
|
||||
}
|
||||
message.contributor?.userId = message.id
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -87,6 +87,12 @@ class UserDeserializer : JsonDeserializer<User> {
|
|||
item.numberOwned = user.purchased?.plan?.mysteryItemCount ?: 0
|
||||
user.items?.special?.ownedItems = RealmList()
|
||||
user.items?.special?.ownedItems?.add(item)
|
||||
|
||||
user.items?.hatchingPotions?.forEach { it.itemType = "hatchingPotions" }
|
||||
user.items?.eggs?.forEach { it.itemType = "eggs" }
|
||||
user.items?.food?.forEach { it.itemType = "food" }
|
||||
user.items?.quests?.forEach { it.itemType = "quests" }
|
||||
|
||||
}
|
||||
if (obj.has("auth")) {
|
||||
user.authentication = context.deserialize(obj.get("auth"), Authentication::class.java)
|
||||
|
|
@ -132,9 +138,6 @@ class UserDeserializer : JsonDeserializer<User> {
|
|||
achievements.add(achievement)
|
||||
}
|
||||
user.achievements = achievements
|
||||
for (achievement in user.achievements) {
|
||||
achievement.userId = user.id
|
||||
}
|
||||
}
|
||||
if (obj.has("tasksOrder")) {
|
||||
user.tasksOrder = context.deserialize(obj.get("tasksOrder"), TasksOrder::class.java)
|
||||
|
|
|
|||
Loading…
Reference in a new issue