File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed
AnkiDroid/src/main/java/com/ichi2/anki Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -64,6 +64,7 @@ import com.ichi2.anki.utils.CollectionPreferences
6464import com.ichi2.anki.utils.Destination
6565import com.ichi2.anki.utils.ext.answerCard
6666import com.ichi2.anki.utils.ext.flag
67+ import com.ichi2.anki.utils.ext.getLongOrNull
6768import com.ichi2.anki.utils.ext.setUserFlagForCards
6869import kotlinx.coroutines.CompletableDeferred
6970import kotlinx.coroutines.Deferred
Original file line number Diff line number Diff line change @@ -21,3 +21,16 @@ fun <T> SavedStateHandle.require(key: String): T =
2121 checkNotNull(get(key)) {
2222 " Wrong type or key '$key ' not found"
2323 }
24+
25+ /* *
26+ * Retrieves the [Long] value for the provided [key], returns null if not found.
27+ *
28+ * @param key the key to use
29+ * @return the long value, or null if not found
30+ */
31+ fun SavedStateHandle.getLongOrNull (key : String ): Long? =
32+ if (contains(key)) {
33+ get(key) as Long?
34+ } else {
35+ null
36+ }
You can’t perform that action at this time.
0 commit comments