-
Notifications
You must be signed in to change notification settings - Fork 372
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
82395f9
commit 3cb45ce
Showing
13 changed files
with
157 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
## 更新日志 | ||
|
||
### v1.2.7 | ||
|
||
* 簡單支持EPG | ||
* 類別樣式優化 | ||
|
||
### v1.2.6 | ||
|
||
* 解決切換頻道時黑屏問題 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.lizongying.mytv0.models | ||
|
||
|
||
data class EPG( | ||
val title: String, | ||
val beginTime: Int, | ||
) |
52 changes: 52 additions & 0 deletions
52
app/src/main/java/com/lizongying/mytv0/models/EPGXmlParser.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.lizongying.mytv0.models | ||
|
||
import android.util.Xml | ||
import org.xmlpull.v1.XmlPullParser | ||
import java.io.InputStream | ||
import java.text.SimpleDateFormat | ||
import java.util.Locale | ||
|
||
|
||
class EPGXmlParser { | ||
|
||
private val ns: String? = null | ||
|
||
private val epg = mutableMapOf<String, MutableList<EPG>>() | ||
|
||
private fun formatFTime(s: String): Int { | ||
val dateFormat = SimpleDateFormat("yyyyMMddHHmmss Z", Locale.getDefault()) | ||
val date = dateFormat.parse(s) | ||
if (date != null) { | ||
return (date.time / 1000).toInt() | ||
} | ||
return 0 | ||
} | ||
|
||
fun parse(inputStream: InputStream): MutableMap<String, MutableList<EPG>> { | ||
inputStream.use { inputStream -> | ||
val parser: XmlPullParser = Xml.newPullParser() | ||
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false) | ||
parser.setInput(inputStream, null) | ||
parser.nextTag() | ||
var channel = "" | ||
while (parser.eventType != XmlPullParser.END_DOCUMENT) { | ||
if (parser.eventType != XmlPullParser.START_TAG) { | ||
parser.next() | ||
continue | ||
} | ||
if (parser.name == "channel") { | ||
parser.nextTag() | ||
channel = parser.nextText() | ||
epg[channel] = mutableListOf() | ||
} else if (parser.name == "programme") { | ||
val start = parser.getAttributeValue(ns, "start") | ||
parser.nextTag() | ||
val title = parser.nextText() | ||
epg[channel]?.add(EPG(title, formatFTime(start))) | ||
} | ||
parser.next() | ||
} | ||
} | ||
return epg | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"version_code": 16909824, "version_name": "1.2.6"} | ||
{"version_code": 16910080, "version_name": "v1.2.7"} |