mirror of
https://github.com/Suwayomi/TachideskJUI.git
synced 2025-12-10 06:42:05 +01:00
Automatic Lint
This commit is contained in:
@@ -30,7 +30,9 @@ class UpdateCheckWorker(private val context: Context, workerParams: WorkerParame
|
||||
.let {
|
||||
if (it.updatePreferences.enabled().get()) {
|
||||
it.updateChecker.await(false)
|
||||
} else null
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
if (update is Update.UpdateFound) {
|
||||
|
||||
@@ -21,5 +21,7 @@ fun String.chop(count: Int, replacement: String = "…"): String {
|
||||
fun String.addSuffix(char: Char): String {
|
||||
return if (endsWith(char)) {
|
||||
this
|
||||
} else this + char
|
||||
} else {
|
||||
this + char
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,5 +65,7 @@ fun <T> Preference<T>.getAsFlow(action: (suspend (T) -> Unit)? = null): Flow<T>
|
||||
.onStart { emit(get()) }
|
||||
return if (action != null) {
|
||||
flow.onEach(action = action)
|
||||
} else flow
|
||||
} else {
|
||||
flow
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,7 +173,9 @@ suspend fun main() {
|
||||
}
|
||||
else -> false
|
||||
}
|
||||
} else false
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
) {
|
||||
AppTheme {
|
||||
|
||||
@@ -23,7 +23,9 @@ class GetCategories @Inject constructor(private val categoryRepository: Category
|
||||
.map { categories ->
|
||||
if (dropDefault) {
|
||||
categories.filterNot { it.name.equals("default", true) }
|
||||
} else categories
|
||||
} else {
|
||||
categories
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -13,5 +13,5 @@ enum class DownloadState(val state: Int) {
|
||||
Queued(0),
|
||||
Downloading(1),
|
||||
Finished(2),
|
||||
Error(3),
|
||||
Error(3)
|
||||
}
|
||||
|
||||
@@ -18,5 +18,5 @@ enum class ImageScale(@Transient val res: StringResource) {
|
||||
FitWidth(MR.strings.scale_fit_width),
|
||||
FitHeight(MR.strings.scale_fit_height),
|
||||
OriginalSize(MR.strings.scale_original),
|
||||
SmartFit(MR.strings.scale_smart),
|
||||
SmartFit(MR.strings.scale_smart)
|
||||
}
|
||||
|
||||
@@ -16,5 +16,5 @@ enum class NavigationMode(@Transient val res: StringResource) {
|
||||
LNavigation(MR.strings.nav_l_shaped),
|
||||
KindlishNavigation(MR.strings.nav_kindle_ish),
|
||||
EdgeNavigation(MR.strings.nav_edge),
|
||||
RightAndLeftNavigation(MR.strings.nav_left_right),
|
||||
RightAndLeftNavigation(MR.strings.nav_left_right)
|
||||
}
|
||||
|
||||
@@ -52,7 +52,9 @@ class ReaderModePreferences(private val mode: String, private val preferenceStor
|
||||
} else {
|
||||
700
|
||||
}
|
||||
} else 0
|
||||
} else {
|
||||
0
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@ data class SourceFilterChange(val position: Int, val state: String) {
|
||||
position,
|
||||
if (state is SortFilter.Selection) {
|
||||
Json.encodeToString(state)
|
||||
} else state.toString()
|
||||
} else {
|
||||
state.toString()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@ data class SourcePreferenceChange(val position: Int, val value: String) {
|
||||
if (value is List<*>) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
Json.encodeToString(value as List<String>)
|
||||
} else value.toString()
|
||||
} else {
|
||||
value.toString()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -12,5 +12,5 @@ import kotlinx.serialization.Serializable
|
||||
enum class ThemeMode {
|
||||
System,
|
||||
Light,
|
||||
Dark,
|
||||
Dark
|
||||
}
|
||||
|
||||
@@ -89,8 +89,12 @@ class ServerService @Inject constructor(
|
||||
if (file.toString().contains("java") || file.toString().contains("jdk")) {
|
||||
if (file.name.equals("bin", true)) {
|
||||
file
|
||||
} else file.resolve("bin")
|
||||
} else null
|
||||
} else {
|
||||
file.resolve("bin")
|
||||
}
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
.mapNotNull { getJavaFromPath(it) }
|
||||
.firstOrNull()
|
||||
|
||||
@@ -24,7 +24,9 @@ sealed class ServerHostPreference<T : Any> {
|
||||
val preference = preference().get().takeIf(::validate)
|
||||
return if (preference != null) {
|
||||
propertyPrefix + preference.toString()
|
||||
} else null
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract val preferenceStore: PreferenceStore
|
||||
|
||||
@@ -42,7 +42,9 @@ class DownloadsScreenViewModel @Inject constructor(
|
||||
) : ViewModel(contextWrapper) {
|
||||
private val uiScope = if (standalone) {
|
||||
MainScope()
|
||||
} else null
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
||||
override val scope: CoroutineScope
|
||||
get() = uiScope ?: super.scope
|
||||
|
||||
@@ -173,7 +173,9 @@ fun DownloadsItem(
|
||||
)
|
||||
val progress = if (item.chapter.pageCount != null && item.chapter.pageCount != -1) {
|
||||
" - " + "${(item.chapter.pageCount!! * item.progress).toInt()}/${item.chapter.pageCount}"
|
||||
} else ""
|
||||
} else {
|
||||
""
|
||||
}
|
||||
MangaListItemSubtitle(
|
||||
text = item.chapter.name + progress
|
||||
)
|
||||
|
||||
@@ -143,7 +143,9 @@ class ExtensionsScreenViewModel @Inject constructor(
|
||||
.let {
|
||||
if (it.isNotEmpty()) {
|
||||
listOf(ExtensionUI.Header(MR.strings.installed.toPlatformString())) + it
|
||||
} else it
|
||||
} else {
|
||||
it
|
||||
}
|
||||
}.plus(
|
||||
filterNot(Extension::installed)
|
||||
.groupBy(Extension::lang)
|
||||
|
||||
@@ -47,7 +47,9 @@ fun DownloadsExtraInfo() {
|
||||
} else {
|
||||
remainingDownloads
|
||||
}
|
||||
} else null
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
WebsocketService.Status.STOPPED -> null
|
||||
}
|
||||
|
||||
@@ -213,7 +213,9 @@ private fun getActionItems(
|
||||
icon = Icons.Rounded.Label,
|
||||
doAction = setCategories
|
||||
)
|
||||
} else null,
|
||||
} else {
|
||||
null
|
||||
},
|
||||
ActionItem(
|
||||
name = stringResource(if (inLibrary) MR.strings.action_remove_favorite else MR.strings.action_favorite),
|
||||
icon = if (inLibrary) {
|
||||
|
||||
@@ -277,7 +277,9 @@ private fun ReaderProgressSlider(
|
||||
modifier = modifier.let {
|
||||
if (isRtL) {
|
||||
it then Modifier.rotate(180F)
|
||||
} else it
|
||||
} else {
|
||||
it
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -113,7 +113,9 @@ class TachideskPageLoader(
|
||||
.getOrElse {
|
||||
ReaderPage.ImageDecodeState.FailedToDecode(it)
|
||||
}
|
||||
} else ReaderPage.ImageDecodeState.UnknownDecoder
|
||||
} else {
|
||||
ReaderPage.ImageDecodeState.UnknownDecoder
|
||||
}
|
||||
} ?: ReaderPage.ImageDecodeState.FailedToGetSnapShot
|
||||
}
|
||||
page.status.value = ReaderPage.Status.READY
|
||||
@@ -156,7 +158,9 @@ class TachideskPageLoader(
|
||||
channel.send(it)
|
||||
}
|
||||
}
|
||||
} else null
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -114,7 +114,9 @@ fun ContinuousReader(
|
||||
Direction.Up, Direction.Down -> Modifier.width(maxSize.dp)
|
||||
Direction.Left, Direction.Right -> Modifier.height(maxSize.dp)
|
||||
}
|
||||
} else Modifier
|
||||
} else {
|
||||
Modifier
|
||||
}
|
||||
val contentPadding = when (direction) {
|
||||
Direction.Right -> PaddingValues(end = padding.dp)
|
||||
Direction.Left -> PaddingValues(start = padding.dp)
|
||||
|
||||
@@ -547,7 +547,9 @@ private fun getActionItems(
|
||||
doAction = onToggleFiltersClick,
|
||||
enabled = !isLatest
|
||||
)
|
||||
} else null,
|
||||
} else {
|
||||
null
|
||||
},
|
||||
if (showLatestButton) {
|
||||
ActionItem(
|
||||
name = stringResource(
|
||||
@@ -564,7 +566,9 @@ private fun getActionItems(
|
||||
},
|
||||
doAction = onClickMode
|
||||
)
|
||||
} else null,
|
||||
} else {
|
||||
null
|
||||
},
|
||||
ActionItem(
|
||||
name = stringResource(MR.strings.display_mode),
|
||||
icon = Icons.Rounded.ViewModule,
|
||||
@@ -576,6 +580,8 @@ private fun getActionItems(
|
||||
icon = Icons.Rounded.Settings,
|
||||
doAction = onSourceSettingsClick
|
||||
)
|
||||
} else null
|
||||
} else {
|
||||
null
|
||||
}
|
||||
).toImmutableList()
|
||||
}
|
||||
|
||||
@@ -301,7 +301,9 @@ fun SortView(sortHolder: StableHolder<SourceFiltersView.Sort>, startExpanded: Bo
|
||||
index,
|
||||
if (state?.index == index) {
|
||||
state?.ascending?.not() ?: false
|
||||
} else false
|
||||
} else {
|
||||
false
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
@@ -319,7 +321,9 @@ fun TextView(textHolder: StableHolder<SourceFiltersView.Text>) {
|
||||
mutableStateOf(
|
||||
if (state == placeholderText) {
|
||||
""
|
||||
} else state
|
||||
} else {
|
||||
state
|
||||
}
|
||||
)
|
||||
}
|
||||
val interactionSource = remember { MutableInteractionSource() }
|
||||
|
||||
@@ -198,11 +198,15 @@ private fun Modifier.drawScrollbar(
|
||||
val totalSize = estimatedItemSize * layoutInfo.totalItemsCount
|
||||
val canvasSize = if (orientation == Orientation.Horizontal) size.width else size.height
|
||||
val thumbSize = viewportSize / totalSize * canvasSize
|
||||
val startOffset = if (items.isEmpty()) 0f else items
|
||||
.first()
|
||||
.run {
|
||||
(estimatedItemSize * index - offset) / totalSize * canvasSize
|
||||
}
|
||||
val startOffset = if (items.isEmpty()) {
|
||||
0f
|
||||
} else {
|
||||
items
|
||||
.first()
|
||||
.run {
|
||||
(estimatedItemSize * index - offset) / totalSize * canvasSize
|
||||
}
|
||||
}
|
||||
val drawScrollbar = onDrawScrollbar(
|
||||
orientation = orientation,
|
||||
reverseDirection = reverseDirection,
|
||||
@@ -245,11 +249,15 @@ private fun Modifier.drawScrollbar(
|
||||
val totalSize = estimatedItemSize * layoutInfo.totalItemsCount
|
||||
val canvasSize = if (orientation == Orientation.Horizontal) size.width else size.height
|
||||
val thumbSize = viewportSize / totalSize * canvasSize
|
||||
val startOffset = if (items.isEmpty()) 0f else items
|
||||
.first()
|
||||
.run {
|
||||
(estimatedItemSize * index - if (orientation == Orientation.Vertical) offset.y else offset.x) / totalSize * canvasSize
|
||||
}
|
||||
val startOffset = if (items.isEmpty()) {
|
||||
0f
|
||||
} else {
|
||||
items
|
||||
.first()
|
||||
.run {
|
||||
(estimatedItemSize * index - if (orientation == Orientation.Vertical) offset.y else offset.x) / totalSize * canvasSize
|
||||
}
|
||||
}
|
||||
val drawScrollbar = onDrawScrollbar(
|
||||
orientation = orientation,
|
||||
reverseDirection = reverseDirection,
|
||||
@@ -332,7 +340,9 @@ private fun Modifier.drawScrollbar(
|
||||
val isLtr = LocalLayoutDirection.current == LayoutDirection.Ltr
|
||||
val reverseDirection = if (orientation == Orientation.Horizontal) {
|
||||
if (isLtr) reverseScrolling else !reverseScrolling
|
||||
} else reverseScrolling
|
||||
} else {
|
||||
reverseScrolling
|
||||
}
|
||||
val atEnd = if (orientation == Orientation.Vertical) isLtr else true
|
||||
|
||||
// Calculate thickness here to workaround https://issuetracker.google.com/issues/206972664
|
||||
|
||||
@@ -30,7 +30,11 @@ fun Modifier.keyboardHandler(
|
||||
} else if (it.key == Key.Tab) {
|
||||
action(focusManager)
|
||||
true
|
||||
} else false
|
||||
} else false
|
||||
} else {
|
||||
false
|
||||
}
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ private val log = logging()
|
||||
private enum class ImageLoaderImageState {
|
||||
Loading,
|
||||
Success,
|
||||
Failure,
|
||||
Failure
|
||||
}
|
||||
|
||||
@Composable
|
||||
|
||||
Reference in New Issue
Block a user