diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupCreateService.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupCreateService.kt index 19fc67bc9..9f3d577e7 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupCreateService.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupCreateService.kt @@ -84,9 +84,6 @@ class BackupCreateService : IntentService(NAME) { // Create root object val root = JsonObject() - // Create information object - val information = JsonObject() - // Create manga array val mangaEntries = JsonArray() diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupRestoreService.kt b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupRestoreService.kt index 4179e0f0a..f3db5c9d4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupRestoreService.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/backup/BackupRestoreService.kt @@ -317,8 +317,8 @@ class BackupRestoreService : Service() { manga } .filter { it.id != null } - .flatMap { manga -> - chapterFetchObservable(source, manga, chapters) + .flatMap { + chapterFetchObservable(source, it, chapters) // Convert to the manga that contains new chapters. .map { manga } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadService.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadService.kt index 0a65f2119..ae2cf2111 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadService.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadService.kt @@ -122,7 +122,7 @@ class DownloadService : Service() { .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe({ state -> onNetworkStateChanged(state) - }, { error -> + }, { _ -> toast(R.string.download_queue_error) stopSelf() }) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt index da232f869..7ffe8c4f8 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt @@ -287,7 +287,7 @@ class Downloader(private val context: Context, private val provider: DownloadPro } return pageListObservable - .doOnNext { pages -> + .doOnNext { _ -> // Delete all temporary (unfinished) files tmpDir.listFiles() ?.filter { it.name!!.endsWith(".tmp") } @@ -303,7 +303,7 @@ class Downloader(private val context: Context, private val provider: DownloadPro // Do when page is downloaded. .doOnNext { notifier.onProgressChange(download, queue) } .toList() - .map { pages -> download } + .map { _ -> download } // Do after download completes .doOnNext { ensureSuccessfulDownload(download, tmpDir, chapterDirname) } // If the page list threw, it will resume here diff --git a/app/src/main/java/eu/kanade/tachiyomi/network/PersistentCookieStore.kt b/app/src/main/java/eu/kanade/tachiyomi/network/PersistentCookieStore.kt index 766bb49a2..c7154deca 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/network/PersistentCookieStore.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/network/PersistentCookieStore.kt @@ -17,7 +17,7 @@ class PersistentCookieStore(context: Context) { val cookies = value as? Set if (cookies != null) { try { - val url = HttpUrl.parse("http://$key") + val url = HttpUrl.parse("http://$key") ?: continue val nonExpiredCookies = cookies.mapNotNull { Cookie.parse(url, it) } .filter { !it.hasExpired() } cookieMap.put(key, nonExpiredCookies) diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/LocalSource.kt b/app/src/main/java/eu/kanade/tachiyomi/source/LocalSource.kt index 07421720f..a7cf4b656 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/LocalSource.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/LocalSource.kt @@ -76,13 +76,13 @@ class LocalSource(private val context: Context) : CatalogueSource { val state = ((if (filters.isEmpty()) POPULAR_FILTERS else filters)[0] as OrderBy).state when (state?.index) { 0 -> { - if (state!!.ascending) + if (state.ascending) mangaDirs = mangaDirs.sortedBy { it.name.toLowerCase(Locale.ENGLISH) } else mangaDirs = mangaDirs.sortedByDescending { it.name.toLowerCase(Locale.ENGLISH) } } 1 -> { - if (state!!.ascending) + if (state.ascending) mangaDirs = mangaDirs.sortedBy(File::lastModified) else mangaDirs = mangaDirs.sortedByDescending(File::lastModified) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/filter/SelectItem.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/filter/SelectItem.kt index 1db147095..79af4b5d9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/filter/SelectItem.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/catalogue/filter/SelectItem.kt @@ -32,8 +32,8 @@ open class SelectItem(val filter: Filter.Select<*>) : AbstractFlexibleItem - filter.state = position + spinner.onItemSelectedListener = IgnoreFirstSpinnerListener { pos -> + filter.state = pos } spinner.setSelection(filter.state) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadPresenter.kt index 4e5b5e288..0577176e9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/download/DownloadPresenter.kt @@ -33,7 +33,7 @@ class DownloadPresenter : BasePresenter() { downloadQueue.getUpdatedObservable() .observeOn(AndroidSchedulers.mainThread()) .map { ArrayList(it) } - .subscribeLatestCache(DownloadController::onNextDownloads, { view, error -> + .subscribeLatestCache(DownloadController::onNextDownloads, { _, error -> Timber.e(error) }) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackPresenter.kt index b9e152ba4..bac625de3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/track/TrackPresenter.kt @@ -67,7 +67,7 @@ class TrackPresenter( .toList() .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) - .subscribeFirst({ view, result -> view.onRefreshDone() }, + .subscribeFirst({ view, _ -> view.onRefreshDone() }, TrackController::onRefreshError) } @@ -99,7 +99,7 @@ class TrackPresenter( .flatMap { db.insertTrack(track).asRxObservable() } .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) - .subscribeFirst({ view, result -> view.onRefreshDone() }, + .subscribeFirst({ view, _ -> view.onRefreshDone() }, { view, error -> view.onRefreshError(error) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt index 1c73097af..3e4e3ebf3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt @@ -176,8 +176,8 @@ class ReaderActivity : BaseRxActivity() { .content(getString(R.string.confirm_update_manga_sync, chapterToUpdate)) .positiveText(android.R.string.yes) .negativeText(android.R.string.no) - .onPositive { dialog, which -> presenter.updateTrackLastChapterRead(chapterToUpdate) } - .onAny { dialog1, which1 -> super.onBackPressed() } + .onPositive { _, _ -> presenter.updateTrackLastChapterRead(chapterToUpdate) } + .onAny { _, _ -> super.onBackPressed() } .show() } else { presenter.updateTrackLastChapterRead(chapterToUpdate) @@ -237,7 +237,7 @@ class ReaderActivity : BaseRxActivity() { .title(getString(R.string.options)) .items(R.array.reader_image_options) .itemsIds(R.array.reader_image_options_values) - .itemsCallback { materialDialog, view, i, charSequence -> + .itemsCallback { _, _, i, _ -> when (i) { 0 -> setImageAsCover(page) 1 -> shareImage(page) @@ -378,7 +378,7 @@ class ReaderActivity : BaseRxActivity() { private fun initializeBottomMenu() { // Intercept all events in this layout - reader_menu_bottom.setOnTouchListener { v, event -> true } + reader_menu_bottom.setOnTouchListener { _, _ -> true } page_seekbar.setOnSeekBarChangeListener(object : SimpleSeekBarListener() { override fun onProgressChanged(seekBar: SeekBar, value: Int, fromUser: Boolean) { @@ -595,7 +595,7 @@ class ReaderActivity : BaseRxActivity() { .content(getString(R.string.confirm_set_image_as_cover)) .positiveText(android.R.string.yes) .negativeText(android.R.string.no) - .onPositive { dialog, which -> presenter.setImageAsCover(page) } + .onPositive { _, _ -> presenter.setImageAsCover(page) } .show() } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderCustomFilterDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderCustomFilterDialog.kt index 973869031..7e3ac1003 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderCustomFilterDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderCustomFilterDialog.kt @@ -106,12 +106,12 @@ class ReaderCustomFilterDialog : DialogFragment() { // Set listeners switch_color_filter.isChecked = preferences.colorFilter().getOrDefault() - switch_color_filter.setOnCheckedChangeListener { v, isChecked -> + switch_color_filter.setOnCheckedChangeListener { _, isChecked -> preferences.colorFilter().set(isChecked) } custom_brightness.isChecked = preferences.customBrightness().getOrDefault() - custom_brightness.setOnCheckedChangeListener { v, isChecked -> + custom_brightness.setOnCheckedChangeListener { _, isChecked -> preferences.customBrightness().set(isChecked) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt index 8ed6a6557..973d57330 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt @@ -153,7 +153,7 @@ class ReaderPresenter( restartableLatestCache(LOAD_ACTIVE_CHAPTER, { loadChapterObservable(chapter) }, - { view, chapter -> view.onChapterReady(this.chapter) }, + { view, _ -> view.onChapterReady(this.chapter) }, { view, error -> view.onChapterError(error) }) if (savedState == null) { @@ -314,7 +314,7 @@ class ReaderPresenter( .observeOn(AndroidSchedulers.mainThread()) .subscribeLatestCache({ view, chapter -> view.onAppendChapter(chapter) - }, { view, error -> + }, { view, _ -> view.onChapterAppendError() }) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderSettingsDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderSettingsDialog.kt index 32e6e6d34..fa09cc120 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderSettingsDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderSettingsDialog.kt @@ -75,17 +75,17 @@ class ReaderSettingsDialog : DialogFragment() { background_color.setSelection(preferences.readerTheme().getOrDefault(), false) show_page_number.isChecked = preferences.showPageNumber().getOrDefault() - show_page_number.setOnCheckedChangeListener { v, isChecked -> + show_page_number.setOnCheckedChangeListener { _, isChecked -> preferences.showPageNumber().set(isChecked) } fullscreen.isChecked = preferences.fullscreen().getOrDefault() - fullscreen.setOnCheckedChangeListener { v, isChecked -> + fullscreen.setOnCheckedChangeListener { _, isChecked -> preferences.fullscreen().set(isChecked) } crop_borders.isChecked = preferences.cropBorders().getOrDefault() - crop_borders.setOnCheckedChangeListener { v, isChecked -> + crop_borders.setOnCheckedChangeListener { _, isChecked -> preferences.cropBorders().set(isChecked) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PageView.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PageView.kt index 1c2e3cd53..1b0fef4ce 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PageView.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PageView.kt @@ -70,7 +70,7 @@ class PageView @JvmOverloads constructor(context: Context, attrs: AttributeSet? setBitmapDecoderClass(reader.bitmapDecoderClass) setVerticalScrollingParent(reader is VerticalReader) setCropBorders(reader.cropBorders) - setOnTouchListener { v, motionEvent -> reader.gestureDetector.onTouchEvent(motionEvent) } + setOnTouchListener { _, motionEvent -> reader.gestureDetector.onTouchEvent(motionEvent) } setOnLongClickListener { reader.onLongClick(page) } setOnImageEventListener(object : SubsamplingScaleImageView.DefaultOnImageEventListener() { override fun onReady() { @@ -83,7 +83,7 @@ class PageView @JvmOverloads constructor(context: Context, attrs: AttributeSet? }) } - retry_button.setOnTouchListener { v, event -> + retry_button.setOnTouchListener { _, event -> if (event.action == MotionEvent.ACTION_UP) { activity.presenter.retryPage(page) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonAdapter.kt index 373902027..6871e6bab 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonAdapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/webtoon/WebtoonAdapter.kt @@ -22,7 +22,7 @@ class WebtoonAdapter(val fragment: WebtoonReader) : RecyclerView.Adapter fragment.imageGestureDetector.onTouchEvent(ev) } + val touchListener = View.OnTouchListener { _, ev -> fragment.imageGestureDetector.onTouchEvent(ev) } /** * Returns the number of pages. diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/AnilistLoginActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/AnilistLoginActivity.kt index af0b6ffc7..982e74fe1 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/AnilistLoginActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/AnilistLoginActivity.kt @@ -30,7 +30,7 @@ class AnilistLoginActivity : AppCompatActivity() { .observeOn(AndroidSchedulers.mainThread()) .subscribe({ returnToSettings() - }, { error -> + }, { _ -> returnToSettings() }) } else { diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/ContextExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/ContextExtensions.kt index 663e6aa12..b777c87b3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/ContextExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/ContextExtensions.kt @@ -143,6 +143,7 @@ fun Context.unregisterLocalReceiver(receiver: BroadcastReceiver) { fun Context.isServiceRunning(serviceClass: Class<*>): Boolean { val className = serviceClass.name val manager = getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager + @Suppress("DEPRECATION") return manager.getRunningServices(Integer.MAX_VALUE) .any { className == it.service.className } } \ No newline at end of file diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/FABAnimationBase.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/FABAnimationBase.kt index 7a847f187..eaa4201e1 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/FABAnimationBase.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/FABAnimationBase.kt @@ -10,15 +10,16 @@ abstract class FABAnimationBase : FloatingActionButton.Behavior() { var isAnimatingOut = false override fun onStartNestedScroll(coordinatorLayout: CoordinatorLayout, child: FloatingActionButton, - directTargetChild: View, target: View, nestedScrollAxes: Int): Boolean { + directTargetChild: View, target: View, axes: Int, type: Int): Boolean { // Ensure we react to vertical scrolling - return nestedScrollAxes == ViewCompat.SCROLL_AXIS_VERTICAL || - super.onStartNestedScroll(coordinatorLayout, child, directTargetChild, target, nestedScrollAxes) + return axes == ViewCompat.SCROLL_AXIS_VERTICAL || + super.onStartNestedScroll(coordinatorLayout, child, directTargetChild, target, axes, type) } - override fun onNestedScroll(coordinatorLayout: CoordinatorLayout, child: FloatingActionButton, target: View, - dxConsumed: Int, dyConsumed: Int, dxUnconsumed: Int, dyUnconsumed: Int) { - super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed) + override fun onNestedScroll(coordinatorLayout: CoordinatorLayout, child: FloatingActionButton, + target: View, dxConsumed: Int, dyConsumed: Int, dxUnconsumed: Int, + dyUnconsumed: Int, type: Int) { + super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed, type) if (dyConsumed > 0 && !isAnimatingOut && child.visibility == View.VISIBLE) { // User scrolled down and the FAB is currently visible -> hide the FAB animateOut(child) diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/FABAnimationUpDown.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/FABAnimationUpDown.kt index ea9e0f89e..e1c4245d2 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/FABAnimationUpDown.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/FABAnimationUpDown.kt @@ -9,6 +9,7 @@ import android.view.animation.Animation import android.view.animation.AnimationUtils import eu.kanade.tachiyomi.R +@Suppress("unused", "UNUSED_PARAMETER") class FABAnimationUpDown @JvmOverloads constructor(ctx: Context, attrs: AttributeSet? = null) : FABAnimationBase() { private val INTERPOLATOR = FastOutSlowInInterpolator() diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/SimpleNavigationView.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/SimpleNavigationView.kt index 8df9fd252..efae6f62f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/SimpleNavigationView.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/SimpleNavigationView.kt @@ -48,6 +48,7 @@ open class SimpleNavigationView @JvmOverloads constructor( R.styleable.NavigationView_elevation, 0).toFloat()) } + @Suppress("DEPRECATION") ViewCompat.setFitsSystemWindows(this, a.getBoolean(R.styleable.NavigationView_android_fitsSystemWindows, false)) @@ -61,6 +62,7 @@ open class SimpleNavigationView @JvmOverloads constructor( /** * Overriden to measure the width of the navigation view. */ + @SuppressLint("SwitchIntDef") override fun onMeasure(widthSpec: Int, heightSpec: Int) { val width = when (MeasureSpec.getMode(widthSpec)) { MeasureSpec.AT_MOST -> MeasureSpec.makeMeasureSpec( diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/preference/LoginDialogPreference.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/preference/LoginDialogPreference.kt index 1b355d490..b27c77c62 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/preference/LoginDialogPreference.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/preference/LoginDialogPreference.kt @@ -31,14 +31,14 @@ abstract class LoginDialogPreference(bundle: Bundle? = null) : DialogController( .negativeText(android.R.string.cancel) .build() - onViewCreated(dialog.view, savedState) + onViewCreated(dialog.view) return dialog } - fun onViewCreated(view: View, savedState: Bundle?) { + fun onViewCreated(view: View) { v = view.apply { - show_password.setOnCheckedChangeListener { v, isChecked -> + show_password.setOnCheckedChangeListener { _, isChecked -> if (isChecked) password.transformationMethod = null else