Skip to content

Commit

Permalink
Use latest Kotlin's features (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
mars885 authored Aug 4, 2024
1 parent cb0bd42 commit 97bad65
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ Let's see how we can do that by following the steps listed above:


private fun getPickerItems(): List<Item> {
return mutableListOf<Item>().apply {
return buildList {
for(number in 1..100) {
add(
PickerItem(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ internal class ClothingSizePickerFragment : BaseFragment<
}

private fun generateClothingSizePickerItems(): List<Item> {
return ClothingSize.values().map {
return ClothingSize.entries.map {
PickerItem(
id = it.ordinal,
title = it.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ internal class DashboardFragment : BaseFragment<
private fun initAdapter(): DashboardRecyclerViewAdapter {
return DashboardRecyclerViewAdapter(
context = requireContext(),
items = DashboardDestination.values().toList(),
items = DashboardDestination.entries.toList(),
onItemClickListener = ::navigateToDestination,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ internal class DatePickerFragment : BaseFragment<
}

private fun generateMonthPickerItems(longMonthNames: Boolean): List<Item> {
return Month.values().map {
return Month.entries.map {
PickerItem(
id = it.ordinal,
title = if (longMonthNames) it.longName else it.shortName,
Expand All @@ -92,7 +92,7 @@ internal class DatePickerFragment : BaseFragment<
}

private fun generateDayPickerItems(): List<Item> {
return mutableListOf<Item>().apply {
return buildList {
for (day in 1..31) {
add(
PickerItem(
Expand All @@ -116,7 +116,7 @@ internal class DatePickerFragment : BaseFragment<
}

private fun generateYearPickerItems(): List<Item> {
return mutableListOf<Item>().apply {
return buildList {
for (year in 2020..2030) {
add(
PickerItem(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ internal class MovieFilteringPickerFragment : BaseFragment<
}

private fun generateGenrePickerItems(): List<Item> {
return Genre.values().map {
return Genre.entries.map {
PickerItem(
id = it.ordinal,
title = it.title,
Expand All @@ -98,7 +98,7 @@ internal class MovieFilteringPickerFragment : BaseFragment<
}

private fun generateYearPickerItems(): List<Item> {
return mutableListOf<Item>().apply {
return buildList {
for (year in 1930..2020) {
add(
PickerItem(
Expand Down Expand Up @@ -128,7 +128,7 @@ internal class MovieFilteringPickerFragment : BaseFragment<
}

private fun generateServicePickerItems(): List<Item> {
return StreamingService.values().map {
return StreamingService.entries.map {
PickerItem(
id = it.ordinal,
title = it.title,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ internal class PersonInfoPickerFragment : BaseFragment<
}

private fun generateAgePickerItems(): List<Item> {
return mutableListOf<Item>().apply {
return buildList {
for (age in 1..100) {
add(
PickerItem(
Expand All @@ -106,7 +106,7 @@ internal class PersonInfoPickerFragment : BaseFragment<
}

private fun generateHeightPickerItems(): List<Item> {
return mutableListOf<Item>().apply {
return buildList {
for (cm in 50..250) {
add(
PickerItem(
Expand Down Expand Up @@ -136,7 +136,7 @@ internal class PersonInfoPickerFragment : BaseFragment<
}

private fun generateWeightPickerItems(): List<Item> {
return mutableListOf<Item>().apply {
return buildList {
for (kg in 10..150) {
add(
PickerItem(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ internal class RatingPickerFragment : BaseFragment<
}

private fun generateRatingPickerItems(): List<Item> {
return Rating.values().map {
return Rating.entries.map {
PickerItem(
id = it.ordinal,
title = it.number.toString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ internal class TeamPickerFragment : BaseFragment<
}

private fun generateTeamPickerItems(): List<Item> {
return Team.values().map {
return Team.entries.map {
PickerItem(
id = it.ordinal,
title = it.longName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ internal class TimePickerFragment : BaseFragment<
}

private fun generateHourPickerItems(): List<Item> {
return mutableListOf<Item>().apply {
return buildList {
for (hour in 1..12) {
add(
PickerItem(
Expand All @@ -94,7 +94,7 @@ internal class TimePickerFragment : BaseFragment<
}

private fun generateMinutePickerItems(): List<Item> {
return mutableListOf<Item>().apply {
return buildList {
for (minute in 0..59) {
add(
PickerItem(
Expand All @@ -118,7 +118,7 @@ internal class TimePickerFragment : BaseFragment<
}

private fun generatePeriodPickerItems(): List<Item> {
return mutableListOf<Item>().apply {
return buildList {
add(
PickerItem(
id = 1,
Expand Down

0 comments on commit 97bad65

Please sign in to comment.