Merge branch 'hotfix-v4.5.4-254-database' into 'release'

捕抓数据库满了的时候的异常

See merge request halo/assistant-android!73
This commit is contained in:
juntao
2021-01-08 11:10:42 +08:00
3 changed files with 27 additions and 14 deletions

View File

@ -1,8 +1,10 @@
package com.gh.common.exposure
import android.database.sqlite.SQLiteFullException
import com.aliyun.sls.android.sdk.model.LogGroup
import com.gh.common.exposure.time.TimeUtil
import com.gh.common.util.toJson
import com.gh.common.util.toastInInternalRelease
import com.gh.common.util.tryWithDefaultCatch
import com.gh.gamecenter.BuildConfig
import com.gh.loghub.LgLOG
@ -40,8 +42,13 @@ object ExposureManager {
loghubHelper.init(HaloApp.getInstance().application, ENDPOINT, PROJECT, LOG_STORE) { TimeUtil.currentTimeMillis() }
exposureExecutor.execute {
val eventList = exposureDao.getAll()
exposureSet.addAll(eventList)
try {
val eventList = exposureDao.getAll()
exposureSet.addAll(eventList)
} catch (e: SQLiteFullException) {
e.printStackTrace()
toastInInternalRelease("数据库/磁盘已满,初始化曝光失败")
}
}
}

View File

@ -69,37 +69,37 @@ object HistoryHelper {
@JvmStatic
fun insertNewsEntity(newsEntity: NewsEntity) {
newsEntity.orderTag = System.currentTimeMillis()
runOnIoThread { HistoryDatabase.instance.newsDao().addNews(newsEntity) }
runOnIoThread { tryCatchInRelease { HistoryDatabase.instance.newsDao().addNews(newsEntity) } }
}
@JvmStatic
fun deleteNewsEntity(newsId: String) {
runOnIoThread { HistoryDatabase.instance.newsDao().deleteNews(NewsEntity().apply { id = newsId }) }
runOnIoThread { tryCatchInRelease { HistoryDatabase.instance.newsDao().deleteNews(NewsEntity().apply { id = newsId }) } }
}
@JvmStatic
fun deleteGameEntity(gameId: String) {
runOnIoThread { HistoryDatabase.instance.gameDao().deleteGame(HistoryGameEntity(id = gameId)) }
runOnIoThread { tryCatchInRelease { HistoryDatabase.instance.gameDao().deleteGame(HistoryGameEntity(id = gameId)) } }
}
@JvmStatic
fun deleteArticleEntity(articleId: String) {
runOnIoThread { HistoryDatabase.instance.articleDao().deleteArticle(ArticleEntity(id = articleId)) }
runOnIoThread { tryCatchInRelease { HistoryDatabase.instance.articleDao().deleteArticle(ArticleEntity(id = articleId)) } }
}
@JvmStatic
fun deleteAnswerEntity(answerId: String) {
runOnIoThread { HistoryDatabase.instance.answerDao().deleteAnswer(AnswerEntity().apply { primaryKey = answerId }) }
runOnIoThread { tryCatchInRelease { HistoryDatabase.instance.answerDao().deleteAnswer(AnswerEntity().apply { primaryKey = answerId }) } }
}
@JvmStatic
fun deleteVideoEntity(videoId: String) {
runOnIoThread { HistoryDatabase.instance.videoHistoryDao().deleteVideo(MyVideoEntity().apply { id = videoId }) }
runOnIoThread { tryCatchInRelease { HistoryDatabase.instance.videoHistoryDao().deleteVideo(MyVideoEntity().apply { id = videoId }) } }
}
@JvmStatic
fun emptyDatabase() {
runOnIoThread { HistoryDatabase.instance.clearAllTables() }
runOnIoThread { tryCatchInRelease { HistoryDatabase.instance.clearAllTables() } }
}
private fun convertArticleDetailToArticle(articleDetailEntity: ArticleDetailEntity): ArticleEntity {

View File

@ -1,5 +1,6 @@
package com.gh.common.util
import android.database.sqlite.SQLiteFullException
import com.gh.gamecenter.entity.GameEntity
import com.gh.gamecenter.entity.HomePluggableFilterEntity
import com.gh.gamecenter.room.AppDatabase
@ -38,13 +39,18 @@ object HomePluggableHelper {
@JvmStatic
fun activationFilterData() {
val filterList = mHomePluggableFilterDao.getDataByActive(false)
try {
val filterList = mHomePluggableFilterDao.getDataByActive(false)
if (filterList != null) {
for (entity in filterList) {
entity.active = true
if (filterList != null) {
for (entity in filterList) {
entity.active = true
}
mHomePluggableFilterDao.addData(filterList)
}
tryCatchInRelease { mHomePluggableFilterDao.addData(filterList) }
} catch (e: SQLiteFullException) {
e.printStackTrace()
toastInInternalRelease("数据库/磁盘已满,插件筛选失败")
}
}
}