Skip to content

Commit

Permalink
Replace Redundant call to position - 1
Browse files Browse the repository at this point in the history
Remove manual density pixel calculation
  • Loading branch information
Rajnish23 committed Oct 7, 2020
1 parent 8e0bd15 commit d94c569
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@ class TableDrawerAdapter constructor(private val listener: TableClickListener) :
holder.itemView.setOnClickListener(listener::onHeaderClick)
}
is SectionTableDrawerViewHolder -> {
holder.bind(sections[position - 1])
val titleAdjustedPosition = position - 1
holder.bind(sections[titleAdjustedPosition])
holder.itemView.setOnClickListener {
listener.onSectionClick(it, position - 1)
listener.onSectionClick(it, titleAdjustedPosition)
}
}
else -> {
Expand Down Expand Up @@ -107,10 +108,8 @@ class TableDrawerAdapter constructor(private val listener: TableClickListener) :
item: TableDrawerAdapter.DocumentSection
) {
val context = itemView.context
val density = context.resources.displayMetrics.density
val padding =
((item.level - 1) * context.resources.getDimension(R.dimen.title_text_padding) * density)
.toInt()
((item.level - 1) * context.resources.getDimension(R.dimen.title_text_padding)).toInt()
titleText.setPadding(padding, 0, 0, 0)
titleText.text = item.title
}
Expand Down

0 comments on commit d94c569

Please sign in to comment.