Use kotlin.time extensions in some more places
(cherry picked from commit 5c868d784679b55e413366c5d4bdea75253bf8f4) # Conflicts: # app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt
This commit is contained in:
parent
f367a121ac
commit
6d46283aee
@ -15,6 +15,7 @@ import androidx.compose.ui.focus.focusRequester
|
|||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
|
import kotlin.time.Duration.Companion.seconds
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun CategoryCreateDialog(
|
fun CategoryCreateDialog(
|
||||||
@ -71,7 +72,7 @@ fun CategoryCreateDialog(
|
|||||||
|
|
||||||
LaunchedEffect(focusRequester) {
|
LaunchedEffect(focusRequester) {
|
||||||
// TODO: https://issuetracker.google.com/issues/204502668
|
// TODO: https://issuetracker.google.com/issues/204502668
|
||||||
delay(100)
|
delay(0.1.seconds)
|
||||||
focusRequester.requestFocus()
|
focusRequester.requestFocus()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -118,7 +119,7 @@ fun CategoryRenameDialog(
|
|||||||
|
|
||||||
LaunchedEffect(focusRequester) {
|
LaunchedEffect(focusRequester) {
|
||||||
// TODO: https://issuetracker.google.com/issues/204502668
|
// TODO: https://issuetracker.google.com/issues/204502668
|
||||||
delay(100)
|
delay(0.1.seconds)
|
||||||
focusRequester.requestFocus()
|
focusRequester.requestFocus()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,6 +60,7 @@ import kotlinx.coroutines.Job
|
|||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.isActive
|
import kotlinx.coroutines.isActive
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlin.time.Duration.Companion.seconds
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun MangaBottomActionMenu(
|
fun MangaBottomActionMenu(
|
||||||
@ -92,7 +93,7 @@ fun MangaBottomActionMenu(
|
|||||||
(0 until 7).forEach { i -> confirm[i] = i == toConfirmIndex }
|
(0 until 7).forEach { i -> confirm[i] = i == toConfirmIndex }
|
||||||
resetJob?.cancel()
|
resetJob?.cancel()
|
||||||
resetJob = scope.launch {
|
resetJob = scope.launch {
|
||||||
delay(1000)
|
delay(1.seconds)
|
||||||
if (isActive) confirm[toConfirmIndex] = false
|
if (isActive) confirm[toConfirmIndex] = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -244,7 +245,7 @@ fun LibraryBottomActionMenu(
|
|||||||
(0 until 5).forEach { i -> confirm[i] = i == toConfirmIndex }
|
(0 until 5).forEach { i -> confirm[i] = i == toConfirmIndex }
|
||||||
resetJob?.cancel()
|
resetJob?.cancel()
|
||||||
resetJob = scope.launch {
|
resetJob = scope.launch {
|
||||||
delay(1000)
|
delay(1.seconds)
|
||||||
if (isActive) confirm[toConfirmIndex] = false
|
if (isActive) confirm[toConfirmIndex] = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ import eu.kanade.presentation.library.LibraryState
|
|||||||
import eu.kanade.tachiyomi.ui.library.LibraryItem
|
import eu.kanade.tachiyomi.ui.library.LibraryItem
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import kotlin.time.Duration.Companion.seconds
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun LibraryContent(
|
fun LibraryContent(
|
||||||
@ -112,7 +113,7 @@ fun LibraryContent(
|
|||||||
scope.launch {
|
scope.launch {
|
||||||
// Fake refresh status but hide it after a second as it's a long running task
|
// Fake refresh status but hide it after a second as it's a long running task
|
||||||
isRefreshing = true
|
isRefreshing = true
|
||||||
delay(1000)
|
delay(1.seconds)
|
||||||
isRefreshing = false
|
isRefreshing = false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -15,6 +15,7 @@ import eu.kanade.presentation.components.ScrollbarLazyColumn
|
|||||||
import eu.kanade.presentation.more.settings.screen.SearchableSettings
|
import eu.kanade.presentation.more.settings.screen.SearchableSettings
|
||||||
import eu.kanade.presentation.more.settings.widget.PreferenceGroupHeader
|
import eu.kanade.presentation.more.settings.widget.PreferenceGroupHeader
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
|
import kotlin.time.Duration.Companion.seconds
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Preference Screen composable which contains a list of [Preference] items
|
* Preference Screen composable which contains a list of [Preference] items
|
||||||
@ -33,7 +34,7 @@ fun PreferenceScreen(
|
|||||||
LaunchedEffect(Unit) {
|
LaunchedEffect(Unit) {
|
||||||
val i = items.findHighlightedIndex(highlightKey)
|
val i = items.findHighlightedIndex(highlightKey)
|
||||||
if (i >= 0) {
|
if (i >= 0) {
|
||||||
delay(500)
|
delay(0.5.seconds)
|
||||||
state.animateScrollToItem(i)
|
state.animateScrollToItem(i)
|
||||||
}
|
}
|
||||||
SearchableSettings.highlightKey = null
|
SearchableSettings.highlightKey = null
|
||||||
|
@ -32,6 +32,7 @@ import androidx.compose.ui.unit.dp
|
|||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
import eu.kanade.presentation.more.settings.LocalPreferenceHighlighted
|
import eu.kanade.presentation.more.settings.LocalPreferenceHighlighted
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
|
import kotlin.time.Duration.Companion.seconds
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
internal fun BasePreferenceWidget(
|
internal fun BasePreferenceWidget(
|
||||||
@ -89,7 +90,7 @@ internal fun Modifier.highlightBackground(highlighted: Boolean): Modifier = comp
|
|||||||
LaunchedEffect(Unit) {
|
LaunchedEffect(Unit) {
|
||||||
if (highlighted) {
|
if (highlighted) {
|
||||||
highlightFlag = true
|
highlightFlag = true
|
||||||
delay(3000)
|
delay(3.seconds)
|
||||||
highlightFlag = false
|
highlightFlag = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,7 @@ import kotlinx.coroutines.delay
|
|||||||
import kotlinx.coroutines.flow.collectLatest
|
import kotlinx.coroutines.flow.collectLatest
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
|
import kotlin.time.Duration.Companion.seconds
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun UpdateScreen(
|
fun UpdateScreen(
|
||||||
@ -135,7 +136,7 @@ private fun UpdateScreenContent(
|
|||||||
scope.launch {
|
scope.launch {
|
||||||
// Fake refresh status but hide it after a second as it's a long running task
|
// Fake refresh status but hide it after a second as it's a long running task
|
||||||
isRefreshing = true
|
isRefreshing = true
|
||||||
delay(1000)
|
delay(1.seconds)
|
||||||
isRefreshing = false
|
isRefreshing = false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -25,6 +25,7 @@ import uy.kohesive.injekt.Injekt
|
|||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
import java.util.concurrent.ConcurrentHashMap
|
import java.util.concurrent.ConcurrentHashMap
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
|
import kotlin.time.Duration.Companion.seconds
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cache where we dump the downloads directory from the filesystem. This class is needed because
|
* Cache where we dump the downloads directory from the filesystem. This class is needed because
|
||||||
@ -258,13 +259,13 @@ class DownloadCache(
|
|||||||
var sources = getSources()
|
var sources = getSources()
|
||||||
|
|
||||||
// Try to wait until extensions and sources have loaded
|
// Try to wait until extensions and sources have loaded
|
||||||
withTimeout(30000L) {
|
withTimeout(30.seconds) {
|
||||||
while (!extensionManager.isInitialized) {
|
while (!extensionManager.isInitialized) {
|
||||||
delay(2000L)
|
delay(2.seconds)
|
||||||
}
|
}
|
||||||
|
|
||||||
while (sources.isEmpty()) {
|
while (sources.isEmpty()) {
|
||||||
delay(2000L)
|
delay(2.seconds)
|
||||||
sources = getSources()
|
sources = getSources()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,6 +87,7 @@ import uy.kohesive.injekt.Injekt
|
|||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
import java.util.LinkedList
|
import java.util.LinkedList
|
||||||
|
import kotlin.time.Duration.Companion.seconds
|
||||||
|
|
||||||
class MainActivity : BaseActivity() {
|
class MainActivity : BaseActivity() {
|
||||||
|
|
||||||
@ -609,7 +610,7 @@ class MainActivity : BaseActivity() {
|
|||||||
private suspend fun resetExitConfirmation() {
|
private suspend fun resetExitConfirmation() {
|
||||||
isConfirmingExit = true
|
isConfirmingExit = true
|
||||||
val toast = toast(R.string.confirm_exit, Toast.LENGTH_LONG)
|
val toast = toast(R.string.confirm_exit, Toast.LENGTH_LONG)
|
||||||
delay(2000)
|
delay(2.seconds)
|
||||||
toast.cancel()
|
toast.cancel()
|
||||||
isConfirmingExit = false
|
isConfirmingExit = false
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user