Fix crashes

This commit is contained in:
Koitharu
2024-05-04 17:06:28 +03:00
parent d8ac4d6738
commit 17828ae755
4 changed files with 11 additions and 10 deletions

View File

@@ -8,7 +8,6 @@ import androidx.appcompat.view.ActionMode
import androidx.core.view.isVisible
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.activityViewModels
import androidx.lifecycle.Lifecycle
import com.google.android.material.tabs.TabLayoutMediator
import dagger.hilt.android.AndroidEntryPoint
import org.koitharu.kotatsu.core.exceptions.resolve.SnackbarErrorObserver
@@ -74,10 +73,12 @@ class ChaptersPagesSheet : BaseAdaptiveSheet<SheetChaptersPagesBinding>(), Actio
actionModeDelegate?.addListener(this, viewLifecycleOwner)
addSheetCallback(this, viewLifecycleOwner)
viewModel.onError.observeEvent(viewLifecycleOwner, SnackbarErrorObserver(binding.pager, this))
viewModel.onActionDone.observeEvent(viewLifecycleOwner, ReversibleActionObserver(binding.pager, null))
viewModel.onDownloadStarted.observeEvent(viewLifecycleOwner, DownloadStartedObserver(binding.pager))
viewModel.newChaptersCount.observe(viewLifecycleOwner, ::onNewChaptersChanged)
if (dialog != null) {
viewModel.onError.observeEvent(viewLifecycleOwner, SnackbarErrorObserver(binding.pager, this))
viewModel.onActionDone.observeEvent(viewLifecycleOwner, ReversibleActionObserver(binding.pager, null))
viewModel.onDownloadStarted.observeEvent(viewLifecycleOwner, DownloadStartedObserver(binding.pager))
}
}
override fun onStateChanged(sheet: View, newState: Int) {
@@ -151,7 +152,7 @@ class ChaptersPagesSheet : BaseAdaptiveSheet<SheetChaptersPagesBinding>(), Actio
fun isShown(fm: FragmentManager): Boolean {
val sheet = fm.findFragmentByTag(TAG) as? ChaptersPagesSheet
return sheet != null && sheet.lifecycle.currentState.isAtLeast(Lifecycle.State.STARTED)
return sheet?.dialog?.isShowing == true
}
}
}

View File

@@ -420,8 +420,8 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), AppBarOwner, BottomNav
}
viewBinding.container.updateLayoutParams<MarginLayoutParams> {
bottomMargin = if (isPinned) {
(bottomNavBar?.measureHeight() ?: 0)
.coerceAtLeast(resources.getDimensionPixelSize(materialR.dimen.m3_bottom_nav_min_height))
(bottomNavBar?.measureHeight()
?.coerceAtLeast(resources.getDimensionPixelSize(materialR.dimen.m3_bottom_nav_min_height)) ?: 0)
} else {
0
}

View File

@@ -3,10 +3,10 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/layout_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".details.ui.DetailsActivity"
tools:ignore="ViewBindingType"
tools:viewBindingType="android.view.ViewGroup">
<com.google.android.material.appbar.AppBarLayout
@@ -391,7 +391,6 @@
android:id="@+id/card_chapters"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="@dimen/side_card_offset"
android:layout_marginTop="2dp"
android:layout_marginEnd="@dimen/side_card_offset"
android:layout_marginBottom="@dimen/side_card_offset"

View File

@@ -3,10 +3,11 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/layout_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
tools:context=".details.ui.DetailsActivity"
tools:ignore="ViewBindingType"
tools:viewBindingType="android.view.ViewGroup">
<com.google.android.material.appbar.AppBarLayout