Run linter

This commit is contained in:
arkon
2020-02-26 18:03:34 -05:00
parent 58ab06b4f8
commit 043e3784e8
331 changed files with 876 additions and 1075 deletions
@@ -1,13 +1,13 @@
package eu.kanade.tachiyomi.util
import android.content.SharedPreferences
import kotlin.coroutines.CoroutineContext
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.channelFlow
import kotlinx.coroutines.flow.flowOn
import kotlin.coroutines.CoroutineContext
@ExperimentalCoroutinesApi
inline fun <reified T> SharedPreferences.getKey(key: String, default: T, dispatcher: CoroutineContext = Dispatchers.Default): Flow<T> {
@@ -140,5 +140,4 @@ object ChapterRecognition {
private fun parseAlphaPostFix(alpha: Char): Float {
return ("0." + (alpha.toInt() - 96).toString()).toFloat()
}
}
@@ -18,10 +18,12 @@ import java.util.TreeSet
* @param source the source of the chapters.
* @return a pair of new insertions and deletions.
*/
fun syncChaptersWithSource(db: DatabaseHelper,
rawSourceChapters: List<SChapter>,
manga: Manga,
source: Source): Pair<List<Chapter>, List<Chapter>> {
fun syncChaptersWithSource(
db: DatabaseHelper,
rawSourceChapters: List<SChapter>,
manga: Manga,
source: Source
): Pair<List<Chapter>, List<Chapter>> {
if (rawSourceChapters.isEmpty()) {
throw Exception("No chapters found")
@@ -51,7 +53,7 @@ fun syncChaptersWithSource(db: DatabaseHelper,
if (dbChapter == null) {
toAdd.add(sourceChapter)
} else {
//this forces metadata update for the main viewable things in the chapter list
// this forces metadata update for the main viewable things in the chapter list
if (source is HttpSource) {
source.prepareNewChapter(sourceChapter, manga)
}
@@ -137,7 +139,7 @@ fun syncChaptersWithSource(db: DatabaseHelper,
return Pair(toAdd.subtract(readded).toList(), toDelete.subtract(readded).toList())
}
//checks if the chapter in db needs updated
// checks if the chapter in db needs updated
private fun shouldUpdateDbChapter(dbChapter: Chapter, sourceChapter: SChapter): Boolean {
return dbChapter.scanlator != sourceChapter.scanlator || dbChapter.name != sourceChapter.name ||
dbChapter.date_upload != sourceChapter.date_upload ||
@@ -1,15 +1,15 @@
package eu.kanade.tachiyomi.util.lang
import java.util.concurrent.TimeUnit.MILLISECONDS
import rx.Observable
import rx.Scheduler
import rx.functions.Func1
import rx.schedulers.Schedulers
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 maxRetries: Int = 1,
private val retryStrategy: (Int) -> Int = { 1000 },
private val scheduler: Scheduler = Schedulers.computation()
) : Func1<Observable<out Throwable>, Observable<*>> {
private var retryCount = 0
@@ -114,4 +114,3 @@ object DiskUtil {
}
}
}
@@ -1,12 +1,12 @@
package eu.kanade.tachiyomi.util.storage
import org.jsoup.Jsoup
import org.jsoup.nodes.Document
import java.io.Closeable
import java.io.File
import java.io.InputStream
import java.util.zip.ZipEntry
import java.util.zip.ZipFile
import org.jsoup.Jsoup
import org.jsoup.nodes.Document
/**
* Wrapper over ZipFile to load files in epub format.
@@ -113,5 +113,4 @@ class EpubFile(file: File) : Closeable {
}
}
}
}
@@ -17,4 +17,3 @@ fun File.getUriCompat(context: Context): Uri {
FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID + ".provider", this)
else Uri.fromFile(this)
}
@@ -1,10 +1,10 @@
package eu.kanade.tachiyomi.util.storage
import java.io.File
import java.io.OutputStream
import okio.BufferedSource
import okio.buffer
import okio.sink
import java.io.File
import java.io.OutputStream
/**
* Saves the given source to a file and closes it. Directories will be created if needed.
@@ -70,5 +70,4 @@ object ImageUtil {
GIF("image/gif", "gif"),
WEBP("image/webp", "webp")
}
}
@@ -7,8 +7,8 @@ import android.os.Build
import android.view.ContextThemeWrapper
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import uy.kohesive.injekt.injectLazy
import java.util.Locale
import uy.kohesive.injekt.injectLazy
/**
* Utility class to change the application's language in runtime.
@@ -141,5 +141,4 @@ object LocaleHelper {
}
return newConfig
}
}
@@ -16,18 +16,18 @@ abstract class WebViewClientCompat : WebViewClient() {
}
open fun onReceivedErrorCompat(
view: WebView,
errorCode: Int,
description: String?,
failingUrl: String,
isMainFrame: Boolean) {
view: WebView,
errorCode: Int,
description: String?,
failingUrl: String,
isMainFrame: Boolean
) {
}
@TargetApi(Build.VERSION_CODES.N)
final override fun shouldOverrideUrlLoading(
view: WebView,
request: WebResourceRequest
view: WebView,
request: WebResourceRequest
): Boolean {
return shouldOverrideUrlCompat(view, request.url.toString())
}
@@ -37,46 +37,45 @@ abstract class WebViewClientCompat : WebViewClient() {
}
final override fun shouldInterceptRequest(
view: WebView,
request: WebResourceRequest
view: WebView,
request: WebResourceRequest
): WebResourceResponse? {
return shouldInterceptRequestCompat(view, request.url.toString())
}
final override fun shouldInterceptRequest(
view: WebView,
url: String
view: WebView,
url: String
): WebResourceResponse? {
return shouldInterceptRequestCompat(view, url)
}
@TargetApi(Build.VERSION_CODES.M)
final override fun onReceivedError(
view: WebView,
request: WebResourceRequest,
error: WebResourceError
view: WebView,
request: WebResourceRequest,
error: WebResourceError
) {
onReceivedErrorCompat(view, error.errorCode, error.description?.toString(),
request.url.toString(), request.isForMainFrame)
}
final override fun onReceivedError(
view: WebView,
errorCode: Int,
description: String?,
failingUrl: String
view: WebView,
errorCode: Int,
description: String?,
failingUrl: String
) {
onReceivedErrorCompat(view, errorCode, description, failingUrl, failingUrl == view.url)
}
@TargetApi(Build.VERSION_CODES.M)
final override fun onReceivedHttpError(
view: WebView,
request: WebResourceRequest,
error: WebResourceResponse
view: WebView,
request: WebResourceRequest,
error: WebResourceResponse
) {
onReceivedErrorCompat(view, error.statusCode, error.reasonPhrase, request.url
.toString(), request.isForMainFrame)
}
}