mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-23 01:51:51 +01:00
Fix #517 and a few more crashes
This commit is contained in:
parent
453f742732
commit
2dc8159d96
@ -5,7 +5,6 @@ import android.app.Service
|
|||||||
import android.content.BroadcastReceiver
|
import android.content.BroadcastReceiver
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.graphics.Bitmap
|
|
||||||
import android.graphics.BitmapFactory
|
import android.graphics.BitmapFactory
|
||||||
import android.os.IBinder
|
import android.os.IBinder
|
||||||
import android.os.PowerManager
|
import android.os.PowerManager
|
||||||
@ -73,7 +72,9 @@ class LibraryUpdateService : Service() {
|
|||||||
private val notificationId: Int
|
private val notificationId: Int
|
||||||
get() = Constants.NOTIFICATION_LIBRARY_ID
|
get() = Constants.NOTIFICATION_LIBRARY_ID
|
||||||
|
|
||||||
private var notificationBitmap: Bitmap? = null
|
private val notificationBitmap by lazy {
|
||||||
|
BitmapFactory.decodeResource(resources, R.mipmap.ic_launcher)
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
@ -141,8 +142,6 @@ class LibraryUpdateService : Service() {
|
|||||||
*/
|
*/
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
subscription?.unsubscribe()
|
subscription?.unsubscribe()
|
||||||
notificationBitmap?.recycle()
|
|
||||||
notificationBitmap = null
|
|
||||||
destroyWakeLock()
|
destroyWakeLock()
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
}
|
}
|
||||||
@ -171,10 +170,6 @@ class LibraryUpdateService : Service() {
|
|||||||
// Update favorite manga. Destroy service when completed or in case of an error.
|
// Update favorite manga. Destroy service when completed or in case of an error.
|
||||||
subscription = Observable
|
subscription = Observable
|
||||||
.defer {
|
.defer {
|
||||||
if (notificationBitmap == null) {
|
|
||||||
notificationBitmap = BitmapFactory.decodeResource(resources, R.mipmap.ic_launcher)
|
|
||||||
}
|
|
||||||
|
|
||||||
val mangaList = getMangaToUpdate(intent)
|
val mangaList = getMangaToUpdate(intent)
|
||||||
|
|
||||||
// Update either chapter list or manga details.
|
// Update either chapter list or manga details.
|
||||||
@ -267,7 +262,6 @@ class LibraryUpdateService : Service() {
|
|||||||
} else {
|
} else {
|
||||||
showResultNotification(newUpdates, failedUpdates)
|
showResultNotification(newUpdates, failedUpdates)
|
||||||
}
|
}
|
||||||
LibraryUpdateJob.setupTask()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ import android.util.AttributeSet
|
|||||||
import com.afollestad.materialdialogs.MaterialDialog
|
import com.afollestad.materialdialogs.MaterialDialog
|
||||||
import eu.kanade.tachiyomi.BuildConfig
|
import eu.kanade.tachiyomi.BuildConfig
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
|
import eu.kanade.tachiyomi.data.library.LibraryUpdateJob
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
import eu.kanade.tachiyomi.data.preference.getOrDefault
|
||||||
import eu.kanade.tachiyomi.data.updater.UpdateCheckerJob
|
import eu.kanade.tachiyomi.data.updater.UpdateCheckerJob
|
||||||
@ -23,9 +24,10 @@ class ChangelogDialogFragment : DialogFragment() {
|
|||||||
preferences.lastVersionCode().set(BuildConfig.VERSION_CODE)
|
preferences.lastVersionCode().set(BuildConfig.VERSION_CODE)
|
||||||
ChangelogDialogFragment().show(fragmentManager, "changelog")
|
ChangelogDialogFragment().show(fragmentManager, "changelog")
|
||||||
|
|
||||||
// FIXME Ugly check to restore auto updates setting. Remove me in a few months :D
|
// FIXME Ugly check to restore jobs. Remove me in a few months :D
|
||||||
if (oldVersion < 14 && BuildConfig.INCLUDE_UPDATER && preferences.automaticUpdates()) {
|
if (oldVersion < 14 && BuildConfig.INCLUDE_UPDATER && preferences.automaticUpdates()) {
|
||||||
UpdateCheckerJob.setupTask()
|
UpdateCheckerJob.setupTask()
|
||||||
|
LibraryUpdateJob.setupTask()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ class SettingsAdvancedFragment : SettingsFragment() {
|
|||||||
private fun clearChapterCache() {
|
private fun clearChapterCache() {
|
||||||
val deletedFiles = AtomicInteger()
|
val deletedFiles = AtomicInteger()
|
||||||
|
|
||||||
val files = chapterCache.cacheDir.listFiles()
|
val files = chapterCache.cacheDir.listFiles() ?: return
|
||||||
|
|
||||||
val dialog = MaterialDialog.Builder(activity)
|
val dialog = MaterialDialog.Builder(activity)
|
||||||
.title(R.string.deleting)
|
.title(R.string.deleting)
|
||||||
|
Loading…
Reference in New Issue
Block a user