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