From c2bcbfaaa9a635bbc4e03a9d86e219913b743f27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Borcz?= Date: Sat, 12 Jan 2019 14:16:59 +0100 Subject: [PATCH] Add grade id to equals (#213) --- .../modules/grade/details/GradeDetailsHeader.kt | 2 -- .../ui/modules/grade/details/GradeDetailsItem.kt | 15 +++++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsHeader.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsHeader.kt index b58ac8c9..0515208e 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsHeader.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsHeader.kt @@ -52,7 +52,6 @@ class GradeDetailsHeader( if (subject != other.subject) return false if (number != other.number) return false if (average != other.average) return false - if (newGrades != other.newGrades) return false if (isExpandable != other.isExpandable) return false return true @@ -62,7 +61,6 @@ class GradeDetailsHeader( var result = subject.hashCode() result = 31 * result + number.hashCode() result = 31 * result + average.hashCode() - result = 31 * result + newGrades result = 31 * result + isExpandable.hashCode() return result } diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsItem.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsItem.kt index 18c2656d..e522a780 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsItem.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsItem.kt @@ -14,8 +14,8 @@ import io.github.wulkanowy.utils.toFormattedString import kotlinx.android.extensions.LayoutContainer import kotlinx.android.synthetic.main.item_grade_details.* -class GradeDetailsItem(val grade: Grade, private val weightString: String, private val valueColor: Int) - : AbstractFlexibleItem() { +class GradeDetailsItem(val grade: Grade, private val weightString: String, private val valueColor: Int) : + AbstractFlexibleItem() { override fun getLayoutRes() = R.layout.item_grade_details @@ -24,8 +24,10 @@ class GradeDetailsItem(val grade: Grade, private val weightString: String, priva } @SuppressLint("SetTextI18n") - override fun bindViewHolder(adapter: FlexibleAdapter>, holder: ViewHolder, - position: Int, payloads: MutableList?) { + override fun bindViewHolder( + adapter: FlexibleAdapter>, holder: ViewHolder, + position: Int, payloads: MutableList? + ) { holder.run { gradeItemValue.run { text = grade.entry @@ -45,6 +47,7 @@ class GradeDetailsItem(val grade: Grade, private val weightString: String, priva other as GradeDetailsItem if (grade != other.grade) return false + if (grade.id != other.grade.id) return false if (weightString != other.weightString) return false if (valueColor != other.valueColor) return false @@ -53,14 +56,14 @@ class GradeDetailsItem(val grade: Grade, private val weightString: String, priva override fun hashCode(): Int { var result = grade.hashCode() + result = 31 * result + grade.id.toInt() result = 31 * result + weightString.hashCode() result = 31 * result + valueColor return result } - class ViewHolder(view: View, adapter: FlexibleAdapter<*>) : FlexibleViewHolder(view, adapter), - LayoutContainer { + LayoutContainer { override val containerView: View get() = contentView