wrap more if's and else with braces

This commit is contained in:
CarlosEsco 2020-04-22 12:50:52 -04:00
parent 4e44ee3605
commit ca633b1f95

View File

@ -174,11 +174,11 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>(),
a.recycle() a.recycle()
setNotchCutoutMode() setNotchCutoutMode()
val systemUiFlag = when(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){ val systemUiFlag = when (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
true -> View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR true -> View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
false -> View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR false -> View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
} }
reader_layout.systemUiVisibility =when(lightStatusBar){ reader_layout.systemUiVisibility = when (lightStatusBar) {
true -> reader_layout.systemUiVisibility.or(systemUiFlag) true -> reader_layout.systemUiVisibility.or(systemUiFlag)
false -> reader_layout.systemUiVisibility.rem(systemUiFlag) false -> reader_layout.systemUiVisibility.rem(systemUiFlag)
} }
@ -194,7 +194,7 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>(),
} }
NotificationReceiver.dismissNotification(this, manga.hashCode(), Notifications.ID_NEW_CHAPTERS) NotificationReceiver.dismissNotification(this, manga.hashCode(), Notifications.ID_NEW_CHAPTERS)
when(chapter> -1){ when (chapter > -1) {
true -> presenter.init(manga, chapter) true -> presenter.init(manga, chapter)
false -> presenter.init(manga, chapterUrl) false -> presenter.init(manga, chapterUrl)
} }
@ -315,8 +315,10 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>(),
private fun initializeMenu() { private fun initializeMenu() {
// Set toolbar // Set toolbar
setSupportActionBar(toolbar) setSupportActionBar(toolbar)
val primaryColor = ColorUtils.setAlphaComponent(getResourceColor(R.attr.colorSecondary), val primaryColor = ColorUtils.setAlphaComponent(
200) getResourceColor(R.attr.colorSecondary),
200
)
appbar.setBackgroundColor(primaryColor) appbar.setBackgroundColor(primaryColor)
window.statusBarColor = Color.TRANSPARENT window.statusBarColor = Color.TRANSPARENT
supportActionBar?.setDisplayHomeAsUpEnabled(true) supportActionBar?.setDisplayHomeAsUpEnabled(true)
@ -340,7 +342,8 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>(),
chapters_bottom_sheet.sheetBehavior?.state = BottomSheetBehavior.STATE_HIDDEN chapters_bottom_sheet.sheetBehavior?.state = BottomSheetBehavior.STATE_HIDDEN
reader_menu.doOnApplyWindowInsets { v, insets, _ -> reader_menu.doOnApplyWindowInsets { v, insets, _ ->
sheetManageNavColor = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && (insets sheetManageNavColor = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && (insets
.systemWindowInsetBottom != insets.tappableElementInsets.bottom)) { .systemWindowInsetBottom != insets.tappableElementInsets.bottom)
) {
window.navigationBarColor = Color.TRANSPARENT window.navigationBarColor = Color.TRANSPARENT
false false
} }
@ -407,8 +410,9 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>(),
appbar.startAnimation(toolbarAnimation) appbar.startAnimation(toolbarAnimation)
BottomSheetBehavior.from(chapters_bottom_sheet).isHideable = true BottomSheetBehavior.from(chapters_bottom_sheet).isHideable = true
BottomSheetBehavior.from(chapters_bottom_sheet).state = BottomSheetBehavior.STATE_HIDDEN BottomSheetBehavior.from(chapters_bottom_sheet).state = BottomSheetBehavior.STATE_HIDDEN
} else } else {
reader_menu.visibility = View.GONE reader_menu.visibility = View.GONE
}
} }
menuStickyVisible = false menuStickyVisible = false
} }
@ -530,12 +534,15 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>(),
page_text.text = "${page.number} / ${pages.size}" page_text.text = "${page.number} / ${pages.size}"
if (newChapter) { if (newChapter) {
if (config?.showNewChapter == false) systemUi?.show() if (config?.showNewChapter == false) {
systemUi?.show()
}
} else if (chapters_bottom_sheet.shouldCollaspe && chapters_bottom_sheet.sheetBehavior?.state == BottomSheetBehavior.STATE_EXPANDED) { } else if (chapters_bottom_sheet.shouldCollaspe && chapters_bottom_sheet.sheetBehavior?.state == BottomSheetBehavior.STATE_EXPANDED) {
chapters_bottom_sheet.sheetBehavior?.state = BottomSheetBehavior.STATE_COLLAPSED chapters_bottom_sheet.sheetBehavior?.state = BottomSheetBehavior.STATE_COLLAPSED
} }
if (chapters_bottom_sheet.selectedChapterId != page.chapter.chapter.id) if (chapters_bottom_sheet.selectedChapterId != page.chapter.chapter.id) {
chapters_bottom_sheet.refreshList() chapters_bottom_sheet.refreshList()
}
chapters_bottom_sheet.shouldCollaspe = true chapters_bottom_sheet.shouldCollaspe = true
// Set seekbar progress // Set seekbar progress
@ -638,11 +645,13 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>(),
* depending on the [result]. * depending on the [result].
*/ */
fun onSetAsCoverResult(result: ReaderPresenter.SetAsCoverResult) { fun onSetAsCoverResult(result: ReaderPresenter.SetAsCoverResult) {
toast(when (result) { toast(
Success -> R.string.cover_updated when (result) {
AddToLibraryFirst -> R.string.must_be_in_library_to_edit Success -> R.string.cover_updated
Error -> R.string.failed_to_update_cover AddToLibraryFirst -> R.string.must_be_in_library_to_edit
}) Error -> R.string.failed_to_update_cover
}
)
} }
override fun onVisibilityChange(visible: Boolean) { override fun onVisibilityChange(visible: Boolean) {
@ -685,7 +694,7 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>(),
if (currentOrientation == Configuration.ORIENTATION_LANDSCAPE) { if (currentOrientation == Configuration.ORIENTATION_LANDSCAPE) {
val params = window.attributes val params = window.attributes
params.layoutInDisplayCutoutMode = params.layoutInDisplayCutoutMode =
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER
} }
} }
} }