Add grade id to equals (#213)

This commit is contained in:
Rafał Borcz 2019-01-12 14:16:59 +01:00 committed by Mikołaj Pich
parent c3d354cd5b
commit c2bcbfaaa9
2 changed files with 9 additions and 8 deletions

View File

@ -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
}

View File

@ -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<GradeDetailsItem.ViewHolder>() {
class GradeDetailsItem(val grade: Grade, private val weightString: String, private val valueColor: Int) :
AbstractFlexibleItem<GradeDetailsItem.ViewHolder>() {
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<IFlexible<*>>, holder: ViewHolder,
position: Int, payloads: MutableList<Any>?) {
override fun bindViewHolder(
adapter: FlexibleAdapter<IFlexible<*>>, holder: ViewHolder,
position: Int, payloads: MutableList<Any>?
) {
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