diff --git a/README.md b/README.md index 130c339..3615d5e 100644 --- a/README.md +++ b/README.md @@ -14,10 +14,24 @@ ## 更新日志 +### v1.4.9(高版本专用) + +* 同步v1.4.8 + +### v1.4.8(通用版) + +* 频道号从1开始,CCTV5+为18 +* 提高CCTV6清晰度 +* 增加天津卫视、新疆卫视 + ### v1.4.7(高版本专用) -* 修复部分用户cctv13播放过程中卡住的问题 -* 调整cctv的频道顺序 +* 修复部分用户CCTV13播放过程中卡住的问题 +* 调整CCTV的频道顺序 + +### v1.4.6(通用版) + +* 10以下频道不再需要先按0 ### v1.4.5(高版本专用) diff --git a/app/src/main/java/com/lizongying/mytv/CardPresenter.kt b/app/src/main/java/com/lizongying/mytv/CardPresenter.kt index a11ff12..099a918 100644 --- a/app/src/main/java/com/lizongying/mytv/CardPresenter.kt +++ b/app/src/main/java/com/lizongying/mytv/CardPresenter.kt @@ -31,23 +31,31 @@ class CardPresenter( cardView.setMainImageDimensions(CARD_WIDTH, CARD_HEIGHT) cardView.tag = tvViewModel.videoUrl.value - if (tvViewModel.logo.value != null) { - if (tvViewModel.title.value == "CCTV8K 超高清") { - Glide.with(viewHolder.view.context) - .load(R.drawable.cctv8k) - .centerInside() - .into(cardView.mainImageView) - } else { - Glide.with(viewHolder.view.context) - .load(tvViewModel.logo.value) - .centerInside() - .into(cardView.mainImageView) - } + when (tvViewModel.title.value) { + "CCTV8K 超高清" -> Glide.with(viewHolder.view.context) + .load(R.drawable.cctv8k) + .centerInside() + .into(cardView.mainImageView) + + "天津卫视" -> Glide.with(viewHolder.view.context) + .load(R.drawable.tianjin) + .centerInside() + .into(cardView.mainImageView) - cardView.setBackgroundColor(Color.WHITE) - cardView.setMainImageScaleType(ImageView.ScaleType.CENTER_INSIDE) + "新疆卫视" -> Glide.with(viewHolder.view.context) + .load(R.drawable.xinjiang) + .centerInside() + .into(cardView.mainImageView) + + else -> Glide.with(viewHolder.view.context) + .load(tvViewModel.logo.value) + .centerInside() + .into(cardView.mainImageView) } + cardView.setBackgroundColor(Color.WHITE) + cardView.setMainImageScaleType(ImageView.ScaleType.CENTER_INSIDE) + tvViewModel.program.observe(owner) { _ -> val program = tvViewModel.getProgramOne() if (program != null) { diff --git a/app/src/main/java/com/lizongying/mytv/ChannelFragment.kt b/app/src/main/java/com/lizongying/mytv/ChannelFragment.kt index 1154200..07adb88 100644 --- a/app/src/main/java/com/lizongying/mytv/ChannelFragment.kt +++ b/app/src/main/java/com/lizongying/mytv/ChannelFragment.kt @@ -30,7 +30,7 @@ class ChannelFragment : Fragment() { fun show(tvViewModel: TVViewModel) { handler.removeCallbacks(hideRunnable) handler.removeCallbacks(playRunnable) - binding.channelContent.text = tvViewModel.id.value.toString() + binding.channelContent.text = (tvViewModel.id.value?.plus(1)).toString() view?.visibility = View.VISIBLE handler.postDelayed(hideRunnable, delay) } @@ -60,7 +60,7 @@ class ChannelFragment : Fragment() { } private val playRunnable = Runnable { - (activity as MainActivity).play(channel) + (activity as MainActivity).play(channel - 1) binding.channelContent.text = "" view?.visibility = View.GONE } diff --git a/app/src/main/java/com/lizongying/mytv/InfoFragment.kt b/app/src/main/java/com/lizongying/mytv/InfoFragment.kt index 06c6693..7da7dcc 100644 --- a/app/src/main/java/com/lizongying/mytv/InfoFragment.kt +++ b/app/src/main/java/com/lizongying/mytv/InfoFragment.kt @@ -2,7 +2,6 @@ package com.lizongying.mytv import android.os.Bundle import android.os.Handler -import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -30,12 +29,21 @@ class InfoFragment : Fragment() { fun show(tvViewModel: TVViewModel) { binding.textView.text = tvViewModel.title.value - if (tvViewModel.title.value == "CCTV8K 超高清") { - Glide.with(this) + + when (tvViewModel.title.value) { + "CCTV8K 超高清" -> Glide.with(this) .load(R.drawable.cctv8k) .into(binding.infoLogo) - } else { - Glide.with(this) + + "天津卫视" -> Glide.with(this) + .load(R.drawable.tianjin) + .into(binding.infoLogo) + + "新疆卫视" -> Glide.with(this) + .load(R.drawable.xinjiang) + .into(binding.infoLogo) + + else -> Glide.with(this) .load(tvViewModel.logo.value) .into(binding.infoLogo) } diff --git a/app/src/main/java/com/lizongying/mytv/MainFragment.kt b/app/src/main/java/com/lizongying/mytv/MainFragment.kt index 084151f..355ab8a 100644 --- a/app/src/main/java/com/lizongying/mytv/MainFragment.kt +++ b/app/src/main/java/com/lizongying/mytv/MainFragment.kt @@ -62,7 +62,7 @@ class MainFragment : BrowseSupportFragment() { mUpdateProgramRunnable = UpdateProgramRunnable() handler.post(mUpdateProgramRunnable) - tvListViewModel.getTVListViewModel().value?.forEach { tvViewModel -> + tvListViewModel.tvListViewModel.value?.forEach { tvViewModel -> tvViewModel.errInfo.observe(viewLifecycleOwner) { _ -> if (tvViewModel.errInfo.value != null && tvViewModel.id.value == itemPosition @@ -251,7 +251,7 @@ class MainFragment : BrowseSupportFragment() { fun play(itemPosition: Int) { view?.post { - if (itemPosition < tvListViewModel.size()) { + if (itemPosition > -1 && itemPosition < tvListViewModel.size()) { this.itemPosition = itemPosition tvListViewModel.setItemPosition(itemPosition) tvListViewModel.getTVViewModel(itemPosition)?.changed() @@ -290,7 +290,7 @@ class MainFragment : BrowseSupportFragment() { tvViewModel.programUpdateTime = timestamp request.fetchProgram(tvViewModel) } else { - if (timestamp - tvViewModel.program.value!!.last().et < 600) { + if (tvViewModel.program.value!!.last().et - timestamp < 600) { tvViewModel.programUpdateTime = timestamp request.fetchProgram(tvViewModel) } @@ -300,7 +300,7 @@ class MainFragment : BrowseSupportFragment() { inner class UpdateProgramRunnable : Runnable { override fun run() { - tvListViewModel.getTVListViewModel().value?.filter { it.programId.value != null } + tvListViewModel.tvListViewModel.value?.filter { it.programId.value != null } ?.forEach { tvViewModel -> updateProgram( tvViewModel diff --git a/app/src/main/java/com/lizongying/mytv/Request.kt b/app/src/main/java/com/lizongying/mytv/Request.kt index 8d18e0f..d7d7a03 100644 --- a/app/src/main/java/com/lizongying/mytv/Request.kt +++ b/app/src/main/java/com/lizongying/mytv/Request.kt @@ -81,6 +81,8 @@ class Request { "四川卫视" to "四川卫视", "福建东南卫视" to "东南卫视", "海南卫视" to "海南卫视", + "天津卫视" to "天津卫视", + "新疆卫视" to "新疆卫视", ) fun initYSP(context: Context) { @@ -123,7 +125,7 @@ class Request { keyBytes + byteArrayOf(0, 0, 0, 0, 0, 0, 0, 0), ivBytes ).uppercase() - Log.i(TAG, "$title url $url") + Log.d(TAG, "$title url $url") tvModel.addVideoUrl(url) tvModel.allReady() tvModel.retryTimes = 0 diff --git a/app/src/main/java/com/lizongying/mytv/TVList.kt b/app/src/main/java/com/lizongying/mytv/TVList.kt index fee7e27..fd2e98c 100644 --- a/app/src/main/java/com/lizongying/mytv/TVList.kt +++ b/app/src/main/java/com/lizongying/mytv/TVList.kt @@ -7,7 +7,7 @@ object TVList { private var mappingLogo = mapOf( "CCTV4K 超高清" to "https://resources.yangshipin.cn/assets/oms/image/202306/3e9d06fd7244d950df5838750f1c6ac3456e172b51caca2c16d2282125b111e8.png?imageMogr2/format/webp", - "CCTV8K 超高清" to "https://static.wikia.nocookie.net/logos/images/6/69/CCTV8K.png/revision/latest/scale-to-width-down/120?cb=20230104110835&path-prefix=vi", + "CCTV8K 超高清" to "", "CCTV1 综合" to "https://resources.yangshipin.cn/assets/oms/image/202306/d57905b93540bd15f0c48230dbbbff7ee0d645ff539e38866e2d15c8b9f7dfcd.png?imageMogr2/format/webp", "CCTV2 财经" to "https://resources.yangshipin.cn/assets/oms/image/202306/20115388de0207131af17eac86c33049b95d69eaff064e55653a1b941810a006.png?imageMogr2/format/webp", "CCTV3 综艺" to "https://resources.yangshipin.cn/assets/oms/image/202306/7b7a65c712450da3deb6ca66fbacf4f9aee00d3f20bd80eafb5ada01ec63eb3a.png?imageMogr2/format/webp", @@ -66,6 +66,8 @@ object TVList { "四川卫视" to "https://resources.yangshipin.cn/assets/oms/image/202306/3276a414ae0eaa0f116f2045cd913367967d0c7c1e978e8621ac3879436c6ed7.png?imageMogr2/format/webp", "东南卫视" to "https://resources.yangshipin.cn/assets/oms/image/202306/3208fe6564a293c21b711333fb3edb05bb5b406cff840573c9a8d839680a1579.png?imageMogr2/format/webp", "海南卫视" to "https://resources.yangshipin.cn/assets/oms/image/202306/6e060391fde0469801fc3d84dbf204b4f8d650d251f17d7595a6964c0bb99e81.png?imageMogr2/format/webp", + "天津卫视" to "", + "新疆卫视" to "", ) private var mappingEPG = mapOf( "CCTV4K 超高清" to "600002264", @@ -128,6 +130,8 @@ object TVList { "四川卫视" to "600002516", "东南卫视" to "600002484", "海南卫视" to "600002506", + "天津卫视" to "600152137", + "新疆卫视" to "600152138", ) private var mappingVideo = mapOf( "CCTV4K 超高清" to arrayOf("600002264", "2000266303"), @@ -138,7 +142,7 @@ object TVList { "CCTV4 中文国际" to arrayOf("600001814", "2000204803"), "CCTV5 体育" to arrayOf("600001818", "2000205103"), "CCTV5+ 体育赛事" to arrayOf("600001817", "2000204503"), - "CCTV6 电影" to arrayOf("600001802", "2000203303"), + "CCTV6 电影" to arrayOf("600001802", "2013693901"), "CCTV7 国防军事" to arrayOf("600004092", "2000510003"), "CCTV8 电视剧" to arrayOf("600001803", "2000203903"), "CCTV9 记录" to arrayOf("600004078", "2000499403"), @@ -190,6 +194,8 @@ object TVList { "四川卫视" to arrayOf("600002516", "2000295003"), "东南卫视" to arrayOf("600002484", "2000292503"), "海南卫视" to arrayOf("600002506", "2000291503"), + "天津卫视" to arrayOf("600152137", "2019927003"), + "新疆卫视" to arrayOf("600152138", "2019927403"), ) private var count: Int = 0 @@ -201,7 +207,6 @@ CCTV2 财经,http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226195/index CCTV3 综艺,http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226397/index.m3u8 CCTV4 中文国际,http://39.134.24.161/dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226191/index.m3u8;http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226191/index.m3u8 CCTV5 体育,http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226395/index.m3u8 -CCTV5+ 体育赛事,http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226221/index.m3u8 CCTV6 电影,http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226393/index.m3u8 CCTV7 国防军事,http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226192/index.m3u8 CCTV8 电视剧,http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226391/index.m3u8 @@ -214,6 +219,7 @@ CCTV14 少儿,http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226193/inde CCTV15 音乐,http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221225785/index.m3u8 CCTV16 奥林匹克,http://39.134.24.162/dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226921/index.m3u8;http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226921/index.m3u8 CCTV17 农业农村,http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226198/index.m3u8 +CCTV5+ 体育赛事,http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226221/index.m3u8 CCTV4K 超高清, CCTV8K 超高清, 风云剧场,http://dbiptv.sn.chinamobile.com/PLTV/88888893/224/3221226950/index.m3u8 @@ -251,6 +257,8 @@ CCTV8K 超高清, 四川卫视,http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221225768/index.m3u8;http://39.134.24.166/dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221225768/index.m3u8 东南卫视,http://ottrrs.hl.chinamobile.com/PLTV/88888888/224/3221226341/index.m3u8;http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221225766/index.m3u8 海南卫视,http://ottrrs.hl.chinamobile.com/PLTV/88888888/224/3221226465/index.m3u8;http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221225769/index.m3u8 +天津卫视, +新疆卫视, 国际频道 CGTN,http://live.cgtn.com/1000/prog_index.m3u8 CGTN 法语频道,https://livefr.cgtn.com/1000f/prog_index.m3u8 diff --git a/app/src/main/java/com/lizongying/mytv/models/TVListViewModel.kt b/app/src/main/java/com/lizongying/mytv/models/TVListViewModel.kt index 1384f93..de70683 100644 --- a/app/src/main/java/com/lizongying/mytv/models/TVListViewModel.kt +++ b/app/src/main/java/com/lizongying/mytv/models/TVListViewModel.kt @@ -8,7 +8,9 @@ class TVListViewModel : ViewModel() { var maxNum = mutableListOf() - private val tvListViewModel = MutableLiveData>() + private val _tvListViewModel = MutableLiveData>() + val tvListViewModel: LiveData> + get() = _tvListViewModel private val _itemPosition = MutableLiveData() val itemPosition: LiveData @@ -18,22 +20,20 @@ class TVListViewModel : ViewModel() { val itemPositionCurrent: LiveData get() = _itemPositionCurrent - fun getTVListViewModel(): MutableLiveData> { - return tvListViewModel - } - fun addTVViewModel(tvViewModel: TVViewModel) { - val currentTVModelList = tvListViewModel.value ?: mutableListOf() - currentTVModelList.add(tvViewModel) - tvListViewModel.value = currentTVModelList + if (_tvListViewModel.value == null) { + _tvListViewModel.value = mutableListOf(tvViewModel) + } else { + _tvListViewModel.value?.add(tvViewModel) + } } fun getTVViewModel(id: Int): TVViewModel? { - return tvListViewModel.value?.get(id) + return _tvListViewModel.value?.get(id) } fun getTVViewModelCurrent(): TVViewModel? { - return _itemPositionCurrent.value?.let { tvListViewModel.value?.get(it) } + return _itemPositionCurrent.value?.let { _tvListViewModel.value?.get(it) } } fun setItemPosition(position: Int) { @@ -46,6 +46,9 @@ class TVListViewModel : ViewModel() { } fun size(): Int { - return tvListViewModel.value!!.size + if (_tvListViewModel.value == null) { + return 0 + } + return _tvListViewModel.value!!.size } } \ No newline at end of file diff --git a/app/src/main/java/com/lizongying/mytv/models/TVViewModel.kt b/app/src/main/java/com/lizongying/mytv/models/TVViewModel.kt index 66f20db..496729b 100644 --- a/app/src/main/java/com/lizongying/mytv/models/TVViewModel.kt +++ b/app/src/main/java/com/lizongying/mytv/models/TVViewModel.kt @@ -78,6 +78,7 @@ class TVViewModel(private var tv: TV) : ViewModel() { var needToken = false private val channelsNeedToken = arrayOf( +// "CCTV4K 超高清", "CCTV3 综艺", "CCTV6 电影", "CCTV8 电视剧", diff --git a/app/src/main/res/drawable/tianjin.png b/app/src/main/res/drawable/tianjin.png new file mode 100644 index 0000000..aa6afe4 Binary files /dev/null and b/app/src/main/res/drawable/tianjin.png differ diff --git a/app/src/main/res/drawable/xinjiang.png b/app/src/main/res/drawable/xinjiang.png new file mode 100644 index 0000000..e098323 Binary files /dev/null and b/app/src/main/res/drawable/xinjiang.png differ