From 4498b10a1061bc36708ce065a799ac561c66ed16 Mon Sep 17 00:00:00 2001 From: arkon Date: Tue, 21 Feb 2023 12:25:46 -0500 Subject: [PATCH] Fix occasional crash when opening library settings sheet See https://stackoverflow.com/questions/47648689/sealed-classs-objects-mysteriously-becoming-null-when-referenced-by-other-compa (cherry picked from commit c0e2eb211daefe47803d93161f896c6d5011a0ff) --- .../java/tachiyomi/domain/library/model/LibraryDisplayMode.kt | 2 +- .../library/model/{LibrarySort.kt => LibrarySortMode.kt} | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename domain/src/main/java/tachiyomi/domain/library/model/{LibrarySort.kt => LibrarySortMode.kt} (93%) diff --git a/domain/src/main/java/tachiyomi/domain/library/model/LibraryDisplayMode.kt b/domain/src/main/java/tachiyomi/domain/library/model/LibraryDisplayMode.kt index 236d00235d..f317db6719 100644 --- a/domain/src/main/java/tachiyomi/domain/library/model/LibraryDisplayMode.kt +++ b/domain/src/main/java/tachiyomi/domain/library/model/LibraryDisplayMode.kt @@ -24,7 +24,7 @@ sealed class LibraryDisplayMode( } companion object { - val values = setOf(CompactGrid, ComfortableGrid, List, CoverOnlyGrid) + val values by lazy { setOf(CompactGrid, ComfortableGrid, List, CoverOnlyGrid) } val default = CompactGrid fun valueOf(flag: Long?): LibraryDisplayMode { diff --git a/domain/src/main/java/tachiyomi/domain/library/model/LibrarySort.kt b/domain/src/main/java/tachiyomi/domain/library/model/LibrarySortMode.kt similarity index 93% rename from domain/src/main/java/tachiyomi/domain/library/model/LibrarySort.kt rename to domain/src/main/java/tachiyomi/domain/library/model/LibrarySortMode.kt index 1d133724c8..9507aaa5cc 100644 --- a/domain/src/main/java/tachiyomi/domain/library/model/LibrarySort.kt +++ b/domain/src/main/java/tachiyomi/domain/library/model/LibrarySortMode.kt @@ -65,8 +65,8 @@ data class LibrarySort( } companion object { - val types = setOf(Type.Alphabetical, Type.LastRead, Type.LastUpdate, Type.UnreadCount, Type.TotalChapters, Type.LatestChapter, Type.ChapterFetchDate, Type.DateAdded) - val directions = setOf(Direction.Ascending, Direction.Descending) + val types by lazy { setOf(Type.Alphabetical, Type.LastRead, Type.LastUpdate, Type.UnreadCount, Type.TotalChapters, Type.LatestChapter, Type.ChapterFetchDate, Type.DateAdded) } + val directions by lazy { setOf(Direction.Ascending, Direction.Descending) } val default = LibrarySort(Type.Alphabetical, Direction.Ascending) fun valueOf(flag: Long): LibrarySort {