diff --git a/app/src/main/java/com/github/droidworksstudio/launcher/helper/AppHelper.kt b/app/src/main/java/com/github/droidworksstudio/launcher/helper/AppHelper.kt index 762251fe..661d9485 100644 --- a/app/src/main/java/com/github/droidworksstudio/launcher/helper/AppHelper.kt +++ b/app/src/main/java/com/github/droidworksstudio/launcher/helper/AppHelper.kt @@ -137,11 +137,11 @@ class AppHelper @Inject constructor() { } } - fun getGravityFromSelectedItem(selectedItem: String): Int { + fun getGravityFromSelectedItem(selectedItem: Int): Int { return when (selectedItem) { - "Left" -> Gravity.START - "Center" -> Gravity.CENTER - "Right" -> Gravity.END + 0 -> Gravity.START + 1 -> Gravity.CENTER + 2 -> Gravity.END else -> Gravity.START } } @@ -387,4 +387,4 @@ class AppHelper @Inject constructor() { // Data class to hold cached weather data along with timestamp data class CachedWeatherData(val timestamp: Long, val weatherResponse: WeatherResponse) -} \ No newline at end of file +} diff --git a/app/src/main/java/com/github/droidworksstudio/launcher/ui/bottomsheetdialog/AlignmentBottomSheetDialogFragment.kt b/app/src/main/java/com/github/droidworksstudio/launcher/ui/bottomsheetdialog/AlignmentBottomSheetDialogFragment.kt index 7430141a..c8bde0d3 100644 --- a/app/src/main/java/com/github/droidworksstudio/launcher/ui/bottomsheetdialog/AlignmentBottomSheetDialogFragment.kt +++ b/app/src/main/java/com/github/droidworksstudio/launcher/ui/bottomsheetdialog/AlignmentBottomSheetDialogFragment.kt @@ -117,8 +117,8 @@ class AlignmentBottomSheetDialogFragment : BottomSheetDialogFragment() { val dialog = MaterialAlertDialogBuilder(requireContext()) dialog.setTitle(DIALOG_TITLE) - dialog.setItems(items) { _, which -> - val selectedItem = items[which] + dialog.setItems(items) { _, index -> + val selectedItem = index val gravity = appHelper.getGravityFromSelectedItem(selectedItem) when (selectedAlignment) { @@ -215,4 +215,4 @@ class AlignmentBottomSheetDialogFragment : BottomSheetDialogFragment() { private const val REQUEST_KEY_ALARM_CLOCK_ALIGNMENT = "REQUEST_KEY_ALARM_CLOCK_ALIGNMENT" private const val REQUEST_KEY_WORD_ALIGNMENT = "REQUEST_KEY_WORD_ALIGNMENT" } -} \ No newline at end of file +}