Skip to content

Commit

Permalink
Rename methods
Browse files Browse the repository at this point in the history
  • Loading branch information
maxkeppeler committed Jan 16, 2021
1 parent 4b2f8df commit 7015828
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class CalendarSheet : Sheet() {
private var selectedDate: LocalDate? = null
private var selectedDateStart: LocalDate? = null
private var selectedDateEnd: LocalDate? = null
private var showButtons = true
private var displayButtons = true

/** Disable timeline into past or future. */
fun disableTimeline(timeLine: TimeLine) {
Expand Down Expand Up @@ -181,9 +181,9 @@ class CalendarSheet : Sheet() {
this.disabledDates.add(disabledDate)
}

/** Show buttons and require a positive button click. */
fun showButtons(showButtons: Boolean = true) {
this.showButtons = showButtons
/** Display buttons and require a positive button click. */
fun displayButtons(displayButtons: Boolean = true) {
this.displayButtons = displayButtons
}

/**
Expand Down Expand Up @@ -250,7 +250,7 @@ class CalendarSheet : Sheet() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
setButtonPositiveListener(::save)
displayButtonsView(showButtons)
displayButtonsView(displayButtons)
validate()
initResources()
with(binding) {
Expand Down Expand Up @@ -794,7 +794,7 @@ class CalendarSheet : Sheet() {
val selectionValid = selectionMode == SelectionMode.RANGE && selectionInRange
|| selectionMode == SelectionMode.DATE && selectedDate != null

if (!showButtons && selectionValid) {
if (!displayButtons && selectionValid) {
Handler(Looper.getMainLooper()).postDelayed({
save()
}, 600)
Expand Down Expand Up @@ -830,7 +830,7 @@ class CalendarSheet : Sheet() {
calendarMode = saved.getSerializable(STATE_CALENDAR_MODE) as CalendarMode
maxRange = saved.getInt(STATE_MAX_RANGE)
rangeYears = saved.getInt(STATE_RANGE_YEARS)
showButtons = saved.getBoolean(STATE_DISPLAY_BUTTONS)
displayButtons = saved.getBoolean(STATE_DISPLAY_BUTTONS)
repeat(saved.getInt(STATE_DISABLE_DATE)) {
val inputItem = saved.getSerializable(STATE_DISABLE_DATE.plus(it)) as Calendar
disabledDates.add(inputItem)
Expand All @@ -850,7 +850,7 @@ class CalendarSheet : Sheet() {
putSerializable(STATE_CALENDAR_MODE, calendarMode as Serializable?)
putInt(STATE_MAX_RANGE, maxRange)
putInt(STATE_RANGE_YEARS, rangeYears)
putBoolean(STATE_DISPLAY_BUTTONS, showButtons)
putBoolean(STATE_DISPLAY_BUTTONS, displayButtons)
disabledDates.forEachIndexed { i, date ->
putSerializable(STATE_DISABLE_DATE.plus(i), date)
}
Expand Down
10 changes: 5 additions & 5 deletions info/src/main/java/com/maxkeppeler/sheets/info/InfoSheet.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class InfoSheet : Sheet() {
private lateinit var binding: SheetsInfoBinding

private var contentText: String? = null
private var showButtons = true
private var displayButtons = true

@DrawableRes
private var drawableRes: Int? = null
Expand Down Expand Up @@ -161,17 +161,17 @@ class InfoSheet : Sheet() {
this.positiveListener = positiveListener
}

/** Show buttons and require a positive button click. */
fun showButtons(showButtons: Boolean = true) {
this.showButtons = showButtons
/** Display buttons and require a positive button click. */
fun displayButtons(displayButtons: Boolean = true) {
this.displayButtons = displayButtons
}

override fun onCreateLayoutView(): View =
SheetsInfoBinding.inflate(LayoutInflater.from(activity)).also { binding = it }.root

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
displayButtonsView(showButtons)
displayButtonsView(displayButtons)
with(binding) {
contentText?.let { content.text = it }
drawableRes?.let { res ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class OptionsSheet : Sheet() {
private var minChoices: Int? = null
private var maxChoices: Int? = null
private var maxChoicesStrict = true
private var showButtons = false
private var displayButtons = false

private val saveAllowed: Boolean
get() {
Expand Down Expand Up @@ -128,9 +128,9 @@ class OptionsSheet : Sheet() {
this.maxChoices = maxChoices
}

/** Show buttons and require a positive button click. */
fun showButtons(showButtons: Boolean = true) {
this.showButtons = showButtons
/** Display buttons and require a positive button click. */
fun displayButtons(displayButtons: Boolean = true) {
this.displayButtons = displayButtons
}

/** Set display mode. */
Expand Down Expand Up @@ -298,7 +298,7 @@ class OptionsSheet : Sheet() {
private val adapterListener = object : OptionsSelectionListener {

override fun select(index: Int) {
if (showButtons) {
if (displayButtons) {
optionsSelected.clear()
optionsSelected.add(index)
validate()
Expand Down Expand Up @@ -338,7 +338,7 @@ class OptionsSheet : Sheet() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
checkSetup()
displayButtonsView(multipleChoices || showButtons)
displayButtonsView(multipleChoices || displayButtons)
setButtonPositiveListener(::save)

colorActive = getPrimaryColor(requireContext())
Expand Down Expand Up @@ -518,7 +518,7 @@ class OptionsSheet : Sheet() {
multipleChoices = saved.getBoolean(STATE_MULTIPLE_CHOICES)
displayMultipleChoicesInfo = saved.getBoolean(STATE_MULTIPLE_CHOICES_INFO)
maxChoicesStrict = saved.getBoolean(STATE_MAX_CHOICES_STRICT)
showButtons = saved.getBoolean(STATE_DISPLAY_BUTTONS)
displayButtons = saved.getBoolean(STATE_DISPLAY_BUTTONS)
minChoices = saved.get(STATE_MIN_CHOICES) as Int?
maxChoices = saved.get(STATE_MAX_CHOICES) as Int?
}
Expand All @@ -537,7 +537,7 @@ class OptionsSheet : Sheet() {
putBoolean(STATE_MULTIPLE_CHOICES, multipleChoices)
putBoolean(STATE_MULTIPLE_CHOICES_INFO, displayMultipleChoicesInfo)
putBoolean(STATE_MAX_CHOICES_STRICT, maxChoicesStrict)
putBoolean(STATE_DISPLAY_BUTTONS, showButtons)
putBoolean(STATE_DISPLAY_BUTTONS, displayButtons)
minChoices?.let { putInt(STATE_MIN_CHOICES, it) }
maxChoices?.let { putInt(STATE_MAX_CHOICES, it) }
}
Expand Down
4 changes: 2 additions & 2 deletions sample/src/main/java/com/maxkeppeler/sample/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ class MainActivity : AppCompatActivity() {
cornerRadius(16f)
title("Note from 27th dec") // Set the title of the sheet
if (Random.nextBoolean()) {
showButtons() // For single choice, no buttons are displayed, except you enforce to display them
displayButtons() // For single choice, no buttons are displayed, except you enforce to display them
}
with( // Add options
Option(R.drawable.ic_send, "Send"),
Expand Down Expand Up @@ -638,7 +638,7 @@ class MainActivity : AppCompatActivity() {
private fun showInfoSheetTopStyleMixed() {

InfoSheet().show(this) {
showButtons(false)
displayButtons(false)
style(SheetStyle.values().random())
cornerFamily(CornerFamily.CUT)
topStyle(TopStyle.MIXED)
Expand Down

0 comments on commit 7015828

Please sign in to comment.