mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-08-01 03:30:34 +00:00
fix equipment screen. Fixes #846
This commit is contained in:
parent
c591b209e6
commit
8dc3b4a0ac
2 changed files with 17 additions and 8 deletions
|
|
@ -11,7 +11,6 @@ import com.habitrpg.android.habitica.helpers.RxErrorHandler
|
|||
import com.habitrpg.android.habitica.ui.fragments.BaseMainFragment
|
||||
import kotlinx.android.synthetic.main.fragment_equipment_overview.*
|
||||
import rx.functions.Action1
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
import kotlin.collections.HashMap
|
||||
|
||||
|
|
@ -25,11 +24,11 @@ class EquipmentOverviewFragment : BaseMainFragment() {
|
|||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?): View? {
|
||||
super.onCreateView(inflater, container, savedInstanceState)
|
||||
val v = inflater.inflate(R.layout.fragment_equipment_overview, container, false)
|
||||
return inflater.inflate(R.layout.fragment_equipment_overview, container, false)
|
||||
}
|
||||
|
||||
if (this.user == null || !this.user!!.isManaged) {
|
||||
return v
|
||||
}
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
battleGearHeadView.setOnClickListener { displayEquipmentDetailList("head", user?.items?.gear?.equipped?.head, false) }
|
||||
battleGearHeadAccessoryView.setOnClickListener { displayEquipmentDetailList("headAccessory", user?.items?.gear?.equipped?.headAccessory, false) }
|
||||
|
|
@ -49,6 +48,8 @@ class EquipmentOverviewFragment : BaseMainFragment() {
|
|||
costumeWeaponView.setOnClickListener { displayEquipmentDetailList("weapon", user?.items?.gear?.costume?.weapon, true) }
|
||||
costumeShieldView.setOnClickListener { displayEquipmentDetailList("shield", user?.items?.gear?.costume?.shield, true) }
|
||||
|
||||
costumeSwitch.isSelected = user?.preferences?.costume ?: false
|
||||
|
||||
costumeSwitch.setOnCheckedChangeListener { _, isChecked -> userRepository.updateUser(user, "preferences.costume", isChecked).subscribe(Action1 { }, RxErrorHandler.handleEmptyError()) }
|
||||
|
||||
setImageNames()
|
||||
|
|
@ -64,8 +65,6 @@ class EquipmentOverviewFragment : BaseMainFragment() {
|
|||
} else {
|
||||
setEquipmentNames()
|
||||
}
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
private fun setEquipmentNames() {
|
||||
|
|
|
|||
|
|
@ -12,17 +12,27 @@ class EquipmentItemRow(context: Context?, attrs: AttributeSet?) : LinearLayout(c
|
|||
|
||||
var equipmentIdentifier: String? = null
|
||||
set(value) {
|
||||
val imageName = if (equipmentIdentifier != null) "shop_"+equipmentIdentifier else "head_0"
|
||||
field = value
|
||||
val imageName = if (equipmentIdentifier != null && equipmentIdentifier != "") "shop_"+equipmentIdentifier else "head_0"
|
||||
DataBindingUtils.loadImage(imageView, imageName)
|
||||
}
|
||||
|
||||
var customizationIdentifier: String? = null
|
||||
set(value) {
|
||||
field = value
|
||||
val imageName = if (customizationIdentifier != null && customizationIdentifier != "") customizationIdentifier else "head_0"
|
||||
DataBindingUtils.loadImage(imageView, imageName)
|
||||
}
|
||||
|
||||
var equipmentName: String? = ""
|
||||
set(value) {
|
||||
field = value
|
||||
valueTextView.text = equipmentName
|
||||
}
|
||||
|
||||
init {
|
||||
View.inflate(context, R.layout.item_image_row, this)
|
||||
isClickable = true
|
||||
|
||||
val attributes = context?.theme?.obtainStyledAttributes(
|
||||
attrs,
|
||||
|
|
|
|||
Loading…
Reference in a new issue