This commit is contained in:
Benoit Marty 2020-07-10 17:51:57 +02:00
parent 825e21362b
commit 179474b975
1 changed files with 5 additions and 5 deletions

View File

@ -45,7 +45,8 @@ import javax.inject.Inject
* An animated reaction button. * An animated reaction button.
* Displays a String reaction (emoji), with a count, and that can be selected or not (toggle) * Displays a String reaction (emoji), with a count, and that can be selected or not (toggle)
*/ */
class ReactionButton @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, class ReactionButton @JvmOverloads constructor(context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0) defStyleAttr: Int = 0)
: FrameLayout(context, attrs, defStyleAttr), View.OnClickListener, View.OnLongClickListener { : FrameLayout(context, attrs, defStyleAttr), View.OnClickListener, View.OnLongClickListener {
@ -110,9 +111,7 @@ class ReactionButton @JvmOverloads constructor(context: Context, attrs: Attribut
countTextView?.text = TextUtils.formatCountToShortDecimal(reactionCount) countTextView?.text = TextUtils.formatCountToShortDecimal(reactionCount)
// emojiView?.typeface = this.emojiTypeFace ?: Typeface.DEFAULT // emojiView?.typeface = this.emojiTypeFace ?: Typeface.DEFAULT
context.withStyledAttributes(attrs, R.styleable.ReactionButton, defStyleAttr) { context.withStyledAttributes(attrs, R.styleable.ReactionButton, defStyleAttr) {
onDrawable = ContextCompat.getDrawable(context, R.drawable.rounded_rect_shape) onDrawable = ContextCompat.getDrawable(context, R.drawable.rounded_rect_shape)
offDrawable = ContextCompat.getDrawable(context, R.drawable.rounded_rect_shape_off) offDrawable = ContextCompat.getDrawable(context, R.drawable.rounded_rect_shape_off)
@ -143,9 +142,10 @@ class ReactionButton @JvmOverloads constructor(context: Context, attrs: Attribut
val status = getBoolean(R.styleable.ReactionButton_toggled, false) val status = getBoolean(R.styleable.ReactionButton_toggled, false)
setChecked(status) setChecked(status)
setOnClickListener(this@ReactionButton)
setOnLongClickListener(this@ReactionButton)
} }
setOnClickListener(this)
setOnLongClickListener(this)
} }
private fun getDrawableFromResource(array: TypedArray, styleableIndexId: Int): Drawable? { private fun getDrawableFromResource(array: TypedArray, styleableIndexId: Int): Drawable? {