From a5a6b3cb7370858761eab817d0c8e92f4cb5ba91 Mon Sep 17 00:00:00 2001 From: jahirfiquitiva Date: Mon, 4 Jun 2018 12:03:43 -0500 Subject: [PATCH] All open functions should call super --- .../main/kotlin/com/jahirfiquitiva/chip/ChipView.kt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/library/src/main/kotlin/com/jahirfiquitiva/chip/ChipView.kt b/library/src/main/kotlin/com/jahirfiquitiva/chip/ChipView.kt index 00c297a..3c7b31d 100644 --- a/library/src/main/kotlin/com/jahirfiquitiva/chip/ChipView.kt +++ b/library/src/main/kotlin/com/jahirfiquitiva/chip/ChipView.kt @@ -136,58 +136,71 @@ open class ChipView : LinearLayout { chipRoot?.setPadding(left, top, right, bottom) } + @CallSuper open fun setText(@StringRes res: Int) { text = context.getString(res) } + @CallSuper open fun setTextColorFromRes(@ColorRes res: Int) { textView?.setTextColor(ContextCompat.getColor(context, res)) } + @CallSuper open fun setTextColor(color: Int) { textView?.setTextColor(color) } + @CallSuper open fun setTextColor(colors: ColorStateList) { textView?.setTextColor(colors) } + @CallSuper open fun setIcon(@DrawableRes drawable: Int) { setIcon(ContextCompat.getDrawable(context, drawable)) } + @CallSuper open fun setIcon(drawable: Drawable?) { iconView?.setImageDrawable(drawable) iconView?.visibility = if (drawable != null) View.VISIBLE else View.GONE } + @CallSuper open fun setIcon(bitmap: Bitmap?) { iconView?.setImageBitmap(bitmap) } @RequiresApi(Build.VERSION_CODES.M) + @CallSuper open fun setIcon(icon: Icon?) { iconView?.setImageIcon(icon) } + @CallSuper open fun setActionIcon(@DrawableRes drawable: Int) { setActionIcon(ContextCompat.getDrawable(context, drawable)) } + @CallSuper open fun setActionIcon(drawable: Drawable?) { actionIconView?.setImageDrawable(drawable) actionIconView?.visibility = if (drawable != null) View.VISIBLE else View.GONE } + @CallSuper open fun setActionIcon(bitmap: Bitmap?) { actionIconView?.setImageBitmap(bitmap) } @RequiresApi(Build.VERSION_CODES.M) + @CallSuper open fun setActionIcon(actionIcon: Icon?) { actionIconView?.setImageIcon(actionIcon) } + @CallSuper open fun setBackgroundColorFromRes(@ColorRes color: Int) { setBackgroundColor(ContextCompat.getColor(context, color)) }