Skip to content

Commit

Permalink
Fix potential crash if preference contains invalid value
Browse files Browse the repository at this point in the history
  • Loading branch information
udenr committed Sep 13, 2024
1 parent d222064 commit c7ac64c
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ class MainActivityViewModel(application: Application) : AndroidViewModel(applica
private val repository: NoteDatabase = NoteDatabase.getInstance(application)
private var filter: MutableStateFlow<String> = MutableStateFlow("")
private var ordering: MutableStateFlow<SortingOrder> = MutableStateFlow(
SortingOrder.valueOf(prefManager.getString(PreferenceKeys.SP_NOTES_ORDERING, SortingOrder.AlphabeticalAscending.name)!!)
kotlin.runCatching {
SortingOrder.valueOf(prefManager.getString(PreferenceKeys.SP_NOTES_ORDERING, SortingOrder.AlphabeticalAscending.name)!!)
}.getOrElse { SortingOrder.AlphabeticalAscending }
)
private var reversed: MutableStateFlow<Boolean> = MutableStateFlow(
prefManager.getBoolean(PreferenceKeys.SP_NOTES_REVERSED, false)
Expand Down

0 comments on commit c7ac64c

Please sign in to comment.