Various fixes for crashes from Tracepot

This commit is contained in:
Jay 2020-05-01 16:16:13 -04:00
parent 65071dc01e
commit 3e541a0500
6 changed files with 21 additions and 17 deletions

View File

@ -64,7 +64,8 @@ open class MangaImpl : Manga {
}
override fun hashCode(): Int {
return url.hashCode()
if (::url.isInitialized) return url.hashCode()
else return (id ?: 0L).hashCode()
}
companion object {

View File

@ -163,7 +163,7 @@ class LibraryController(
activeCategory = order
if (presenter.categories.size > 1 && dy != 0) {
val headerItem = getHeader() ?: return
val view = fast_scroller.getChildAt(0) ?: return
val view = fast_scroller?.getChildAt(0) ?: return
val index = adapter.headerItems.indexOf(headerItem)
textAnim?.cancel()
textAnim = text_view_m.animate().alpha(0f).setDuration(250L).setStartDelay(2000)
@ -186,12 +186,12 @@ class LibraryController(
when (newState) {
RecyclerView.SCROLL_STATE_DRAGGING -> {
scrollAnim?.cancel()
if (fast_scroller.translationX != 0f) {
fast_scroller.show()
if (fast_scroller?.translationX != 0f) {
fast_scroller?.show()
}
}
RecyclerView.SCROLL_STATE_IDLE -> {
scrollAnim = fast_scroller.hide()
scrollAnim = fast_scroller?.hide()
}
}
}
@ -299,7 +299,7 @@ class LibraryController(
activity!!.theme.resolveAttribute(R.attr.actionBarTintColor, tv, true)
swipe_refresh.setStyle()
scrollViewWith(recycler, swipeRefreshLayout = swipe_refresh, afterInsets = { insets ->
fast_scroller.updateLayoutParams<ViewGroup.MarginLayoutParams> {
fast_scroller?.updateLayoutParams<ViewGroup.MarginLayoutParams> {
topMargin = insets.systemWindowInsetTop
}
})
@ -405,11 +405,11 @@ class LibraryController(
fun updateShowScrollbar(show: Boolean) {
alwaysShowScroller = show
fast_scroller.setBackground(!show)
fast_scroller?.setBackground(!show)
if (libraryLayout == 0) reattachAdapter()
scrollAnim?.cancel()
if (show) fast_scroller.translationX = 0f
else scrollAnim = fast_scroller.hide()
if (show) fast_scroller?.translationX = 0f
else scrollAnim = fast_scroller?.hide()
setRecyclerLayout()
}
@ -503,9 +503,9 @@ class LibraryController(
if (justStarted && freshStart) {
scrollToHeader(activeCategory)
if (!alwaysShowScroller) {
fast_scroller.show(false)
fast_scroller?.show(false)
view?.post {
scrollAnim = fast_scroller.hide(2000)
scrollAnim = fast_scroller?.hide(2000)
}
}
}

View File

@ -6,8 +6,8 @@ import android.os.Bundle
import com.bluelinelabs.conductor.Controller
import eu.kanade.tachiyomi.data.notification.NotificationReceiver
import eu.kanade.tachiyomi.ui.base.controller.DialogController
import eu.kanade.tachiyomi.ui.source.global_search.SourceSearchController
import eu.kanade.tachiyomi.ui.security.SecureActivityDelegate
import eu.kanade.tachiyomi.ui.source.global_search.SourceSearchController
import eu.kanade.tachiyomi.util.view.gone
import eu.kanade.tachiyomi.util.view.withFadeTransaction
import kotlinx.android.synthetic.main.main_activity.*
@ -16,8 +16,8 @@ class SearchActivity : MainActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
toolbar.navigationIcon = drawerArrow
toolbar.setNavigationOnClickListener {
toolbar?.navigationIcon = drawerArrow
toolbar?.setNavigationOnClickListener {
popToRoot()
}
}

View File

@ -477,7 +477,9 @@ class MangaDetailsPresenter(
updateChapters()
withContext(Dispatchers.Main) { controller.updateChapters(this@MangaDetailsPresenter.chapters) }
} catch (e: java.lang.Exception) {
controller.showError(trimException(e))
withContext(Dispatchers.Main) {
controller.showError(trimException(e))
}
}
}
}

View File

@ -140,10 +140,10 @@ abstract class PagerViewer(val activity: ReaderActivity) : BaseViewer {
* activity of the change and requests the preload of the next chapter if this is the last page.
*/
private fun onReaderPageSelected(page: ReaderPage) {
val pages = page.chapter.pages!! // Won't be null because it's the loaded chapter
Timber.d("onReaderPageSelected: ${page.number}/${pages.size}")
activity.onPageSelected(page)
val pages = page.chapter.pages ?: return
Timber.d("onReaderPageSelected: ${page.number}/${pages.size}")
// Preload next chapter once we're within the last 3 pages of the current chapter
val inPreloadRange = pages.size - page.number < 3
if (inPreloadRange) {

View File

@ -253,6 +253,7 @@ class RecentsController(bundle: Bundle? = null) : BaseController(bundle),
fun refresh() = presenter.getRecents()
fun showLists(recents: List<RecentMangaItem>) {
if (view == null) return
swipe_refresh.isRefreshing = LibraryUpdateService.isRunning()
adapter.updateItems(recents)
adapter.removeAllScrollableHeaders()