From 00361a58c7c7935315087641077ad6e157ddbbef Mon Sep 17 00:00:00 2001 From: Fabian Henneke Date: Wed, 22 Apr 2020 18:13:56 +0200 Subject: Fix crash when using type independent sort (#734) --- app/src/main/java/com/zeapo/pwdstore/SearchableRepositoryViewModel.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'app/src') diff --git a/app/src/main/java/com/zeapo/pwdstore/SearchableRepositoryViewModel.kt b/app/src/main/java/com/zeapo/pwdstore/SearchableRepositoryViewModel.kt index 31258201..3dcca85f 100644 --- a/app/src/main/java/com/zeapo/pwdstore/SearchableRepositoryViewModel.kt +++ b/app/src/main/java/com/zeapo/pwdstore/SearchableRepositoryViewModel.kt @@ -92,7 +92,9 @@ private fun PasswordItem.Companion.makeComparator( ): Comparator { return when (typeSortOrder) { PasswordRepository.PasswordSortOrder.FOLDER_FIRST -> compareBy { it.type } - PasswordRepository.PasswordSortOrder.INDEPENDENT -> compareBy() + // In order to let INDEPENDENT not distinguish between items based on their type, we simply + // declare them all equal at this stage. + PasswordRepository.PasswordSortOrder.INDEPENDENT -> Comparator { _, _ -> 0 } PasswordRepository.PasswordSortOrder.FILE_FIRST -> compareByDescending { it.type } } .then(compareBy(nullsLast(CaseInsensitiveComparator)) { -- cgit v1.2.3