Skip to content

Instantly share code, notes, and snippets.

@boek
Created May 5, 2020 20:06
Show Gist options
  • Select an option

  • Save boek/4d3f4854dfde96d53d3340730c94487f to your computer and use it in GitHub Desktop.

Select an option

Save boek/4d3f4854dfde96d53d3340730c94487f to your computer and use it in GitHub Desktop.
@@ -9,6 +9,7 @@ import android.view.View
import android.widget.ImageView
import android.widget.TextView
import androidx.appcompat.widget.AppCompatImageButton
+import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView
import mozilla.components.browser.tabstray.BrowserTabsTray
import mozilla.components.browser.tabstray.TabViewHolder
@@ -64,24 +65,17 @@ class TabTrayViewHolder(itemView: View) : TabViewHolder(itemView) {
mozac:tabsTraySelectedItemUrlTextColor="?tabTrayItemUrl"
*/
- titleView.setTextColor(
- ThemeManager.resolveAttribute(R.attr.tabTrayItemText, itemView.context)
- )
- urlView?.setTextColor(
- ThemeManager.resolveAttribute(R.attr.tabTrayItemUrl, itemView.context)
- )
- closeView.imageTintList = ColorStateList.valueOf(
- ThemeManager.resolveAttribute(R.attr.tabTrayItemText, itemView.context)
- )
+ val getColor: (Int) -> Int = {
+ ContextCompat.getColor(itemView.context, ThemeManager.resolveAttribute(it, itemView.context))
+ }
+ titleView.setTextColor(getColor(R.attr.tabTrayItemText))
+ urlView?.setTextColor(getColor(R.attr.tabTrayItemUrl))
+ closeView.imageTintList = ColorStateList.valueOf(getColor(R.attr.tabTrayItemText))
if (isSelected) {
- itemView.setBackgroundColor(
- ThemeManager.resolveAttribute(R.attr.tabTrayItemSelectedBackground, itemView.context)
- )
+ itemView.setBackgroundColor(getColor(R.attr.tabTrayItemSelectedBackground))
} else {
- itemView.setBackgroundColor(
- ThemeManager.resolveAttribute(R.attr.tabTrayItemBackground, itemView.context)
- )
+ itemView.setBackgroundColor(getColor(R.attr.tabTrayItemBackground))
}
thumbnailView.setImageBitmap(tab.thumbnail)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment