mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-18 11:49:01 +00:00
Improve wheelchair support
This commit is contained in:
parent
6e83b6c2ca
commit
33fcaa6da5
7 changed files with 17 additions and 4 deletions
|
|
@ -68,6 +68,11 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:id="@+id/avatarSkinView"
|
||||
app:equipmentTitle="@string/avatar_skin"/>
|
||||
<com.habitrpg.android.habitica.ui.views.EquipmentItemRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/avatarChairView"
|
||||
app:equipmentTitle="@string/avatar_wheelchair"/>
|
||||
</LinearLayout>
|
||||
</android.support.v7.widget.CardView>
|
||||
<TextView
|
||||
|
|
|
|||
|
|
@ -165,6 +165,8 @@ public class Customization extends RealmObject {
|
|||
}
|
||||
case "background":
|
||||
return "background_" + this.identifier;
|
||||
case "chair":
|
||||
return "chair_" + identifier;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -367,6 +367,8 @@ class AvatarView : View {
|
|||
private fun getFileName(imageName: String): String {
|
||||
val name = if (FILENAME_MAP.containsKey(imageName)) {
|
||||
FILENAME_MAP[imageName]
|
||||
} else if (imageName.startsWith("handleless")) {
|
||||
"chair_$imageName"
|
||||
} else {
|
||||
imageName
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ class CustomizationRecyclerViewAdapter : RecyclerView.Adapter<RecyclerView.ViewH
|
|||
fun updateOwnership(ownedCustomizations: List<String>) {
|
||||
for ((position, obj) in customizationList.withIndex()) {
|
||||
if (obj.javaClass == Customization::class.java) {
|
||||
val customization = obj as Customization
|
||||
val customization = obj as? Customization ?: return
|
||||
if (customization.purchased != ownedCustomizations.contains(customization.id)) {
|
||||
customization.purchased = ownedCustomizations.contains(customization.id)
|
||||
notifyItemChanged(position)
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ class AvatarOverviewFragment : BaseMainFragment(), AdapterView.OnItemSelectedLis
|
|||
|
||||
avatarShirtView.setOnClickListener { displayCustomizationFragment("shirt", null) }
|
||||
avatarSkinView.setOnClickListener { displayCustomizationFragment("skin", null) }
|
||||
avatarChairView.setOnClickListener { displayCustomizationFragment("chair", null) }
|
||||
avatarHairColorView.setOnClickListener { displayCustomizationFragment("hair", "color") }
|
||||
avatarHairBangsView.setOnClickListener { displayCustomizationFragment("hair", "bangs") }
|
||||
avatarHairBaseView.setOnClickListener { displayCustomizationFragment("hair", "base") }
|
||||
|
|
@ -54,6 +55,9 @@ class AvatarOverviewFragment : BaseMainFragment(), AdapterView.OnItemSelectedLis
|
|||
avatarShirtView.equipmentName = user?.preferences?.shirt
|
||||
avatarSkinView.customizationIdentifier = "skin_" + user?.preferences?.skin
|
||||
avatarSkinView.equipmentName = user?.preferences?.skin
|
||||
val chair = user?.preferences?.chair
|
||||
avatarChairView.customizationIdentifier = if (chair?.startsWith("handleless") == true) "chair_$chair" else chair
|
||||
avatarChairView.equipmentName = chair?.removePrefix("chair_")
|
||||
avatarHairColorView.customizationIdentifier = if (user?.preferences?.hair?.color != null && user?.preferences?.hair?.color != "") "hair_bangs_1_" + user?.preferences?.hair?.color else ""
|
||||
avatarHairColorView.equipmentName = user?.preferences?.hair?.color
|
||||
avatarHairBangsView.customizationIdentifier = if (user?.preferences?.hair?.bangs != null && user?.preferences?.hair?.bangs != 0) "hair_bangs_" + user?.preferences?.hair?.bangs + "_" + user?.preferences?.hair?.color else ""
|
||||
|
|
@ -100,7 +104,7 @@ class AvatarOverviewFragment : BaseMainFragment(), AdapterView.OnItemSelectedLis
|
|||
override fun onItemSelected(parent: AdapterView<*>, view: View, position: Int, id: Long) {
|
||||
val newSize: String = if (position == 0) "slim" else "broad"
|
||||
|
||||
if (this.user != null && this.user!!.preferences?.size != newSize) {
|
||||
if (this.user != null && this.user?.preferences?.size != newSize) {
|
||||
userRepository.updateUser(user, "preferences.size", newSize)
|
||||
.subscribe(Consumer { }, RxErrorHandler.handleEmptyError())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class NPCBannerView(context: Context?, attrs: AttributeSet?) : FrameLayout(conte
|
|||
field = if (value.isEmpty() || value.startsWith("_")) {
|
||||
value
|
||||
} else {
|
||||
"_"+value
|
||||
"_$value"
|
||||
}
|
||||
if (identifier.isNotEmpty()) {
|
||||
setImage()
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ public class CustomizationDeserializer implements JsonDeserializer<List<Customiz
|
|||
}
|
||||
}
|
||||
|
||||
for (String type : Arrays.asList("shirt", "skin")) {
|
||||
for (String type : Arrays.asList("shirt", "skin", "chair")) {
|
||||
for (Map.Entry<String, JsonElement> entry : object.get(type).getAsJsonObject().entrySet()) {
|
||||
customizations.add(this.parseCustomization(null, type, null, entry.getKey(), entry.getValue().getAsJsonObject()));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue