Skip to content

Android library for easy selection of date range on selection bar.

License

Notifications You must be signed in to change notification settings

banmarkovic/DateRangeSelectionBar

Repository files navigation

DateRangeSelectionBar

Android library for easy selection of date range on selection bar. Date range could be selected by scrolling or clicking on the date range shown next to focused one.

date_range_selection_bar_example_11

Implementation

implementation 'com.github.banmarkovic:DateRangeSelectionBar:0.1.3'

XML attributes

app:drsTextSize="16sp"

app:drsTextColor="@android:color/white"

app:drsUnderlineColor="@android:color/white"

app:drsVerticalPadding="14dp"

Example

For receiving the dates of selected date range in selection bar, you need to pass instance of

DateRangeSelectionBar.DRSOnTimePeriodSelectListener interface in DateRangeSelectionBar view.

private val onTimePeriodSelectListener = object: DateRangeSelectionBar.DRSOnTimePeriodSelectListener {
    override fun onDatePeriodSelected(datePeriod: DRSDatePeriod) {
        Toast.makeText(this@MainActivity, "${datePeriod.startDate} - ${datePeriod.endDate}", Toast.LENGTH_SHORT).show()
    }
}

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)

    dateRangeSelectionBar.setCurrentShownTimePeriodType(DRSDatePeriodType.DRSMonthlyType)
    dateRangeSelectionBar.onTimePeriodSelectListener = onTimePeriodSelectListener
    dateRangeSelectionBar.allowFutureDates = true
}

Configuration changes by code

Change the date period type shown in selection bar (default is DRSDatePeriodType.DRSMonthlyType).

Set DateRangeSelectionBar.DRSOnTimePeriodSelectListener listener.

Enable showing of future dates (default is true).

Four types of date range could be shown in selection bar:

DRSDatePeriodType.DRSDailyType //Days

DRSDatePeriodType.DRSWeeklyType //Weeks

DRSDatePeriodType.DRSMonthlyType //Months

DRSDatePeriodType.DRSYearlyType //Years

About

Android library for easy selection of date range on selection bar.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages