Fixing a few tracepot crashes

This commit is contained in:
Jays2Kings 2021-04-18 01:48:44 -04:00
parent 6b0813928a
commit 3d2eac7772
2 changed files with 24 additions and 18 deletions
app/src/main/java/eu/kanade/tachiyomi

@ -14,6 +14,7 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import timber.log.Timber
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
import java.io.File
@ -127,6 +128,7 @@ class CoverCache(val context: Context) {
fun deleteCachedCovers() {
if (lastClean + renewInterval < System.currentTimeMillis()) {
GlobalScope.launch(Dispatchers.IO) {
try {
val directory = onlineCoverDirectory
val size = DiskUtil.getDirectorySize(directory)
if (size <= maxOnlineCacheSize) {
@ -143,6 +145,9 @@ class CoverCache(val context: Context) {
break
}
}
} catch (e: Exception) {
Timber.e(e)
}
}
lastClean = System.currentTimeMillis()
}

@ -1079,7 +1079,7 @@ class MangaDetailsController :
} else {
val favButton = getHeader()?.binding?.favoriteButton ?: return
val popup = makeFavPopup(favButton, manga, categories)
popup.show()
popup?.show()
}
}
@ -1091,11 +1091,12 @@ class MangaDetailsController :
return
}
val popup = makeFavPopup(popupView, manga, presenter.getCategories())
popupView.setOnTouchListener(popup.dragToOpenListener)
popupView.setOnTouchListener(popup?.dragToOpenListener)
}
private fun makeFavPopup(popupView: View, manga: Manga, categories: List<Category>): PopupMenu {
val popup = PopupMenu(view!!.context, popupView)
private fun makeFavPopup(popupView: View, manga: Manga, categories: List<Category>): PopupMenu? {
val view = view ?: return null
val popup = PopupMenu(view.context, popupView)
popup.menu.add(0, 1, 0, R.string.remove_from_library)
if (categories.isNotEmpty()) {
popup.menu.add(0, 0, 1, R.string.edit_categories)