Skip to content

Commit

Permalink
phoenix epg
Browse files Browse the repository at this point in the history
  • Loading branch information
lizongying committed Mar 12, 2024
1 parent 00e6c8d commit d37ada1
Show file tree
Hide file tree
Showing 19 changed files with 1,337 additions and 1,270 deletions.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,26 @@

## 更新日志

### v1.6.6(通用)

* 更新重庆卫视图标
* 凤凰卫视增强画质
* 凤凰卫视增加EPG

### v1.6.4(通用)

* 增加CETV1
* 增加凤凰卫视
* 默认关闭开机启动

### v1.6.3(安卓5及以上专用)

* 增加CETV1
* 凤凰卫视增强画质
* 默认关闭开机启动
* 延迟菜单自动关闭时间
* 解决一些可能导致首次打开时黑屏的问题

### v1.6.2(通用)

* 修复按键无效的问题
Expand Down Expand Up @@ -211,11 +225,11 @@ adb install my-tv.apk
* 地方频道
* 收藏夹
* 自定义源
* 凤凰卫视、凤凰资讯台
* 海外
* 1.5.0 无法安装,1.5.1 可以安装
* 节目增加预告
* 频道列表优化
* epg更新后菜单更新

## 赞赏

Expand Down
Binary file modified app/src/main/cpp/arm64-v8a/libnative.so
Binary file not shown.
Binary file modified app/src/main/cpp/armeabi-v7a/libnative.so
Binary file not shown.
45 changes: 9 additions & 36 deletions app/src/main/java/com/lizongying/mytv/CardAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -88,46 +88,19 @@ class CardAdapter(

cardView.titleText = tvViewModel.title.value

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)

"新疆卫视" -> Glide.with(viewHolder.view.context)
.load(R.drawable.xinjiang)
.centerInside()
.into(cardView.mainImageView)

"兵团卫视" -> Glide.with(viewHolder.view.context)
.load(R.drawable.bingtuan)
.centerInside()
.into(cardView.mainImageView)

"CETV1" -> Glide.with(viewHolder.view.context)
.load(R.drawable.cetv1)
.centerInside()
.into(cardView.mainImageView)

else -> Glide.with(viewHolder.view.context)
.load(tvViewModel.logo.value)
.centerInside()
.into(cardView.mainImageView)
}
Glide.with(viewHolder.view.context)
.load(tvViewModel.logo.value)
.centerInside()
.into(cardView.mainImageView)

cardView.mainImageView.setBackgroundColor(Color.WHITE)
cardView.setMainImageScaleType(ImageView.ScaleType.CENTER_INSIDE)

tvViewModel.program.observe(owner) { _ ->
val program = tvViewModel.getProgramOne()
if (program != null) {
cardView.contentText = program.name
}
val epg = tvViewModel.epg.value?.filter { it.beginTime < Utils.getDateTimestamp() }
if (!epg.isNullOrEmpty()) {
cardView.contentText = epg.last().title
} else {
cardView.contentText = ""
}
}

