Skip to content

Commit 4c3072e

Browse files
committed
Add drawable support to text option adapter
1 parent bddeb0b commit 4c3072e

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ publish {
3636
userOrg = 'buffer'
3737
groupId = 'org.buffer.android'
3838
artifactId = 'android-components'
39-
publishVersion = '0.19'
39+
publishVersion = '1.0'
4040
desc = 'An Android library for frequently used UI components'
4141
website = 'https://github.com/bufferapp/android-components'
4242
}

app/src/main/java/org/buffer/android/components/TextOptionAdapter.kt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@ package org.buffer.android.components
22

33
import android.buffer.org.ui_kit.R
44
import android.content.Context
5+
import android.graphics.drawable.Drawable
56
import android.view.View
67
import android.view.ViewGroup
78
import android.widget.ArrayAdapter
89
import android.widget.TextView
910

1011
open class TextOptionAdapter(
1112
context: Context,
12-
private val values: Array<String>
13+
private val values: Array<String>,
14+
private val icons: Array<Drawable>? = null
1315
) : ArrayAdapter<String>(context, R.layout.item_share_option, values) {
1416

1517
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
@@ -22,7 +24,16 @@ open class TextOptionAdapter(
2224
} else {
2325
optionViewHolder = shareOptionRow.tag as OptionViewHolder
2426
}
25-
optionViewHolder.optionText.text = values[position]
27+
28+
optionViewHolder.optionText.apply {
29+
text = values[position]
30+
icons?.let {
31+
setCompoundDrawablesWithIntrinsicBounds(
32+
it[position], null, null, null
33+
)
34+
compoundDrawablePadding = DisplayMetricsUtil.dpToPx(16)
35+
}
36+
}
2637
return shareOptionRow!!
2738
}
2839

0 commit comments

Comments
 (0)