Skip to content

Commit

Permalink
Feat: Select specific days.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Schreiber committed Sep 14, 2022
1 parent 34b2a93 commit 36308ab
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions pickerlib/src/main/java/com/rohyme/pickerlib/DayPicker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import android.view.ViewGroup.LayoutParams.MATCH_PARENT
import android.widget.LinearLayout
import android.widget.TextView
import java.util.*
import kotlin.collections.ArrayList


class DayPicker : LinearLayout {
Expand Down Expand Up @@ -196,6 +197,30 @@ class DayPicker : LinearLayout {
}
}

/**
* Selects specific days based upon their index.
*
* @param daysList list of day indices
*/
fun selectDays(dayIndexList: ArrayList<Int>) {
dayIndexList.forEach { dayIndex ->
if(daysList.size > dayIndex) {
daysList[dayIndex].isSelected = true
}
if(textItemList.containsKey(dayIndex)) {
textItemList[dayIndex]?.isSelected = true
textItemList[dayIndex]?.configSelection(true)
}
}
}

/**
* Enable or disable this element.
*/
fun enable(enable: Boolean) {
mIsEnabled = enable
}

/**
* Method to get the selected List
*/
Expand Down

0 comments on commit 36308ab

Please sign in to comment.