From e7a60e07d8cf94cabb421b871eff4709a4bcb04a Mon Sep 17 00:00:00 2001 From: rebelonion <87634197+rebelonion@users.noreply.github.com> Date: Fri, 24 May 2024 14:03:33 -0500 Subject: [PATCH] fix: destroyed activity crash on slower phones --- .../java/ani/dantotsu/others/AppUpdater.kt | 23 +++++++++++++++++++ .../java/ani/dantotsu/others/AppUpdater.kt | 7 +++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/app/src/fdroid/java/ani/dantotsu/others/AppUpdater.kt b/app/src/fdroid/java/ani/dantotsu/others/AppUpdater.kt index bb9893f6..5dfb79e7 100644 --- a/app/src/fdroid/java/ani/dantotsu/others/AppUpdater.kt +++ b/app/src/fdroid/java/ani/dantotsu/others/AppUpdater.kt @@ -6,4 +6,27 @@ object AppUpdater { suspend fun check(activity: FragmentActivity, post: Boolean = false) { //no-op } + + @Serializable + data class GithubResponse( + @SerialName("html_url") + val htmlUrl: String, + @SerialName("tag_name") + val tagName: String, + val prerelease: Boolean, + @SerialName("created_at") + val createdAt: String, + val body: String? = null, + val assets: List? = null + ) { + @Serializable + data class Asset( + @SerialName("browser_download_url") + val browserDownloadURL: String + ) + + fun timeStamp(): Long { + return dateFormat.parse(createdAt)!!.time + } + } } \ No newline at end of file diff --git a/app/src/google/java/ani/dantotsu/others/AppUpdater.kt b/app/src/google/java/ani/dantotsu/others/AppUpdater.kt index 67b7ce43..f6f8e8ca 100644 --- a/app/src/google/java/ani/dantotsu/others/AppUpdater.kt +++ b/app/src/google/java/ani/dantotsu/others/AppUpdater.kt @@ -29,6 +29,7 @@ import ani.dantotsu.util.Logger import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.MainScope import kotlinx.coroutines.launch +import kotlinx.coroutines.time.delay import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable import kotlinx.serialization.json.JsonArray @@ -69,7 +70,11 @@ object AppUpdater { ) addView( TextView(activity).apply { - val markWon = buildMarkwon(activity, false) + val markWon = try { //slower phones can destroy the activity before this is done + buildMarkwon(activity, false) + } catch (e: IllegalArgumentException) { + return@runOnUiThread + } markWon.setMarkdown(this, md) } )