Fixing tracepot crashes

This commit is contained in:
Jay 2020-05-11 02:01:21 -04:00
parent be69f05657
commit 3ad9d84b5f
4 changed files with 7 additions and 5 deletions

View File

@ -180,10 +180,11 @@ class LibraryController(
private var scrollListener = object : RecyclerView.OnScrollListener() {
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
super.onScrolled(recyclerView, dx, dy)
val recyclerCover = recycler_cover ?: return
val notAtTop = recycler.canScrollVertically(-1)
if (notAtTop != elevate) elevateFunc(notAtTop)
val order = getCategoryOrder()
if (!recycler_cover.isClickable && isAnimatingHopper != true) {
if (!recyclerCover.isClickable && isAnimatingHopper != true) {
category_hopper_frame.translationY += dy
category_hopper_frame.translationY =
category_hopper_frame.translationY.coerceIn(0f, 50f.dpToPx)

View File

@ -254,7 +254,7 @@ class MangaDetailsController : BaseController,
}
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
val atTop = !recycler.canScrollVertically(-1)
val atTop = recycler?.canScrollVertically(-1) == false
if (atTop) getHeader()?.backdrop?.translationY = 0f
}
})
@ -521,7 +521,7 @@ class MangaDetailsController : BaseController,
}
private fun getHeader(): MangaHeaderHolder? {
return recycler.findViewHolderForAdapterPosition(0) as? MangaHeaderHolder
return recycler?.findViewHolderForAdapterPosition(0) as? MangaHeaderHolder
}
fun updateHeader() {

View File

@ -143,6 +143,7 @@ class RecentsController(bundle: Bundle? = null) : BaseController(bundle),
dl_bottom_sheet.sheetBehavior?.addBottomSheetCallback(object :
BottomSheetBehavior.BottomSheetCallback() {
override fun onSlide(bottomSheet: View, progress: Float) {
val shadow2 = shadow2 ?: return
shadow2.alpha = (1 - abs(progress)) * 0.25f
shadow.alpha = (1 - abs(progress)) * 0.5f
if (progress >= 0) activity?.appbar?.elevation = max(

View File

@ -119,7 +119,7 @@ fun Controller.scrollViewWith(
if (changeType.isEnter) {
elevateFunc(elevate)
if (fakeToolbarView?.parent != null) {
val parent = recycler.parent as ViewGroup
val parent = recycler.parent as? ViewGroup ?: return
parent.removeView(fakeToolbarView)
fakeToolbarView = null
}
@ -136,9 +136,9 @@ fun Controller.scrollViewWith(
if (!customPadding && lastY == 0f && router.backstack.lastOrNull()
?.controller() is MangaDetailsController
) {
val parent = recycler.parent as? ViewGroup ?: return
val v = View(activity)
fakeToolbarView = v
val parent = recycler.parent as ViewGroup
parent.addView(v, parent.indexOfChild(recycler) + 1)
val params = fakeToolbarView?.layoutParams
params?.height = recycler.paddingTop