Skip to content

Commit

Permalink
All open functions should call super
Browse files Browse the repository at this point in the history
  • Loading branch information
jahirfiquitiva committed Jun 4, 2018
1 parent 3fc85c0 commit a5a6b3c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions library/src/main/kotlin/com/jahirfiquitiva/chip/ChipView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down

0 comments on commit a5a6b3c

Please sign in to comment.