Commit fcc27fbf authored by SusanneFischer's avatar SusanneFischer
Browse files

fixes, database component structure change,

parent 3f678637
......@@ -39,13 +39,23 @@ class RentalItemChoiceAdapter(
.placeholder(R.drawable.placeholder)
.into(holder.itemBinding.itemImageView)
holder.isSelected = selectedItems?.contains(model) == true
var colorResId = if (selectedItems?.contains(model) == true) {
R.color.colorSecondaryLight
} else {
R.color.surface
}
holder.itemBinding.itemChoiceCard.setCardBackgroundColor(
holder.itemView.context.getColor(colorResId)
)
holder.itemBinding.itemImageView.setOnClickListener {
holder.isSelected = !holder.isSelected
val colorResId: Int = if (holder.isSelected) {
selectItem.invoke(model, true)
selectItem.invoke(model, holder.isSelected)
colorResId = if (holder.isSelected) {
R.color.colorSecondaryLight
} else {
selectItem.invoke(model, false)
R.color.surface
}
......@@ -57,15 +67,6 @@ class RentalItemChoiceAdapter(
holder.itemBinding.itemInformationButton.setOnClickListener {
showBottomSheetDialog.invoke(model)
}
val colorResId = if (selectedItems?.contains(model) == true) {
R.color.colorSecondaryLight
} else {
R.color.surface
}
holder.itemBinding.itemChoiceCard.setCardBackgroundColor(
holder.itemView.context.getColor(colorResId)
)
}
fun resetSelectedItems(items: ArrayList<RentalObject>): RentalItemChoiceAdapter {
......@@ -76,7 +77,7 @@ class RentalItemChoiceAdapter(
class ViewHolder(val itemBinding: RowItemChoiceBinding) :
RecyclerView.ViewHolder(itemBinding.root) {
var isSelected = false
var isSelected: Boolean = false
}
companion object {
......
......@@ -6,14 +6,14 @@ class RentalObject() {
var description: String? = null
var picture_name: String? = null
var quantity: Int? = null
var components: MutableMap<String, MutableMap<String, Any>>? = null
var components: MutableMap<String, Int>? = null
constructor(
name: String?,
description: String?,
picture_name: String?,
quantity: Int?,
components: MutableMap<String, MutableMap<String, Any>>?
components: MutableMap<String, Int>?
) : this() {
this.name = name
this.description = description
......
......@@ -14,9 +14,11 @@ class NewRentalViewModel : ViewModel() {
fun addRentalObject(rentalObject: RentalObject) {
val list = getObjectList()
list?.add(rentalObject)
list?.sortBy { it.name }
mutableObjects.value = list
if (list?.contains(rentalObject) == false) {
list.add(rentalObject)
list.sortBy { it.name }
mutableObjects.value = list
}
}
fun removeRentalObject(rentalObject: RentalObject) {
......
......@@ -49,6 +49,9 @@
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginBottom="8dp"
android:nestedScrollingEnabled="false"
android:overScrollMode="never"
android:scrollbars="none"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment