mirror of
https://github.com/lizongying/my-tv.git
synced 2026-11-01 00:56:29 +08:00
fix channel number did not disappear
This commit is contained in:
@@ -48,6 +48,13 @@ class ChannelFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
if (view?.visibility == View.VISIBLE) {
|
||||
handler.postDelayed(hideRunnable, delay)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
handler.removeCallbacks(hideRunnable)
|
||||
|
||||
@@ -174,7 +174,7 @@ class MainActivity : FragmentActivity() {
|
||||
}
|
||||
|
||||
override fun onFling(
|
||||
e1: MotionEvent,
|
||||
e1: MotionEvent?,
|
||||
e2: MotionEvent,
|
||||
velocityX: Float,
|
||||
velocityY: Float
|
||||
@@ -495,6 +495,9 @@ class MainActivity : FragmentActivity() {
|
||||
override fun onResume() {
|
||||
Log.i(TAG, "onResume")
|
||||
super.onResume()
|
||||
if (!mainFragment.isHidden){
|
||||
handler.postDelayed(hideMain, delayHideMain)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
|
||||
@@ -139,7 +139,7 @@ class MainFragment : BrowseSupportFragment() {
|
||||
val cardPresenter = CardPresenter(viewLifecycleOwner)
|
||||
|
||||
var idx: Long = 0
|
||||
TVList.init(requireContext())
|
||||
context?.let { TVList.init(it) }
|
||||
for ((k, v) in TVList.list) {
|
||||
val listRowAdapter = ArrayObjectAdapter(cardPresenter)
|
||||
for ((idx2, v1) in v.withIndex()) {
|
||||
|
||||
@@ -40,6 +40,8 @@ class Request {
|
||||
private var tokenRunnable: TokenRunnable = TokenRunnable()
|
||||
|
||||
private val regex = Regex("""des_key = "([^"]+).+var des_iv = "([^"]+)""")
|
||||
private val input =
|
||||
"""{"mver":"1","subver":"1.2","host":"www.yangshipin.cn/#/tv/home?pid=","referer":"","canvas":"YSPANGLE(Apple,AppleM1Pro,OpenGL4.1)"}""".toByteArray()
|
||||
|
||||
private var mapping = mapOf(
|
||||
"CCTV4K" to "CCTV4K 超高清",
|
||||
@@ -134,7 +136,7 @@ class Request {
|
||||
keyBytes + byteArrayOf(0, 0, 0, 0, 0, 0, 0, 0),
|
||||
ivBytes
|
||||
).uppercase()
|
||||
Log.d(TAG, "$title url $url")
|
||||
// Log.d(TAG, "$title url $url")
|
||||
tvModel.addVideoUrl(url)
|
||||
tvModel.allReady()
|
||||
tvModel.retryTimes = 0
|
||||
@@ -202,7 +204,7 @@ class Request {
|
||||
}
|
||||
|
||||
override fun onFailure(call: Call<LiveInfo>, t: Throwable) {
|
||||
Log.e(TAG, "$title request error")
|
||||
Log.e(TAG, "$title request error $t")
|
||||
if (tvModel.retryTimes < tvModel.retryMaxTimes) {
|
||||
tvModel.retryTimes++
|
||||
if (tvModel.getTV().needToken) {
|
||||
@@ -231,7 +233,7 @@ class Request {
|
||||
token = response.body()?.data?.token!!
|
||||
Log.i(TAG, "info success $token")
|
||||
val cookie =
|
||||
"vplatform=109; yspopenid=vu0-8lgGV2LW9QjDeuBFsX8yMnzs37Q3_HZF6XyVDpGR_I; vusession=$token"
|
||||
"versionName=99.99.99; versionCode=999999; vplatform=109; platformVersion=Chrome; deviceModel=120; yspappid=519748109;yspopenid=vu0-8lgGV2LW9QjDeuBFsX8yMnzs37Q3_HZF6XyVDpGR_I; vusession=$token"
|
||||
fetchVideo(tvModel, cookie)
|
||||
} else {
|
||||
Log.e(TAG, "info status error")
|
||||
@@ -240,7 +242,8 @@ class Request {
|
||||
fetchVideo(tvModel)
|
||||
} else {
|
||||
if (!tvModel.getTV().mustToken) {
|
||||
val cookie = "vplatform=109"
|
||||
val cookie =
|
||||
"versionName=99.99.99; versionCode=999999; vplatform=109; platformVersion=Chrome; deviceModel=120; yspappid=519748109"
|
||||
fetchVideo(tvModel, cookie)
|
||||
}
|
||||
}
|
||||
@@ -254,7 +257,8 @@ class Request {
|
||||
fetchVideo(tvModel)
|
||||
} else {
|
||||
if (!tvModel.getTV().mustToken) {
|
||||
val cookie = "vplatform=109"
|
||||
val cookie =
|
||||
"versionName=99.99.99; versionCode=999999; vplatform=109; platformVersion=Chrome; deviceModel=120; yspappid=519748109"
|
||||
fetchVideo(tvModel, cookie)
|
||||
}
|
||||
}
|
||||
@@ -262,7 +266,7 @@ class Request {
|
||||
})
|
||||
} else {
|
||||
val cookie =
|
||||
"vplatform=109; yspopenid=vu0-8lgGV2LW9QjDeuBFsX8yMnzs37Q3_HZF6XyVDpGR_I; vusession=$token"
|
||||
"versionName=99.99.99; versionCode=999999; vplatform=109; platformVersion=Chrome; deviceModel=120; yspappid=519748109;yspopenid=vu0-8lgGV2LW9QjDeuBFsX8yMnzs37Q3_HZF6XyVDpGR_I; vusession=$token"
|
||||
fetchVideo(tvModel, cookie)
|
||||
}
|
||||
}
|
||||
@@ -271,7 +275,8 @@ class Request {
|
||||
if (tvModel.getTV().needToken) {
|
||||
fetchVideo(tvModel)
|
||||
} else {
|
||||
val cookie = "vplatform=109"
|
||||
val cookie =
|
||||
"versionName=99.99.99; versionCode=999999; vplatform=109; platformVersion=Chrome; deviceModel=120; yspappid=519748109"
|
||||
fetchVideo(tvModel, cookie)
|
||||
}
|
||||
}
|
||||
@@ -412,15 +417,12 @@ class Request {
|
||||
}
|
||||
|
||||
private fun encryptTripleDES(key: ByteArray, iv: ByteArray): String {
|
||||
val plaintext =
|
||||
"""{"mver":"1","subver":"1.2","host":"www.yangshipin.cn/#/tv/home?pid=","referer":"","canvas":"YSPANGLE(Apple,AppleM1Pro,OpenGL4.1)"}"""
|
||||
return try {
|
||||
val keySpec = SecretKeySpec(key, "DESede")
|
||||
val ivSpec = IvParameterSpec(iv)
|
||||
val cipher = Cipher.getInstance("DESede/CBC/PKCS5Padding")
|
||||
cipher.init(Cipher.ENCRYPT_MODE, keySpec, ivSpec)
|
||||
val encryptedBytes = cipher.doFinal(plaintext.toByteArray())
|
||||
return encryptedBytes.let { it -> it.joinToString("") { "%02x".format(it) } }
|
||||
return cipher.doFinal(input).let { it -> it.joinToString("") { "%02x".format(it) } }
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
""
|
||||
|
||||
@@ -7,13 +7,14 @@ import java.io.File
|
||||
|
||||
object TVList {
|
||||
lateinit var list: Map<String, List<TV>>
|
||||
private val channels = "channels.json"
|
||||
|
||||
fun init(context: Context){
|
||||
if(::list.isInitialized){
|
||||
fun init(context: Context) {
|
||||
if (::list.isInitialized) {
|
||||
return
|
||||
}
|
||||
synchronized(this){
|
||||
if(::list.isInitialized){
|
||||
synchronized(this) {
|
||||
if (::list.isInitialized) {
|
||||
return
|
||||
}
|
||||
list = setupTV(context)
|
||||
@@ -21,17 +22,16 @@ object TVList {
|
||||
}
|
||||
|
||||
|
||||
private fun setupTV(context:Context): Map<String, List<TV>> {
|
||||
private fun setupTV(context: Context): Map<String, List<TV>> {
|
||||
val map: MutableMap<String, MutableList<TV>> = mutableMapOf()
|
||||
val appDirectory = Utils.getAppDirectory(context)
|
||||
|
||||
//检查当前目录下是否存在channels.json
|
||||
var file = File(appDirectory, "channels.json")
|
||||
val file = File(appDirectory, channels)
|
||||
if (!file.exists()) {
|
||||
//不存在则从assets中拷贝
|
||||
file = File(appDirectory, "channels.json")
|
||||
file.createNewFile()
|
||||
context.assets.open("channels.json").use { input ->
|
||||
context.resources.openRawResource(R.raw.channels).use { input ->
|
||||
file.outputStream().use { output ->
|
||||
input.copyTo(output)
|
||||
}
|
||||
@@ -42,7 +42,7 @@ object TVList {
|
||||
val json = file.readText()
|
||||
//防止类型擦除
|
||||
val type = object : TypeToken<Array<TV>>() {}.type
|
||||
Gson().fromJson<Array<TV>>(json, type).forEach {
|
||||
Gson().fromJson<Array<TV>>(json, type)?.forEach {
|
||||
if (map.containsKey(it.channel)) {
|
||||
map[it.channel]?.add(it)
|
||||
} else {
|
||||
|
||||
@@ -70,7 +70,7 @@ object Utils {
|
||||
* @param context 应用环境信息
|
||||
* @return 服务器地址
|
||||
*/
|
||||
fun getServerUrl(context: Context): String {
|
||||
private fun getServerUrl(context: Context): String {
|
||||
return context.resources.getString(R.string.server_url)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user