From ca633b1f9575de34e63b571333ade45654fd6faa Mon Sep 17 00:00:00 2001 From: CarlosEsco Date: Wed, 22 Apr 2020 12:50:52 -0400 Subject: [PATCH] wrap more if's and else with braces --- .../tachiyomi/ui/reader/ReaderActivity.kt | 39 ++++++++++++------- 1 file changed, 24 insertions(+), 15 deletions(-) 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 477fd88cc9..0243367423 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 @@ -174,11 +174,11 @@ class ReaderActivity : BaseRxActivity(), 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(), } 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(), 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(), 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,8 +410,9 @@ class ReaderActivity : BaseRxActivity(), 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(), 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(), * depending on the [result]. */ fun onSetAsCoverResult(result: ReaderPresenter.SetAsCoverResult) { - toast(when (result) { - Success -> R.string.cover_updated - AddToLibraryFirst -> R.string.must_be_in_library_to_edit - Error -> R.string.failed_to_update_cover - }) + 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) { @@ -685,7 +694,7 @@ class ReaderActivity : BaseRxActivity(), if (currentOrientation == Configuration.ORIENTATION_LANDSCAPE) { val params = window.attributes params.layoutInDisplayCutoutMode = - WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER + WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER } } }