Refactor View.selected usage to View.activated

The View documentation recommends using activated to indicate whether or not a view is selected: https://developer.android.com/reference/android/view/View#setActivated(boolean)
This commit is contained in:
Moez Bhatti
2018-08-14 16:49:44 +02:00
parent a646291c51
commit 7be398ee06
8 changed files with 19 additions and 19 deletions
@@ -67,8 +67,8 @@ class MenuItemAdapter @Inject constructor(private val context: Context, private
val view = layoutInflater.inflate(R.layout.menu_list_item, parent, false)
val states = arrayOf(
intArrayOf(android.R.attr.state_selected),
intArrayOf(-android.R.attr.state_selected))
intArrayOf(android.R.attr.state_activated),
intArrayOf(-android.R.attr.state_activated))
val text = parent.context.resolveThemeColor(android.R.attr.textColorTertiary)
view.check.imageTintList = ColorStateList(states, intArrayOf(colors.theme().theme, text))
@@ -86,7 +86,7 @@ class MenuItemAdapter @Inject constructor(private val context: Context, private
val view = holder.itemView
view.title.text = menuItem.title
view.check.isSelected = (menuItem.actionId == selectedItem)
view.check.isActivated = (menuItem.actionId == selectedItem)
view.check.setVisible(selectedItem != null)
}
@@ -71,13 +71,13 @@ class PagerTitleView @JvmOverloads constructor(context: Context, attrs: Attribut
}
childCount.forEach { index ->
getChildAt(index).isSelected = index == pager?.currentItem
getChildAt(index).isActivated = index == pager?.currentItem
}
pager?.addOnPageChangeListener(object : ViewPager.SimpleOnPageChangeListener() {
override fun onPageSelected(position: Int) {
childCount.forEach { index ->
getChildAt(index).isSelected = index == position
getChildAt(index).isActivated = index == position
}
}
})
@@ -87,8 +87,8 @@ class PagerTitleView @JvmOverloads constructor(context: Context, attrs: Attribut
super.onAttachedToWindow()
val states = arrayOf(
intArrayOf(android.R.attr.state_selected),
intArrayOf(-android.R.attr.state_selected))
intArrayOf(android.R.attr.state_activated),
intArrayOf(-android.R.attr.state_activated))
threadId
.distinctUntilChanged()