mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-20 04:39:04 +00:00
deserialize Items and add to Member object
This commit is contained in:
parent
1ae62e723b
commit
3371db97e0
4 changed files with 44 additions and 4 deletions
|
|
@ -365,7 +365,9 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:stretchColumns="0,1">
|
||||
|
||||
<TableRow android:layout_height="wrap_content">
|
||||
<TableRow
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
|
|
@ -377,9 +379,15 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
tools:text="#" />
|
||||
<com.facebook.drawee.view.SimpleDraweeView
|
||||
android:id="@+id/current_pet_drawee"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
fresco:actualImageScaleType="centerCrop"/>>
|
||||
</TableRow>
|
||||
|
||||
<TableRow android:layout_height="wrap_content">
|
||||
<TableRow android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
|
|
@ -391,6 +399,11 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
tools:text="#" />
|
||||
<com.facebook.drawee.view.SimpleDraweeView
|
||||
android:id="@+id/current_mount_drawee"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
fresco:actualImageScaleType="centerCrop"/>
|
||||
</TableRow>
|
||||
</TableLayout>
|
||||
</LinearLayout>
|
||||
|
|
|
|||
|
|
@ -78,6 +78,13 @@ open class Member : RealmObject(), Avatar {
|
|||
authentication.userId = this.id
|
||||
}
|
||||
}
|
||||
var items: Items? = null
|
||||
set(items) {
|
||||
field = items
|
||||
if (items != null && this.id != null && !items.isManaged) {
|
||||
items.userId = this.id
|
||||
}
|
||||
}
|
||||
private var costume: Outfit? = null
|
||||
private var equipped: Outfit? = null
|
||||
|
||||
|
|
@ -92,6 +99,12 @@ open class Member : RealmObject(), Avatar {
|
|||
""
|
||||
} else this.profile?.name ?: ""
|
||||
|
||||
val petsFoundCount: Int
|
||||
get() = this.items?.pets?.size ?: 0
|
||||
|
||||
val mountsTamedCount: Int
|
||||
get() = this.items?.mounts?.size ?: 0
|
||||
|
||||
override fun getPreferences(): MemberPreferences? {
|
||||
return preferences
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import com.habitrpg.android.habitica.models.user.Stats
|
|||
import com.habitrpg.android.habitica.ui.AvatarView
|
||||
import com.habitrpg.android.habitica.ui.AvatarWithBarsViewModel
|
||||
import com.habitrpg.android.habitica.ui.adapter.social.AchievementAdapter
|
||||
import com.habitrpg.android.habitica.ui.helpers.DataBindingUtils
|
||||
import com.habitrpg.android.habitica.ui.helpers.KeyboardUtil
|
||||
import com.habitrpg.android.habitica.ui.helpers.MarkdownParser
|
||||
import com.habitrpg.android.habitica.ui.helpers.bindView
|
||||
|
|
@ -70,6 +71,8 @@ class FullProfileActivity : BaseActivity() {
|
|||
private val fullprofile_scrollview: ScrollView by bindView(R.id.fullprofile_scrollview)
|
||||
private val petsFoundCount: TextView by bindView(R.id.profile_pets_found_count)
|
||||
private val mountsTamedCount: TextView by bindView(R.id.profile_mounts_tamed_count)
|
||||
private val currentPetDrawee: SimpleDraweeView by bindView(R.id.current_pet_drawee)
|
||||
private val currentMountDrawee: SimpleDraweeView by bindView(R.id.current_mount_drawee)
|
||||
private val achievementCard: CardView by bindView(R.id.profile_achievements_card)
|
||||
private val achievementProgress: ProgressBar by bindView(R.id.avatar_achievements_progress)
|
||||
private val achievementGroupList: RecyclerView by bindView(R.id.recyclerView)
|
||||
|
|
@ -162,6 +165,7 @@ class FullProfileActivity : BaseActivity() {
|
|||
private fun updateView(user: Member) {
|
||||
val profile = user.profile ?: return
|
||||
|
||||
updatePetsMountsView(user)
|
||||
userName = profile.name
|
||||
|
||||
title = profile.name
|
||||
|
|
@ -210,13 +214,19 @@ class FullProfileActivity : BaseActivity() {
|
|||
costumeCard.visibility = View.GONE
|
||||
}
|
||||
|
||||
//petsFoundCount.setText(String.valueOf(user.getPetsFoundCount()));
|
||||
//mountsTamedCount.setText(String.valueOf(user.getMountsTamedCount()));
|
||||
|
||||
// Load the members achievements now
|
||||
socialRepository.getMemberAchievements(this.userId).subscribe(Consumer<AchievementResult> { this.fillAchievements(it) }, RxErrorHandler.handleEmptyError())
|
||||
}
|
||||
|
||||
private fun updatePetsMountsView(user: Member) {
|
||||
petsFoundCount.text = user.petsFoundCount.toString()
|
||||
mountsTamedCount.text = user.mountsTamedCount.toString()
|
||||
|
||||
DataBindingUtils.loadImage(this.currentPetDrawee, "Pet-" + user.currentPet)
|
||||
DataBindingUtils.loadImage(this.currentMountDrawee, "Mount_Icon_" + user.currentMount)
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region Attributes
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import com.habitrpg.android.habitica.models.social.UserParty;
|
|||
import com.habitrpg.android.habitica.models.user.Authentication;
|
||||
import com.habitrpg.android.habitica.models.user.ContributorInfo;
|
||||
import com.habitrpg.android.habitica.models.user.Inbox;
|
||||
import com.habitrpg.android.habitica.models.user.Items;
|
||||
import com.habitrpg.android.habitica.models.user.Outfit;
|
||||
import com.habitrpg.android.habitica.models.user.Profile;
|
||||
import com.habitrpg.android.habitica.models.user.Stats;
|
||||
|
|
@ -87,6 +88,9 @@ public class MemberSerialization implements JsonDeserializer<Member> {
|
|||
if (obj.has("loginIncentives")) {
|
||||
member.setLoginIncentives(obj.get("loginIncentives").getAsInt());
|
||||
}
|
||||
if (obj.has("items")) {
|
||||
member.setItems(context.deserialize(obj.get("items"), Items.class));
|
||||
}
|
||||
|
||||
member.setId(member.getId());
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue