android / codelab-android-datastore

Apache License 2.0
228 stars 105 forks source link

[Pref DataStore] Deadline & Priority switches go in infinite loop #31

Open anidhamal opened 3 years ago

anidhamal commented 3 years ago

Issue :: When both deadline and priority are selected, leaving the app and reopening, makes deadline & priority switches go in infinite loop Steps to reproduce:

Why:: After reopening, updateSort -> enableSortByPriority -> SortOrder.BY_PRIORITY -> updateSort -> enableSortByDeadline -> SortOrder.BY_DEADLINE_AND_PRIORITY -> enableSortByPriority -> SortOrder.BY_PRIORITY -> updateSort -> ♾

Solution :: Inside enableSortByPriority / enableSortByDeadline mtds, check if the argument is enable and SortOrder is BY_DEADLINE_AND_PRIORITY, return from the mtds.