mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-15 13:37:29 +01:00
Update linter
This commit is contained in:
@@ -25,7 +25,7 @@ fun syncChaptersWithSource(
|
||||
db: DatabaseHelper,
|
||||
rawSourceChapters: List<SChapter>,
|
||||
manga: Manga,
|
||||
source: Source
|
||||
source: Source,
|
||||
): Pair<List<Chapter>, List<Chapter>> {
|
||||
if (rawSourceChapters.isEmpty()) {
|
||||
throw NoChaptersException()
|
||||
|
||||
@@ -102,7 +102,7 @@ private const val MILLISECONDS_IN_DAY = 86_400_000L
|
||||
fun Date.toRelativeString(
|
||||
context: Context,
|
||||
range: Int = 7,
|
||||
dateFormat: DateFormat = DateFormat.getDateInstance(DateFormat.SHORT)
|
||||
dateFormat: DateFormat = DateFormat.getDateInstance(DateFormat.SHORT),
|
||||
): String {
|
||||
if (range == 0) {
|
||||
return dateFormat.format(this)
|
||||
|
||||
@@ -9,7 +9,7 @@ import java.util.concurrent.TimeUnit.MILLISECONDS
|
||||
class RetryWithDelay(
|
||||
private val maxRetries: Int = 1,
|
||||
private val retryStrategy: (Int) -> Int = { 1000 },
|
||||
private val scheduler: Scheduler = Schedulers.computation()
|
||||
private val scheduler: Scheduler = Schedulers.computation(),
|
||||
) : Func1<Observable<out Throwable>, Observable<*>> {
|
||||
|
||||
private var retryCount = 0
|
||||
|
||||
@@ -41,11 +41,11 @@ private suspend fun <T> Observable<T>.awaitOne(): T = suspendCancellableCoroutin
|
||||
}
|
||||
|
||||
override fun onError(e: Throwable) {
|
||||
/*
|
||||
* Rx1 observable throws NoSuchElementException if cancellation happened before
|
||||
* element emission. To mitigate this we try to atomically resume continuation with exception:
|
||||
* if resume failed, then we know that continuation successfully cancelled itself
|
||||
*/
|
||||
/*
|
||||
* Rx1 observable throws NoSuchElementException if cancellation happened before
|
||||
* element emission. To mitigate this we try to atomically resume continuation with exception:
|
||||
* if resume failed, then we know that continuation successfully cancelled itself
|
||||
*/
|
||||
val token = cont.tryResumeWithException(e)
|
||||
if (token != null) {
|
||||
cont.completeResume(token)
|
||||
|
||||
@@ -142,7 +142,7 @@ inline fun SwitchPreferenceCompat.requireAuthentication(activity: FragmentActivi
|
||||
callback = object : AuthenticatorUtil.AuthenticationCallback() {
|
||||
override fun onAuthenticationSucceeded(
|
||||
activity: FragmentActivity?,
|
||||
result: BiometricPrompt.AuthenticationResult
|
||||
result: BiometricPrompt.AuthenticationResult,
|
||||
) {
|
||||
super.onAuthenticationSucceeded(activity, result)
|
||||
isChecked = newValue as Boolean
|
||||
@@ -151,7 +151,7 @@ inline fun SwitchPreferenceCompat.requireAuthentication(activity: FragmentActivi
|
||||
override fun onAuthenticationError(
|
||||
activity: FragmentActivity?,
|
||||
errorCode: Int,
|
||||
errString: CharSequence
|
||||
errString: CharSequence,
|
||||
) {
|
||||
super.onAuthenticationError(activity, errorCode, errString)
|
||||
activity?.toast(errString.toString())
|
||||
|
||||
@@ -31,7 +31,7 @@ object AuthenticatorUtil {
|
||||
title: String,
|
||||
subtitle: String? = null,
|
||||
confirmationRequired: Boolean = true,
|
||||
callback: AuthenticationCallback
|
||||
callback: AuthenticationCallback,
|
||||
) {
|
||||
isAuthenticating = true
|
||||
startClass2BiometricOrCredentialAuthentication(
|
||||
@@ -72,7 +72,7 @@ object AuthenticatorUtil {
|
||||
override fun onAuthenticationError(
|
||||
activity: FragmentActivity?,
|
||||
@AuthenticationError errorCode: Int,
|
||||
errString: CharSequence
|
||||
errString: CharSequence,
|
||||
) {
|
||||
isAuthenticating = false
|
||||
}
|
||||
@@ -90,7 +90,7 @@ object AuthenticatorUtil {
|
||||
@CallSuper
|
||||
override fun onAuthenticationSucceeded(
|
||||
activity: FragmentActivity?,
|
||||
result: BiometricPrompt.AuthenticationResult
|
||||
result: BiometricPrompt.AuthenticationResult,
|
||||
) {
|
||||
isAuthenticating = false
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import logcat.logcat
|
||||
inline fun Any.logcat(
|
||||
priority: LogPriority = LogPriority.DEBUG,
|
||||
throwable: Throwable? = null,
|
||||
message: () -> String = { "" }
|
||||
message: () -> String = { "" },
|
||||
) = logcat(priority = priority) {
|
||||
var msg = message()
|
||||
if (throwable != null) {
|
||||
|
||||
@@ -12,7 +12,7 @@ import androidx.core.app.NotificationChannelGroupCompat
|
||||
*/
|
||||
fun buildNotificationChannelGroup(
|
||||
channelId: String,
|
||||
block: (NotificationChannelGroupCompat.Builder.() -> Unit)
|
||||
block: (NotificationChannelGroupCompat.Builder.() -> Unit),
|
||||
): NotificationChannelGroupCompat {
|
||||
val builder = NotificationChannelGroupCompat.Builder(channelId)
|
||||
builder.block()
|
||||
@@ -30,7 +30,7 @@ fun buildNotificationChannelGroup(
|
||||
fun buildNotificationChannel(
|
||||
channelId: String,
|
||||
channelImportance: Int,
|
||||
block: (NotificationChannelCompat.Builder.() -> Unit)
|
||||
block: (NotificationChannelCompat.Builder.() -> Unit),
|
||||
): NotificationChannelCompat {
|
||||
val builder = NotificationChannelCompat.Builder(channelId, channelImportance)
|
||||
builder.block()
|
||||
|
||||
@@ -24,14 +24,14 @@ abstract class WebViewClientCompat : WebViewClient() {
|
||||
errorCode: Int,
|
||||
description: String?,
|
||||
failingUrl: String,
|
||||
isMainFrame: Boolean
|
||||
isMainFrame: Boolean,
|
||||
) {
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.N)
|
||||
final override fun shouldOverrideUrlLoading(
|
||||
view: WebView,
|
||||
request: WebResourceRequest
|
||||
request: WebResourceRequest,
|
||||
): Boolean {
|
||||
return shouldOverrideUrlCompat(view, request.url.toString())
|
||||
}
|
||||
@@ -42,14 +42,14 @@ abstract class WebViewClientCompat : WebViewClient() {
|
||||
|
||||
final override fun shouldInterceptRequest(
|
||||
view: WebView,
|
||||
request: WebResourceRequest
|
||||
request: WebResourceRequest,
|
||||
): WebResourceResponse? {
|
||||
return shouldInterceptRequestCompat(view, request.url.toString())
|
||||
}
|
||||
|
||||
final override fun shouldInterceptRequest(
|
||||
view: WebView,
|
||||
url: String
|
||||
url: String,
|
||||
): WebResourceResponse? {
|
||||
return shouldInterceptRequestCompat(view, url)
|
||||
}
|
||||
@@ -57,7 +57,7 @@ abstract class WebViewClientCompat : WebViewClient() {
|
||||
final override fun onReceivedError(
|
||||
view: WebView,
|
||||
request: WebResourceRequest,
|
||||
error: WebResourceError
|
||||
error: WebResourceError,
|
||||
) {
|
||||
onReceivedErrorCompat(
|
||||
view,
|
||||
@@ -72,7 +72,7 @@ abstract class WebViewClientCompat : WebViewClient() {
|
||||
view: WebView,
|
||||
errorCode: Int,
|
||||
description: String?,
|
||||
failingUrl: String
|
||||
failingUrl: String,
|
||||
) {
|
||||
onReceivedErrorCompat(view, errorCode, description, failingUrl, failingUrl == view.url)
|
||||
}
|
||||
@@ -80,7 +80,7 @@ abstract class WebViewClientCompat : WebViewClient() {
|
||||
final override fun onReceivedHttpError(
|
||||
view: WebView,
|
||||
request: WebResourceRequest,
|
||||
error: WebResourceResponse
|
||||
error: WebResourceResponse,
|
||||
) {
|
||||
onReceivedErrorCompat(
|
||||
view,
|
||||
|
||||
@@ -38,7 +38,7 @@ fun ImageView.setVectorCompat(@DrawableRes drawable: Int, @AttrRes tint: Int? =
|
||||
fun ImageView.loadAutoPause(
|
||||
data: Any?,
|
||||
loader: ImageLoader = context.imageLoader,
|
||||
builder: ImageRequest.Builder.() -> Unit = {}
|
||||
builder: ImageRequest.Builder.() -> Unit = {},
|
||||
) {
|
||||
load(data, loader) {
|
||||
placeholder(ColorDrawable(context.getColor(R.color.cover_placeholder)))
|
||||
|
||||
@@ -52,7 +52,7 @@ fun View.getCoordinates() = Point((left + right) / 2, (top + bottom) / 2)
|
||||
inline fun View.snack(
|
||||
message: String,
|
||||
length: Int = 10_000,
|
||||
f: Snackbar.() -> Unit = {}
|
||||
f: Snackbar.() -> Unit = {},
|
||||
): Snackbar {
|
||||
val snack = Snackbar.make(this, message, length)
|
||||
snack.f()
|
||||
@@ -88,7 +88,7 @@ inline fun View.setTooltip(text: String) {
|
||||
inline fun View.popupMenu(
|
||||
@MenuRes menuRes: Int,
|
||||
noinline initMenu: (Menu.() -> Unit)? = null,
|
||||
noinline onMenuItemClick: MenuItem.() -> Unit
|
||||
noinline onMenuItemClick: MenuItem.() -> Unit,
|
||||
): PopupMenu {
|
||||
val popup = PopupMenu(context, this, Gravity.NO_GRAVITY, R.attr.actionOverflowMenuStyle, 0)
|
||||
popup.menuInflater.inflate(menuRes, popup.menu)
|
||||
@@ -116,7 +116,7 @@ inline fun View.popupMenu(
|
||||
inline fun View.popupMenu(
|
||||
items: List<Pair<Int, Int>>,
|
||||
selectedItemId: Int? = null,
|
||||
noinline onMenuItemClick: MenuItem.() -> Unit
|
||||
noinline onMenuItemClick: MenuItem.() -> Unit,
|
||||
): PopupMenu {
|
||||
val popup = PopupMenu(context, this, Gravity.NO_GRAVITY, R.attr.actionOverflowMenuStyle, 0)
|
||||
items.forEach { (id, stringRes) ->
|
||||
@@ -174,7 +174,7 @@ inline fun ExtendedFloatingActionButton.shrinkOnScroll(recycler: RecyclerView):
|
||||
inline fun ChipGroup.setChips(
|
||||
items: List<String>?,
|
||||
noinline onClick: ((item: String) -> Unit)? = null,
|
||||
noinline onLongClick: ((item: String) -> Unit)? = null
|
||||
noinline onLongClick: ((item: String) -> Unit)? = null,
|
||||
) {
|
||||
removeAllViews()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user