Refactor away some unnecessary lambda expressions
This commit is contained in:
@@ -1039,29 +1039,29 @@ class ReaderActivity : BaseActivity() {
|
||||
.launchIn(lifecycleScope)
|
||||
|
||||
readerPreferences.showPageNumber().changes()
|
||||
.onEach { setPageNumberVisibility(it) }
|
||||
.onEach(::setPageNumberVisibility)
|
||||
.launchIn(lifecycleScope)
|
||||
|
||||
readerPreferences.trueColor().changes()
|
||||
.onEach { setTrueColor(it) }
|
||||
.onEach(::setTrueColor)
|
||||
.launchIn(lifecycleScope)
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
readerPreferences.cutoutShort().changes()
|
||||
.onEach { setCutoutShort(it) }
|
||||
.onEach(::setCutoutShort)
|
||||
.launchIn(lifecycleScope)
|
||||
}
|
||||
|
||||
readerPreferences.keepScreenOn().changes()
|
||||
.onEach { setKeepScreenOn(it) }
|
||||
.onEach(::setKeepScreenOn)
|
||||
.launchIn(lifecycleScope)
|
||||
|
||||
readerPreferences.customBrightness().changes()
|
||||
.onEach { setCustomBrightness(it) }
|
||||
.onEach(::setCustomBrightness)
|
||||
.launchIn(lifecycleScope)
|
||||
|
||||
readerPreferences.colorFilter().changes()
|
||||
.onEach { setColorFilter(it) }
|
||||
.onEach(::setColorFilter)
|
||||
.launchIn(lifecycleScope)
|
||||
|
||||
readerPreferences.colorFilterMode().changes()
|
||||
@@ -1138,7 +1138,7 @@ class ReaderActivity : BaseActivity() {
|
||||
if (enabled) {
|
||||
readerPreferences.customBrightnessValue().changes()
|
||||
.sample(100)
|
||||
.onEach { setCustomBrightnessValue(it) }
|
||||
.onEach(::setCustomBrightnessValue)
|
||||
.launchIn(lifecycleScope)
|
||||
} else {
|
||||
setCustomBrightnessValue(0)
|
||||
@@ -1152,7 +1152,7 @@ class ReaderActivity : BaseActivity() {
|
||||
if (enabled) {
|
||||
readerPreferences.colorFilterValue().changes()
|
||||
.sample(100)
|
||||
.onEach { setColorFilterValue(it) }
|
||||
.onEach(::setColorFilterValue)
|
||||
.launchIn(lifecycleScope)
|
||||
} else {
|
||||
binding.colorOverlay.isVisible = false
|
||||
|
||||
+4
-4
@@ -33,7 +33,7 @@ class ReaderColorFilterSettings @JvmOverloads constructor(context: Context, attr
|
||||
addView(binding.root)
|
||||
|
||||
readerPreferences.colorFilter().changes()
|
||||
.onEach { setColorFilter(it) }
|
||||
.onEach(::setColorFilter)
|
||||
.launchIn((context as ReaderActivity).lifecycleScope)
|
||||
|
||||
readerPreferences.colorFilterMode().changes()
|
||||
@@ -41,7 +41,7 @@ class ReaderColorFilterSettings @JvmOverloads constructor(context: Context, attr
|
||||
.launchIn(context.lifecycleScope)
|
||||
|
||||
readerPreferences.customBrightness().changes()
|
||||
.onEach { setCustomBrightness(it) }
|
||||
.onEach(::setCustomBrightness)
|
||||
.launchIn(context.lifecycleScope)
|
||||
|
||||
// Get color and update values
|
||||
@@ -141,7 +141,7 @@ class ReaderColorFilterSettings @JvmOverloads constructor(context: Context, attr
|
||||
if (enabled) {
|
||||
readerPreferences.customBrightnessValue().changes()
|
||||
.sample(100)
|
||||
.onEach { setCustomBrightnessValue(it) }
|
||||
.onEach(::setCustomBrightnessValue)
|
||||
.launchIn((context as ReaderActivity).lifecycleScope)
|
||||
} else {
|
||||
setCustomBrightnessValue(0, true)
|
||||
@@ -169,7 +169,7 @@ class ReaderColorFilterSettings @JvmOverloads constructor(context: Context, attr
|
||||
if (enabled) {
|
||||
readerPreferences.colorFilterValue().changes()
|
||||
.sample(100)
|
||||
.onEach { setColorFilterValue(it) }
|
||||
.onEach(::setColorFilterValue)
|
||||
.launchIn((context as ReaderActivity).lifecycleScope)
|
||||
}
|
||||
setColorFilterSeekBar(enabled)
|
||||
|
||||
+1
-1
@@ -63,7 +63,7 @@ class PagerTransitionHolder(
|
||||
|
||||
transitionView.bind(transition, viewer.downloadManager, viewer.activity.viewModel.manga)
|
||||
|
||||
transition.to?.let { observeStatus(it) }
|
||||
transition.to?.let(::observeStatus)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -74,9 +74,7 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer {
|
||||
setChaptersInternal(viewerChapters)
|
||||
awaitingIdleViewerChapters = null
|
||||
if (viewerChapters.currChapter.pages?.size == 1) {
|
||||
adapter.nextTransition?.to?.let {
|
||||
activity.requestPreloadChapter(it)
|
||||
}
|
||||
adapter.nextTransition?.to?.let(activity::requestPreloadChapter)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -234,9 +232,7 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer {
|
||||
val inPreloadRange = pages.size - page.number < 5
|
||||
if (inPreloadRange && allowPreload && page.chapter == adapter.currentChapter) {
|
||||
logcat { "Request preload next chapter because we're at page ${page.number} of ${pages.size}" }
|
||||
adapter.nextTransition?.to?.let {
|
||||
activity.requestPreloadChapter(it)
|
||||
}
|
||||
adapter.nextTransition?.to?.let(activity::requestPreloadChapter)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -320,7 +316,7 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer {
|
||||
*/
|
||||
protected open fun moveRight() {
|
||||
if (pager.currentItem != adapter.count - 1) {
|
||||
val holder = (currentPage as? ReaderPage)?.let { getPageHolder(it) }
|
||||
val holder = (currentPage as? ReaderPage)?.let(::getPageHolder)
|
||||
if (holder != null && config.navigateToPan && holder.canPanRight()) {
|
||||
holder.panRight()
|
||||
} else {
|
||||
@@ -334,7 +330,7 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer {
|
||||
*/
|
||||
protected open fun moveLeft() {
|
||||
if (pager.currentItem != 0) {
|
||||
val holder = (currentPage as? ReaderPage)?.let { getPageHolder(it) }
|
||||
val holder = (currentPage as? ReaderPage)?.let(::getPageHolder)
|
||||
if (holder != null && config.navigateToPan && holder.canPanLeft()) {
|
||||
holder.panLeft()
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user