make drawable optional

This commit is contained in:
Bnyro 2022-09-10 16:56:17 +02:00
parent 45c04a0af6
commit 437438fd56
4 changed files with 5 additions and 7 deletions

View File

@ -1,6 +1,7 @@
package com.github.libretube.adapters
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.databinding.BottomSheetItemBinding
@ -23,7 +24,7 @@ class BottomSheetAdapter(
val item = items[position]
holder.binding.apply {
title.text = if (item.currentValue != null) "${item.title} (${item.currentValue})" else item.title
drawable.setImageResource(item.drawable)
if (item.drawable != null) drawable.setImageResource(item.drawable) else drawable.visibility = View.GONE
root.setOnClickListener {
listener.invoke(position)

View File

@ -110,10 +110,7 @@ class SubscriptionsFragment : BaseFragment() {
val sortOptionValues = resources.getStringArray(R.array.sortOptionsValues)
val items = mutableListOf<BottomSheetItem>()
sortOptions.forEach {
items += BottomSheetItem(
it,
R.drawable.ic_arrow_down
)
items += BottomSheetItem(it)
}
val bottomSheet = BottomSheet().apply {

View File

@ -2,6 +2,6 @@ package com.github.libretube.obj
data class BottomSheetItem(
val title: String,
val drawable: Int,
val drawable: Int? = null,
val currentValue: String? = null
)

View File

@ -11,7 +11,7 @@
android:id="@+id/drawable"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="5dp"
android:layout_marginEnd="10dp"
tools:src="@drawable/ic_download" />
<TextView