Reputation: 1
fun toggleRunning(context: Context) {
if (_isStartButtonBlurred.value) return
val isStarting = timeElapsed.value <= 0
viewModelScope.launch {
val currentState = _uiState.value
val updatedState = if (isStarting) {
val startTime = displayTimeFormatter.format(Date())
withContext(Dispatchers.IO) {
sharedPreferences.edit().putString(START_TIME_KEY, startTime).apply()
}
startTimer(context)
currentState.copy(bottomSheetVisibility = false)
} else {
val endTime = displayTimeFormatter.format(Date())
withContext(Dispatchers.IO) {
sharedPreferences.edit().putString(END_TIME_KEY, endTime).apply()
}
stopTimer(context)
currentState.copy(bottomSheetVisibility = true)
}
_uiState.value = updatedState
}
}
logcat exception:
E : ANR in com.jtpl.project (com.jtpl.project/.presentation.MainActivity) PID: 20257 Reason: Input dispatching timed out (d863c4a com.jtpl.project/com.jtpl.sleeplikeababy.presentation.MainActivity (server) is not responding. Waited 5002ms for FocusEvent(hasFocus=false)). Parent: com.jtpl.project/.presentation.MainActivity ErrorId: b8443fce-5bba-4078-81ee-2d85417e44f3 Frozen: false Load: 1.51 / 0.48 / 0.29
---- Output from /proc/pressure/memory -----
When start and stop timer for first time bottom sheet is not opening for second time its opening.
Upvotes: 0
Views: 11