Fix many compilation warnings

This commit is contained in:
inorichi 2017-10-28 19:12:17 +02:00
parent 827792c4f0
commit 4ae00c80ca
21 changed files with 43 additions and 41 deletions

View File

@ -84,9 +84,6 @@ class BackupCreateService : IntentService(NAME) {
// Create root object // Create root object
val root = JsonObject() val root = JsonObject()
// Create information object
val information = JsonObject()
// Create manga array // Create manga array
val mangaEntries = JsonArray() val mangaEntries = JsonArray()

View File

@ -317,8 +317,8 @@ class BackupRestoreService : Service() {
manga manga
} }
.filter { it.id != null } .filter { it.id != null }
.flatMap { manga -> .flatMap {
chapterFetchObservable(source, manga, chapters) chapterFetchObservable(source, it, chapters)
// Convert to the manga that contains new chapters. // Convert to the manga that contains new chapters.
.map { manga } .map { manga }
} }

View File

@ -122,7 +122,7 @@ class DownloadService : Service() {
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe({ state -> onNetworkStateChanged(state) .subscribe({ state -> onNetworkStateChanged(state)
}, { error -> }, { _ ->
toast(R.string.download_queue_error) toast(R.string.download_queue_error)
stopSelf() stopSelf()
}) })

View File

@ -287,7 +287,7 @@ class Downloader(private val context: Context, private val provider: DownloadPro
} }
return pageListObservable return pageListObservable
.doOnNext { pages -> .doOnNext { _ ->
// Delete all temporary (unfinished) files // Delete all temporary (unfinished) files
tmpDir.listFiles() tmpDir.listFiles()
?.filter { it.name!!.endsWith(".tmp") } ?.filter { it.name!!.endsWith(".tmp") }
@ -303,7 +303,7 @@ class Downloader(private val context: Context, private val provider: DownloadPro
// Do when page is downloaded. // Do when page is downloaded.
.doOnNext { notifier.onProgressChange(download, queue) } .doOnNext { notifier.onProgressChange(download, queue) }
.toList() .toList()
.map { pages -> download } .map { _ -> download }
// Do after download completes // Do after download completes
.doOnNext { ensureSuccessfulDownload(download, tmpDir, chapterDirname) } .doOnNext { ensureSuccessfulDownload(download, tmpDir, chapterDirname) }
// If the page list threw, it will resume here // If the page list threw, it will resume here

View File

@ -17,7 +17,7 @@ class PersistentCookieStore(context: Context) {
val cookies = value as? Set<String> val cookies = value as? Set<String>
if (cookies != null) { if (cookies != null) {
try { try {
val url = HttpUrl.parse("http://$key") val url = HttpUrl.parse("http://$key") ?: continue
val nonExpiredCookies = cookies.mapNotNull { Cookie.parse(url, it) } val nonExpiredCookies = cookies.mapNotNull { Cookie.parse(url, it) }
.filter { !it.hasExpired() } .filter { !it.hasExpired() }
cookieMap.put(key, nonExpiredCookies) cookieMap.put(key, nonExpiredCookies)

View File

@ -76,13 +76,13 @@ class LocalSource(private val context: Context) : CatalogueSource {
val state = ((if (filters.isEmpty()) POPULAR_FILTERS else filters)[0] as OrderBy).state val state = ((if (filters.isEmpty()) POPULAR_FILTERS else filters)[0] as OrderBy).state
when (state?.index) { when (state?.index) {
0 -> { 0 -> {
if (state!!.ascending) if (state.ascending)
mangaDirs = mangaDirs.sortedBy { it.name.toLowerCase(Locale.ENGLISH) } mangaDirs = mangaDirs.sortedBy { it.name.toLowerCase(Locale.ENGLISH) }
else else
mangaDirs = mangaDirs.sortedByDescending { it.name.toLowerCase(Locale.ENGLISH) } mangaDirs = mangaDirs.sortedByDescending { it.name.toLowerCase(Locale.ENGLISH) }
} }
1 -> { 1 -> {
if (state!!.ascending) if (state.ascending)
mangaDirs = mangaDirs.sortedBy(File::lastModified) mangaDirs = mangaDirs.sortedBy(File::lastModified)
else else
mangaDirs = mangaDirs.sortedByDescending(File::lastModified) mangaDirs = mangaDirs.sortedByDescending(File::lastModified)

View File

@ -32,8 +32,8 @@ open class SelectItem(val filter: Filter.Select<*>) : AbstractFlexibleItem<Selec
android.R.layout.simple_spinner_item, filter.values).apply { android.R.layout.simple_spinner_item, filter.values).apply {
setDropDownViewResource(R.layout.common_spinner_item) setDropDownViewResource(R.layout.common_spinner_item)
} }
spinner.onItemSelectedListener = IgnoreFirstSpinnerListener { position -> spinner.onItemSelectedListener = IgnoreFirstSpinnerListener { pos ->
filter.state = position filter.state = pos
} }
spinner.setSelection(filter.state) spinner.setSelection(filter.state)
} }

View File

@ -33,7 +33,7 @@ class DownloadPresenter : BasePresenter<DownloadController>() {
downloadQueue.getUpdatedObservable() downloadQueue.getUpdatedObservable()
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.map { ArrayList(it) } .map { ArrayList(it) }
.subscribeLatestCache(DownloadController::onNextDownloads, { view, error -> .subscribeLatestCache(DownloadController::onNextDownloads, { _, error ->
Timber.e(error) Timber.e(error)
}) })
} }

View File

@ -67,7 +67,7 @@ class TrackPresenter(
.toList() .toList()
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribeFirst({ view, result -> view.onRefreshDone() }, .subscribeFirst({ view, _ -> view.onRefreshDone() },
TrackController::onRefreshError) TrackController::onRefreshError)
} }
@ -99,7 +99,7 @@ class TrackPresenter(
.flatMap { db.insertTrack(track).asRxObservable() } .flatMap { db.insertTrack(track).asRxObservable() }
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribeFirst({ view, result -> view.onRefreshDone() }, .subscribeFirst({ view, _ -> view.onRefreshDone() },
{ view, error -> { view, error ->
view.onRefreshError(error) view.onRefreshError(error)

View File

@ -176,8 +176,8 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
.content(getString(R.string.confirm_update_manga_sync, chapterToUpdate)) .content(getString(R.string.confirm_update_manga_sync, chapterToUpdate))
.positiveText(android.R.string.yes) .positiveText(android.R.string.yes)
.negativeText(android.R.string.no) .negativeText(android.R.string.no)
.onPositive { dialog, which -> presenter.updateTrackLastChapterRead(chapterToUpdate) } .onPositive { _, _ -> presenter.updateTrackLastChapterRead(chapterToUpdate) }
.onAny { dialog1, which1 -> super.onBackPressed() } .onAny { _, _ -> super.onBackPressed() }
.show() .show()
} else { } else {
presenter.updateTrackLastChapterRead(chapterToUpdate) presenter.updateTrackLastChapterRead(chapterToUpdate)
@ -237,7 +237,7 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
.title(getString(R.string.options)) .title(getString(R.string.options))
.items(R.array.reader_image_options) .items(R.array.reader_image_options)
.itemsIds(R.array.reader_image_options_values) .itemsIds(R.array.reader_image_options_values)
.itemsCallback { materialDialog, view, i, charSequence -> .itemsCallback { _, _, i, _ ->
when (i) { when (i) {
0 -> setImageAsCover(page) 0 -> setImageAsCover(page)
1 -> shareImage(page) 1 -> shareImage(page)
@ -378,7 +378,7 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
private fun initializeBottomMenu() { private fun initializeBottomMenu() {
// Intercept all events in this layout // Intercept all events in this layout
reader_menu_bottom.setOnTouchListener { v, event -> true } reader_menu_bottom.setOnTouchListener { _, _ -> true }
page_seekbar.setOnSeekBarChangeListener(object : SimpleSeekBarListener() { page_seekbar.setOnSeekBarChangeListener(object : SimpleSeekBarListener() {
override fun onProgressChanged(seekBar: SeekBar, value: Int, fromUser: Boolean) { override fun onProgressChanged(seekBar: SeekBar, value: Int, fromUser: Boolean) {
@ -595,7 +595,7 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
.content(getString(R.string.confirm_set_image_as_cover)) .content(getString(R.string.confirm_set_image_as_cover))
.positiveText(android.R.string.yes) .positiveText(android.R.string.yes)
.negativeText(android.R.string.no) .negativeText(android.R.string.no)
.onPositive { dialog, which -> presenter.setImageAsCover(page) } .onPositive { _, _ -> presenter.setImageAsCover(page) }
.show() .show()
} }

View File

@ -106,12 +106,12 @@ class ReaderCustomFilterDialog : DialogFragment() {
// Set listeners // Set listeners
switch_color_filter.isChecked = preferences.colorFilter().getOrDefault() switch_color_filter.isChecked = preferences.colorFilter().getOrDefault()
switch_color_filter.setOnCheckedChangeListener { v, isChecked -> switch_color_filter.setOnCheckedChangeListener { _, isChecked ->
preferences.colorFilter().set(isChecked) preferences.colorFilter().set(isChecked)
} }
custom_brightness.isChecked = preferences.customBrightness().getOrDefault() custom_brightness.isChecked = preferences.customBrightness().getOrDefault()
custom_brightness.setOnCheckedChangeListener { v, isChecked -> custom_brightness.setOnCheckedChangeListener { _, isChecked ->
preferences.customBrightness().set(isChecked) preferences.customBrightness().set(isChecked)
} }

View File

@ -153,7 +153,7 @@ class ReaderPresenter(
restartableLatestCache(LOAD_ACTIVE_CHAPTER, restartableLatestCache(LOAD_ACTIVE_CHAPTER,
{ loadChapterObservable(chapter) }, { loadChapterObservable(chapter) },
{ view, chapter -> view.onChapterReady(this.chapter) }, { view, _ -> view.onChapterReady(this.chapter) },
{ view, error -> view.onChapterError(error) }) { view, error -> view.onChapterError(error) })
if (savedState == null) { if (savedState == null) {
@ -314,7 +314,7 @@ class ReaderPresenter(
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribeLatestCache({ view, chapter -> .subscribeLatestCache({ view, chapter ->
view.onAppendChapter(chapter) view.onAppendChapter(chapter)
}, { view, error -> }, { view, _ ->
view.onChapterAppendError() view.onChapterAppendError()
}) })
} }

View File

@ -75,17 +75,17 @@ class ReaderSettingsDialog : DialogFragment() {
background_color.setSelection(preferences.readerTheme().getOrDefault(), false) background_color.setSelection(preferences.readerTheme().getOrDefault(), false)
show_page_number.isChecked = preferences.showPageNumber().getOrDefault() show_page_number.isChecked = preferences.showPageNumber().getOrDefault()
show_page_number.setOnCheckedChangeListener { v, isChecked -> show_page_number.setOnCheckedChangeListener { _, isChecked ->
preferences.showPageNumber().set(isChecked) preferences.showPageNumber().set(isChecked)
} }
fullscreen.isChecked = preferences.fullscreen().getOrDefault() fullscreen.isChecked = preferences.fullscreen().getOrDefault()
fullscreen.setOnCheckedChangeListener { v, isChecked -> fullscreen.setOnCheckedChangeListener { _, isChecked ->
preferences.fullscreen().set(isChecked) preferences.fullscreen().set(isChecked)
} }
crop_borders.isChecked = preferences.cropBorders().getOrDefault() crop_borders.isChecked = preferences.cropBorders().getOrDefault()
crop_borders.setOnCheckedChangeListener { v, isChecked -> crop_borders.setOnCheckedChangeListener { _, isChecked ->
preferences.cropBorders().set(isChecked) preferences.cropBorders().set(isChecked)
} }
} }

View File

@ -70,7 +70,7 @@ class PageView @JvmOverloads constructor(context: Context, attrs: AttributeSet?
setBitmapDecoderClass(reader.bitmapDecoderClass) setBitmapDecoderClass(reader.bitmapDecoderClass)
setVerticalScrollingParent(reader is VerticalReader) setVerticalScrollingParent(reader is VerticalReader)
setCropBorders(reader.cropBorders) setCropBorders(reader.cropBorders)
setOnTouchListener { v, motionEvent -> reader.gestureDetector.onTouchEvent(motionEvent) } setOnTouchListener { _, motionEvent -> reader.gestureDetector.onTouchEvent(motionEvent) }
setOnLongClickListener { reader.onLongClick(page) } setOnLongClickListener { reader.onLongClick(page) }
setOnImageEventListener(object : SubsamplingScaleImageView.DefaultOnImageEventListener() { setOnImageEventListener(object : SubsamplingScaleImageView.DefaultOnImageEventListener() {
override fun onReady() { 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) { if (event.action == MotionEvent.ACTION_UP) {
activity.presenter.retryPage(page) activity.presenter.retryPage(page)
} }

View File

@ -22,7 +22,7 @@ class WebtoonAdapter(val fragment: WebtoonReader) : RecyclerView.Adapter<Webtoon
/** /**
* Touch listener for images in holders. * Touch listener for images in holders.
*/ */
val touchListener = View.OnTouchListener { v, ev -> fragment.imageGestureDetector.onTouchEvent(ev) } val touchListener = View.OnTouchListener { _, ev -> fragment.imageGestureDetector.onTouchEvent(ev) }
/** /**
* Returns the number of pages. * Returns the number of pages.

View File

@ -30,7 +30,7 @@ class AnilistLoginActivity : AppCompatActivity() {
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe({ .subscribe({
returnToSettings() returnToSettings()
}, { error -> }, { _ ->
returnToSettings() returnToSettings()
}) })
} else { } else {

View File

@ -143,6 +143,7 @@ fun Context.unregisterLocalReceiver(receiver: BroadcastReceiver) {
fun Context.isServiceRunning(serviceClass: Class<*>): Boolean { fun Context.isServiceRunning(serviceClass: Class<*>): Boolean {
val className = serviceClass.name val className = serviceClass.name
val manager = getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager val manager = getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
@Suppress("DEPRECATION")
return manager.getRunningServices(Integer.MAX_VALUE) return manager.getRunningServices(Integer.MAX_VALUE)
.any { className == it.service.className } .any { className == it.service.className }
} }

View File

@ -10,15 +10,16 @@ abstract class FABAnimationBase : FloatingActionButton.Behavior() {
var isAnimatingOut = false var isAnimatingOut = false
override fun onStartNestedScroll(coordinatorLayout: CoordinatorLayout, child: FloatingActionButton, 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 // Ensure we react to vertical scrolling
return nestedScrollAxes == ViewCompat.SCROLL_AXIS_VERTICAL || return axes == ViewCompat.SCROLL_AXIS_VERTICAL ||
super.onStartNestedScroll(coordinatorLayout, child, directTargetChild, target, nestedScrollAxes) super.onStartNestedScroll(coordinatorLayout, child, directTargetChild, target, axes, type)
} }
override fun onNestedScroll(coordinatorLayout: CoordinatorLayout, child: FloatingActionButton, target: View, override fun onNestedScroll(coordinatorLayout: CoordinatorLayout, child: FloatingActionButton,
dxConsumed: Int, dyConsumed: Int, dxUnconsumed: Int, dyUnconsumed: Int) { target: View, dxConsumed: Int, dyConsumed: Int, dxUnconsumed: Int,
super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed) dyUnconsumed: Int, type: Int) {
super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed, type)
if (dyConsumed > 0 && !isAnimatingOut && child.visibility == View.VISIBLE) { if (dyConsumed > 0 && !isAnimatingOut && child.visibility == View.VISIBLE) {
// User scrolled down and the FAB is currently visible -> hide the FAB // User scrolled down and the FAB is currently visible -> hide the FAB
animateOut(child) animateOut(child)

View File

@ -9,6 +9,7 @@ import android.view.animation.Animation
import android.view.animation.AnimationUtils import android.view.animation.AnimationUtils
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
@Suppress("unused", "UNUSED_PARAMETER")
class FABAnimationUpDown @JvmOverloads constructor(ctx: Context, attrs: AttributeSet? = null) : FABAnimationBase() { class FABAnimationUpDown @JvmOverloads constructor(ctx: Context, attrs: AttributeSet? = null) : FABAnimationBase() {
private val INTERPOLATOR = FastOutSlowInInterpolator() private val INTERPOLATOR = FastOutSlowInInterpolator()

View File

@ -48,6 +48,7 @@ open class SimpleNavigationView @JvmOverloads constructor(
R.styleable.NavigationView_elevation, 0).toFloat()) R.styleable.NavigationView_elevation, 0).toFloat())
} }
@Suppress("DEPRECATION")
ViewCompat.setFitsSystemWindows(this, ViewCompat.setFitsSystemWindows(this,
a.getBoolean(R.styleable.NavigationView_android_fitsSystemWindows, false)) 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. * Overriden to measure the width of the navigation view.
*/ */
@SuppressLint("SwitchIntDef")
override fun onMeasure(widthSpec: Int, heightSpec: Int) { override fun onMeasure(widthSpec: Int, heightSpec: Int) {
val width = when (MeasureSpec.getMode(widthSpec)) { val width = when (MeasureSpec.getMode(widthSpec)) {
MeasureSpec.AT_MOST -> MeasureSpec.makeMeasureSpec( MeasureSpec.AT_MOST -> MeasureSpec.makeMeasureSpec(

View File

@ -31,14 +31,14 @@ abstract class LoginDialogPreference(bundle: Bundle? = null) : DialogController(
.negativeText(android.R.string.cancel) .negativeText(android.R.string.cancel)
.build() .build()
onViewCreated(dialog.view, savedState) onViewCreated(dialog.view)
return dialog return dialog
} }
fun onViewCreated(view: View, savedState: Bundle?) { fun onViewCreated(view: View) {
v = view.apply { v = view.apply {
show_password.setOnCheckedChangeListener { v, isChecked -> show_password.setOnCheckedChangeListener { _, isChecked ->
if (isChecked) if (isChecked)
password.transformationMethod = null password.transformationMethod = null
else else