From 24fb03a0b8a1d5ac5f6be7eb4c6af5fc5a945752 Mon Sep 17 00:00:00 2001 From: DeweyReed <32358486+DeweyReed@users.noreply.github.com> Date: Fri, 22 Mar 2024 20:13:16 +0800 Subject: [PATCH] Specify some types for MutableLiveData to pass the lint --- .../aprildown/timer/presentation/timer/RecordViewModel.kt | 5 +++-- .../aprildown/timer/presentation/timer/TimerViewModel.kt | 8 +++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/presentation/src/main/java/xyz/aprildown/timer/presentation/timer/RecordViewModel.kt b/presentation/src/main/java/xyz/aprildown/timer/presentation/timer/RecordViewModel.kt index 1f2779ef..cd58d411 100644 --- a/presentation/src/main/java/xyz/aprildown/timer/presentation/timer/RecordViewModel.kt +++ b/presentation/src/main/java/xyz/aprildown/timer/presentation/timer/RecordViewModel.kt @@ -62,12 +62,13 @@ class RecordViewModel @Inject constructor( getRecords.calculateTimeline(it) } - private val _minDateMilli = MutableLiveData() + private val _minDateMilli: MutableLiveData = MutableLiveData() val minDateMilli: LiveData = _minDateMilli init { launch { - _minDateMilli.value = getRecords.getMinDateMilli() + val minDateMilli: Long = getRecords.getMinDateMilli() + _minDateMilli.value = minDateMilli val all = mutableListOf() val sortBy = folderSortByRule.get() diff --git a/presentation/src/main/java/xyz/aprildown/timer/presentation/timer/TimerViewModel.kt b/presentation/src/main/java/xyz/aprildown/timer/presentation/timer/TimerViewModel.kt index b45c5cf4..080b5c87 100644 --- a/presentation/src/main/java/xyz/aprildown/timer/presentation/timer/TimerViewModel.kt +++ b/presentation/src/main/java/xyz/aprildown/timer/presentation/timer/TimerViewModel.kt @@ -79,7 +79,7 @@ class TimerViewModel @Inject constructor( folders.find { it.id == id } }.asLiveData() - private val currentSortBy = MutableLiveData() + private val currentSortBy: MutableLiveData = MutableLiveData() val timerInfo: LiveData> = currentFolderId.asFlow().combine(currentSortBy.asFlow()) { id, by -> @@ -106,12 +106,14 @@ class TimerViewModel @Inject constructor( } else { FolderEntity.FOLDER_DEFAULT } - currentSortBy.value = folderSortByRule.get() + val folderSortBy: FolderSortBy = folderSortByRule.get() + currentSortBy.value = folderSortBy } } private suspend fun refreshFolders() { - _allFolders.value = getFolders.invoke() + val folders: List = getFolders() + _allFolders.value = folders } fun changeFolder(folderId: Long) {