Add SeparatorViewHolder

pull/1012/head
Alex Baker 4 years ago
parent 6487180e38
commit efa663f444

@ -77,7 +77,7 @@ class FilterAdapter @Inject constructor(
newView.tag = when (viewType) {
ITEM -> FilterViewHolder(
newView, false, locale, activity, inventory, colorProvider, null)
SEPARATOR -> FilterViewHolder(newView)
SEPARATOR -> SeparatorViewHolder(newView)
SUBHEADER -> SubheaderViewHolder(
newView,
activity,

@ -17,7 +17,15 @@ import org.tasks.themes.ColorProvider
import org.tasks.themes.CustomIcons.getIconResId
import org.tasks.themes.DrawableUtil
class FilterViewHolder : RecyclerView.ViewHolder {
class FilterViewHolder internal constructor(
itemView: View,
private val navigationDrawer: Boolean,
private val locale: Locale,
private val activity: Activity,
private val inventory: Inventory,
private val colorProvider: ColorProvider,
private val onClick: ((FilterListItem?) -> Unit)?) : RecyclerView.ViewHolder(itemView) {
@BindView(R.id.row)
lateinit var row: View
@ -30,35 +38,13 @@ class FilterViewHolder : RecyclerView.ViewHolder {
@BindView(R.id.size)
lateinit var size: TextView
private var onClick: ((FilterListItem?) -> Unit)? = null
private var navigationDrawer = false
private var locale: Locale? = null
private var activity: Activity? = null
private var inventory: Inventory? = null
private var colorProvider: ColorProvider? = null
internal constructor(
itemView: View,
navigationDrawer: Boolean,
locale: Locale,
activity: Activity,
inventory: Inventory,
colorProvider: ColorProvider,
onClick: ((FilterListItem?) -> Unit)?) : super(itemView) {
this.inventory = inventory
this.colorProvider = colorProvider
init {
ButterKnife.bind(this, itemView)
this.navigationDrawer = navigationDrawer
this.locale = locale
this.activity = activity
this.onClick = onClick
if (navigationDrawer) {
text.checkMarkDrawable = null
}
}
internal constructor(itemView: View) : super(itemView)
fun bind(filter: FilterListItem, selected: Boolean, count: Int?) {
if (navigationDrawer) {
itemView.isSelected = selected
@ -72,28 +58,28 @@ class FilterViewHolder : RecyclerView.ViewHolder {
if (count == null || count == 0) {
size.visibility = View.GONE
} else {
size.text = locale!!.formatNumber(count)
size.text = locale.formatNumber(count)
size.visibility = View.VISIBLE
}
if (onClick != null) {
row.setOnClickListener {
onClick?.invoke(filter)
onClick.invoke(filter)
}
}
}
private fun getColor(filter: FilterListItem): Int {
if (filter.tint != 0) {
val color = colorProvider!!.getThemeColor(filter.tint, true)
if (color.isFree || inventory!!.purchasedThemes()) {
val color = colorProvider.getThemeColor(filter.tint, true)
if (color.isFree || inventory.purchasedThemes()) {
return color.primaryColor
}
}
return activity!!.getColor(R.color.text_primary)
return activity.getColor(R.color.text_primary)
}
private fun getIcon(filter: FilterListItem): Int {
if (filter.icon < 1000 || inventory!!.hasPro()) {
if (filter.icon < 1000 || inventory.hasPro()) {
val icon = getIconResId(filter.icon)
if (icon != null) {
return icon

@ -69,7 +69,7 @@ class NavigationDrawerAdapter @Inject constructor(
view, true, locale, activity, inventory, colorProvider) { filter: FilterListItem? -> onClickFilter(filter) }
FilterListItem.Type.SUBHEADER -> SubheaderViewHolder(
view, activity, preferences, googleTaskDao, caldavDao, localBroadcastManager)
else -> FilterViewHolder(view)
else -> SeparatorViewHolder(view)
}
}

@ -0,0 +1,6 @@
package com.todoroo.astrid.adapter
import android.view.View
import androidx.recyclerview.widget.RecyclerView
class SeparatorViewHolder internal constructor(itemView: View) : RecyclerView.ViewHolder(itemView)
Loading…
Cancel
Save