From 59fef0e5dd6e362c1d3a99f0356a0f8486f5ef74 Mon Sep 17 00:00:00 2001
From: yaoxieyoulei <1622968661@qq.com>
Date: Mon, 27 May 2024 08:45:25 +0800
Subject: [PATCH] =?UTF-8?q?:bug:=20=E4=BF=AE=E5=A4=8D=E8=8A=82=E7=9B=AE?=
=?UTF-8?q?=E5=8D=95=E6=9C=AA=E5=88=B7=E6=96=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.idea/other.xml | 11 ------
.../data/repositories/epg/EpgRepository.kt | 38 ++++++-------------
2 files changed, 12 insertions(+), 37 deletions(-)
diff --git a/.idea/other.xml b/.idea/other.xml
index d0886deb..0d3a1fbb 100644
--- a/.idea/other.xml
+++ b/.idea/other.xml
@@ -235,17 +235,6 @@
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/src/main/java/top/yogiczy/mytv/data/repositories/epg/EpgRepository.kt b/app/src/main/java/top/yogiczy/mytv/data/repositories/epg/EpgRepository.kt
index 6718cbc5..ba06f04e 100644
--- a/app/src/main/java/top/yogiczy/mytv/data/repositories/epg/EpgRepository.kt
+++ b/app/src/main/java/top/yogiczy/mytv/data/repositories/epg/EpgRepository.kt
@@ -96,20 +96,17 @@ class EpgRepository : FileCacheRepository("epg.json") {
refreshTimeThreshold: Int,
) = withContext(Dispatchers.Default) {
try {
- val xmlJson = getOrRefresh({ lastModified, cacheData ->
- if (epgXmlRepository.cacheFileLastModified() > lastModified)
- return@getOrRefresh true
-
-// if (!cacheData.isNullOrBlank()) {
-// val epgList = Json.decodeFromString>(cacheData)
-// val oldHashCode = epgList.map { it.channel }.hashCode()
-// return@getOrRefresh oldHashCode != filteredChannels.hashCode()
-// }
-
-// true
- false
+ if (Calendar.getInstance().get(Calendar.HOUR_OF_DAY) < refreshTimeThreshold) {
+ log.d("未到时间点,不刷新节目单")
+ return@withContext EpgList()
+ }
+
+ val dateFormat = SimpleDateFormat("yyyy-MM-dd", Locale.getDefault())
+
+ val xmlJson = getOrRefresh({ lastModified, _ ->
+ dateFormat.format(System.currentTimeMillis()) != dateFormat.format(lastModified)
}) {
- val xmlString = epgXmlRepository.getEpgXml(xmlUrl, refreshTimeThreshold)
+ val xmlString = epgXmlRepository.getEpgXml(xmlUrl)
Json.encodeToString(parseFromXml(xmlString, filteredChannels).value)
}
@@ -154,20 +151,9 @@ private class EpgXmlRepository : FileCacheRepository("epg.xml") {
/**
* 获取xml
*/
- suspend fun getEpgXml(url: String, refreshTimeThreshold: Int): String {
- if (Calendar.getInstance().get(Calendar.HOUR_OF_DAY) < refreshTimeThreshold) {
- log.d("未到时间点,不刷新节目单")
- return ""
- }
-
- val dateFormat = SimpleDateFormat("yyyy-MM-dd", Locale.getDefault())
-
- return getOrRefresh({ lastModified, _ ->
- dateFormat.format(System.currentTimeMillis()) != dateFormat.format(lastModified)
- }) {
+ suspend fun getEpgXml(url: String): String {
+ return getOrRefresh(0) {
fetchXml(url)
}
}
-
- fun cacheFileLastModified() = getCacheFile().lastModified()
}