Expand Down
38 changes: 10 additions & 28 deletions app/src/main/java/com/lizongying/mytv/InfoFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ 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
Expand Down Expand Up @@ -30,35 +31,16 @@ class InfoFragment : Fragment() {
fun show(tvViewModel: TVViewModel) {
binding.textView.text = tvViewModel.title.value

when (tvViewModel.title.value) {
"CCTV8K 超高清" -> Glide.with(this)
.load(R.drawable.cctv8k)
.into(binding.infoLogo)
Glide.with(this)
.load(tvViewModel.logo.value)
.into(binding.infoLogo)

"天津卫视" -> Glide.with(this)
.load(R.drawable.tianjin)
.into(binding.infoLogo)

"新疆卫视" -> Glide.with(this)
.load(R.drawable.xinjiang)
.into(binding.infoLogo)

"兵团卫视" -> Glide.with(this)
.load(R.drawable.bingtuan)
.into(binding.infoLogo)

"CETV1" -> Glide.with(this)
.load(R.drawable.cetv1)
.into(binding.infoLogo)

else -> Glide.with(this)
.load(tvViewModel.logo.value)
.into(binding.infoLogo)
}

val program = tvViewModel.getProgramOne()
if (program != null) {
binding.infoDesc.text = program.name
Log.i(TAG, "${tvViewModel.title.value} ${tvViewModel.epg.value}")
val epg = tvViewModel.epg.value?.filter { it.beginTime < Utils.getDateTimestamp() }
if (!epg.isNullOrEmpty()) {
binding.infoDesc.text = epg.last().title
} else {
binding.infoDesc.text = ""
}

handler.removeCallbacks(removeRunnable)
Expand Down
36 changes: 22 additions & 14 deletions app/src/main/java/com/lizongying/mytv/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import kotlinx.coroutines.launch
import java.security.MessageDigest


class MainActivity : FragmentActivity() {
class MainActivity : FragmentActivity(), Request.RequestListener {

private var ready = 0
private var playerFragment = PlayerFragment()
Expand All @@ -39,24 +39,17 @@ class MainActivity : FragmentActivity() {
private lateinit var gestureDetector: GestureDetector

private val handler = Handler()
private val delayHideMain: Long = 5000
private val delayHideMain: Long = 10000
private val delayHideSetting: Long = 10000

init {
lifecycleScope.launch(Dispatchers.IO) {
val utilsJob = async(start = CoroutineStart.LAZY) { Utils.init() }

utilsJob.start()

utilsJob.await()
}
}

override fun onCreate(savedInstanceState: Bundle?) {
Log.i(TAG, "onCreate")
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

Request.onCreate()
Request.setRequestListener(this)

window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)
window.decorView.systemUiVisibility = SYSTEM_UI_FLAG_HIDE_NAVIGATION
Expand All @@ -78,7 +71,13 @@ class MainActivity : FragmentActivity() {
} else {
packageInfo.versionCode.toLong()
}
settingFragment = SettingFragment(versionName, versionCode, SP.channelReversal, SP.channelNum, SP.bootStartup)
settingFragment = SettingFragment(
versionName,
versionCode,
SP.channelReversal,
SP.channelNum,
SP.bootStartup
)
}

fun showInfoFragment(tvViewModel: TVViewModel) {
Expand Down Expand Up @@ -172,7 +171,7 @@ class MainActivity : FragmentActivity() {
fun fragmentReady() {
ready++
Log.i(TAG, "ready $ready")
if (ready == 4) {
if (ready == 5) {
mainFragment.fragmentReady()
}
}
Expand Down Expand Up @@ -519,6 +518,15 @@ class MainActivity : FragmentActivity() {
handler.removeCallbacks(hideMain)
}

override fun onDestroy() {
super.onDestroy()
Request.onDestroy()
}

override fun onRequestFinished() {
fragmentReady()
}

private companion object {
const val TAG = "MainActivity"
}
Expand Down
50 changes: 10 additions & 40 deletions app/src/main/java/com/lizongying/mytv/MainFragment.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.lizongying.mytv

import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.util.Log
import android.view.KeyEvent
import android.view.LayoutInflater
Expand All @@ -14,7 +12,7 @@ import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.lizongying.mytv.Utils.dpToPx
import com.lizongying.mytv.Utils.getDateTimestamp
import com.lizongying.mytv.api.YSP
import com.lizongying.mytv.databinding.RowBinding
import com.lizongying.mytv.databinding.ShowBinding
import com.lizongying.mytv.models.TVListViewModel
Expand All @@ -32,15 +30,10 @@ class MainFragment : Fragment(), CardAdapter.ItemListener {
private var _binding: ShowBinding? = null
private val binding get() = _binding!!

private var request = Request()

var tvListViewModel = TVListViewModel()

private var lastVideoUrl = ""

private val handler = Handler(Looper.getMainLooper())
private lateinit var mUpdateProgramRunnable: UpdateProgramRunnable

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
Expand All @@ -52,7 +45,7 @@ class MainFragment : Fragment(), CardAdapter.ItemListener {
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)

activity?.let { request.initYSP(it) }
activity?.let { YSP.init(it) }

itemPosition = SP.itemPosition

Expand All @@ -71,6 +64,8 @@ class MainFragment : Fragment(), CardAdapter.ItemListener {
tvViewModel.setItemPosition(idx2)
tvListViewModelCurrent.addTVViewModel(tvViewModel)
tvListViewModel.addTVViewModel(tvViewModel)

updateEPG(tvViewModel)
}
tvListViewModel.maxNum.add(v.size)

Expand Down Expand Up @@ -112,9 +107,6 @@ class MainFragment : Fragment(), CardAdapter.ItemListener {
idx++
}

mUpdateProgramRunnable = UpdateProgramRunnable()
handler.post(mUpdateProgramRunnable)

if (itemPosition >= tvListViewModel.size()) {
itemPosition = 0
}
Expand Down Expand Up @@ -155,7 +147,7 @@ class MainFragment : Fragment(), CardAdapter.ItemListener {
if (tvViewModel.pid.value != "") {
Log.i(TAG, "request $title")
lifecycleScope.launch(Dispatchers.IO) {
tvViewModel.let { request.fetchData(it) }
tvViewModel.let { Request.fetchData(it) }
}
(activity as? MainActivity)?.showInfoFragment(tvViewModel)
setPosition(
Expand Down Expand Up @@ -304,30 +296,11 @@ class MainFragment : Fragment(), CardAdapter.ItemListener {
}
}

fun updateProgram(tvViewModel: TVViewModel) {
val timestamp = getDateTimestamp()
if (timestamp - tvViewModel.programUpdateTime > 60) {
if (tvViewModel.program.value!!.isEmpty()) {
tvViewModel.programUpdateTime = timestamp
request.fetchProgram(tvViewModel)
} else {
if (tvViewModel.program.value!!.last().et - timestamp < 600) {
tvViewModel.programUpdateTime = timestamp
request.fetchProgram(tvViewModel)
}
}
}
}

inner class UpdateProgramRunnable : Runnable {
override fun run() {
tvListViewModel.tvListViewModel.value?.filter { it.programId.value != null && it.programId.value != "" }
?.forEach { tvViewModel ->
updateProgram(
tvViewModel
)
}
handler.postDelayed(this, 60000)
private fun updateEPG(tvViewModel: TVViewModel) {
if (tvViewModel.getTV().channel == "港澳台") {
Request.fetchFEPG(tvViewModel)
} else {
Request.fetchYEPG(tvViewModel)
}
}

Expand All @@ -346,9 +319,6 @@ class MainFragment : Fragment(), CardAdapter.ItemListener {
override fun onDestroy() {
Log.i(TAG, "onDestroy")
super.onDestroy()
if (::mUpdateProgramRunnable.isInitialized) {
handler.removeCallbacks(mUpdateProgramRunnable)
}
}

override fun onDestroyView() {
Expand Down
Loading

0 comments on commit d37ada1

Please sign in to comment.