Skip to content

Commit

Permalink
Feat: Added enabling/disabling
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Schreiber committed Sep 14, 2022
1 parent 0941a4d commit dd32009
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pickerlib/src/main/java/com/rohyme/pickerlib/DayPicker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class DayPicker : LinearLayout {
private var mTextSize = resources.getDimension(R.dimen.text_size)
private var mTextSelectedColor = 0
private var mTextUnSelectedColor = 0
private var mIsEnabled: Boolean = false

constructor(context: Context) : super(context)

Expand All @@ -47,7 +48,7 @@ class DayPicker : LinearLayout {
fun setAttrs(attrs: AttributeSet?) {
val typedArray = context.theme.obtainStyledAttributes(attrs, R.styleable.dayPicker, 0, 0)
try {
isEnabled = typedArray.getBoolean(R.styleable.dayPicker_dp_enabled, true)
mIsEnabled = typedArray.getBoolean(R.styleable.dayPicker_dp_enabled, true)
isSelectedByDefault = typedArray.getBoolean(R.styleable.dayPicker_dp_default_selection, true)
selectedColor = typedArray.getInt(
R.styleable.dayPicker_dp_selected_color,
Expand Down Expand Up @@ -129,7 +130,7 @@ class DayPicker : LinearLayout {
this.background = resources.getDrawable(R.drawable.day_bg)
configSelection(day.isSelected)
setOnClickListener {
if(!isEnabled) return@setOnClickListener
if(!mIsEnabled) return@setOnClickListener

day.isSelected = !day.isSelected
if (this@DayPicker::selectionListener.isInitialized) {
Expand Down

0 comments on commit dd32009

Please sign in to comment.