Browse Source

Resize native radios icons to be more legible.

housekeeping/remove-warnings
Antoine POPINEAU 4 years ago
parent
commit
80554796d3
No known key found for this signature in database
GPG Key ID: A78AC64694F84063
  1. 27
      app/src/main/java/com/github/apognu/otter/adapters/RadiosAdapter.kt
  2. 10
      app/src/main/res/layout/row_radio.xml

27
app/src/main/java/com/github/apognu/otter/adapters/RadiosAdapter.kt

@ -30,26 +30,31 @@ class RadiosAdapter(val context: Context?, private val listener: OnRadioClickLis @@ -30,26 +30,31 @@ class RadiosAdapter(val context: Context?, private val listener: OnRadioClickLis
override fun onBindViewHolder(holder: RadiosAdapter.ViewHolder, position: Int) {
val radio = data[position]
holder.art.visibility = View.VISIBLE
holder.nativeArt.visibility = View.GONE
holder.name.text = radio.name
holder.description.text = radio.description
context?.let { context ->
when (radio.radio_type) {
"random" -> {
holder.art.setImageDrawable(context.getDrawable(R.drawable.shuffle))
holder.art.alpha = 0.7f
holder.art.setColorFilter(context.getColor(R.color.controlForeground))
}
"less-listened" -> {
holder.art.setImageDrawable(context.getDrawable(R.drawable.sad))
holder.art.alpha = 0.7f
holder.art.setColorFilter(context.getColor(R.color.controlForeground))
}
val icon = when (radio.radio_type) {
"random" -> R.drawable.shuffle
"less-listened" -> R.drawable.sad
else -> null
}
icon?.let {
holder.art.visibility = View.GONE
holder.nativeArt.visibility = View.VISIBLE
holder.nativeArt.setImageDrawable(context.getDrawable(icon))
holder.nativeArt.alpha = 0.7f
holder.nativeArt.setColorFilter(context.getColor(R.color.controlForeground))
}
}
}
inner class ViewHolder(view: View, private val listener: OnRadioClickListener) : RecyclerView.ViewHolder(view), View.OnClickListener {
val nativeArt = view.native_art
val art = view.art
val name = view.name
val description = view.description

10
app/src/main/res/layout/row_radio.xml

@ -13,6 +13,16 @@ @@ -13,6 +13,16 @@
android:transitionGroup="true"
tools:showIn="@layout/fragment_radios">
<ImageView
android:id="@+id/native_art"
android:layout_width="48dp"
android:layout_height="32dp"
android:layout_marginEnd="16dp"
android:scaleType="fitCenter"
android:src="@drawable/cover"
android:visibility="gone"
tools:src="@tools:sample/avatars" />
<com.github.apognu.otter.views.SquareImageView
android:id="@+id/art"
android:layout_width="48dp"

Loading…
Cancel
Save