Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
WoooKong authored Mar 4, 2024
2 parents ede420a + 95ea83e commit dc81112
Show file tree
Hide file tree
Showing 26 changed files with 908 additions and 174 deletions.
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@

## 更新日志

### v1.6.2(通用)

* 修复按键无效的问题
* 新的频道列表样式

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

* 增加凤凰卫视

### v1.6.0(通用)

* 通用(春晚緊急修復)
Expand Down Expand Up @@ -199,9 +208,8 @@ adb install my-tv.apk
* 凤凰卫视、凤凰资讯台
* 海外
* 1.5.0 无法安装,1.5.1 可以安装
* 选中的图标比例能否相差更大
* 自动重连
* 节目增加预告
* 频道列表优化

## 赞赏

Expand Down
Binary file modified app/src/main/cpp/armeabi-v7a/libnative.so
Binary file not shown.
5 changes: 5 additions & 0 deletions app/src/main/java/com/lizongying/mytv/CardPresenter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ class CardPresenter(
.centerInside()
.into(cardView.mainImageView)

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

else -> Glide.with(viewHolder.view.context)
.load(tvViewModel.logo.value)
.centerInside()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.lizongying.mytv

import android.app.AlertDialog
import android.app.Dialog
import android.os.Bundle
import androidx.fragment.app.DialogFragment

class ConfirmationDialogFragment(private val listener: ConfirmationDialogListener) :
DialogFragment() {

override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
return activity?.let {
val builder = AlertDialog.Builder(it)
builder.setTitle("确认")
.setMessage("确认更新吗?")
.setPositiveButton(
"确定"
) { _, _ ->
listener.onConfirm()
}
.setNegativeButton(
"取消"
) { _, _ ->
listener.onCancel()
}
// 创建并返回 AlertDialog 对象
builder.create()
} ?: throw IllegalStateException("Activity cannot be null")
}

interface ConfirmationDialogListener {
fun onConfirm()
fun onCancel()
}
}

2 changes: 2 additions & 0 deletions app/src/main/java/com/lizongying/mytv/Encryptor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class Encryptor {

external fun hash(data: ByteArray): ByteArray?

external fun hash2(data: ByteArray): ByteArray?

companion object {
init {
System.loadLibrary("native")
Expand Down
29 changes: 19 additions & 10 deletions app/src/main/java/com/lizongying/mytv/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ import java.security.MessageDigest

class MainActivity : FragmentActivity() {

var playerFragment = PlayerFragment()
private val mainFragment = MainFragment()
private val infoFragment = InfoFragment()
private val channelFragment = ChannelFragment()
private var ready = 0
private var playerFragment = PlayerFragment()
private var mainFragment = MainFragment()
private var infoFragment = InfoFragment()
private var channelFragment = ChannelFragment()
private lateinit var settingFragment: SettingFragment

private var doubleBackToExitPressedOnce = false
Expand Down Expand Up @@ -127,19 +128,24 @@ class MainActivity : FragmentActivity() {

if (mainFragment.isHidden) {
transaction.show(mainFragment)
keepRunnable()
mainActive()
} else {
transaction.hide(mainFragment)
}

transaction.commit()
}

fun keepRunnable() {
fun mainActive() {
handler.removeCallbacks(hideMain)
handler.postDelayed(hideMain, delayHideMain)
}

fun settingActive() {
handler.removeCallbacks(hideSetting)
handler.postDelayed(hideSetting, delayHideSetting)
}

private val hideMain = Runnable {
if (!mainFragment.isHidden) {
supportFragmentManager.beginTransaction().hide(mainFragment).commit()
Expand All @@ -159,7 +165,11 @@ class MainActivity : FragmentActivity() {
}

fun fragmentReady() {
mainFragment.fragmentReady()
ready++
Log.i(TAG, "ready $ready")
if (ready == 4) {
mainFragment.fragmentReady()
}
}

override fun onTouchEvent(event: MotionEvent?): Boolean {
Expand Down Expand Up @@ -218,8 +228,7 @@ class MainActivity : FragmentActivity() {
Log.i(TAG, "settingFragment ${settingFragment.isVisible}")
if (!settingFragment.isVisible) {
settingFragment.show(supportFragmentManager, "setting")
handler.removeCallbacks(hideSetting)
handler.postDelayed(hideSetting, delayHideSetting)
settingActive()
} else {
handler.removeCallbacks(hideSetting)
settingFragment.dismiss()
Expand Down Expand Up @@ -497,4 +506,4 @@ class MainActivity : FragmentActivity() {
private companion object {
const val TAG = "MainActivity"
}
}
}
17 changes: 7 additions & 10 deletions app/src/main/java/com/lizongying/mytv/MainFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ class MainFragment : BrowseSupportFragment() {
private val handler = Handler(Looper.getMainLooper())
private lateinit var mUpdateProgramRunnable: UpdateProgramRunnable

private var ready = 0

override fun onCreate(savedInstanceState: Bundle?) {
Log.i(TAG, "onCreate")
super.onCreate(savedInstanceState)
Expand Down Expand Up @@ -85,6 +83,7 @@ class MainFragment : BrowseSupportFragment() {
tvViewModel.change.observe(viewLifecycleOwner) { _ ->
if (tvViewModel.change.value != null) {
val title = tvViewModel.title.value
Log.i(TAG, "switch $title")
if (tvViewModel.pid.value != "") {
Log.i(TAG, "request $title")
lifecycleScope.launch(Dispatchers.IO) {
Expand All @@ -109,7 +108,7 @@ class MainFragment : BrowseSupportFragment() {
}
}

fragmentReady()
(activity as MainActivity).fragmentReady()
}

fun toLastPosition() {
Expand Down Expand Up @@ -219,7 +218,7 @@ class MainFragment : BrowseSupportFragment() {
) {
if (item is TVViewModel) {
tvListViewModel.setItemPositionCurrent(item.id.value!!)
(activity as MainActivity).keepRunnable()
(activity as MainActivity).mainActive()
}
}
}
Expand All @@ -241,12 +240,8 @@ class MainFragment : BrowseSupportFragment() {
}

fun fragmentReady() {
ready++
Log.i(TAG, "ready $ready")
if (ready == 4) {
// request.fetchPage()
tvListViewModel.getTVViewModel(itemPosition)?.changed()
}
tvListViewModel.getTVViewModel(itemPosition)?.changed()
}

fun play(itemPosition: Int) {
Expand Down Expand Up @@ -325,7 +320,9 @@ class MainFragment : BrowseSupportFragment() {
override fun onDestroy() {
Log.i(TAG, "onDestroy")
super.onDestroy()
handler.removeCallbacks(mUpdateProgramRunnable)
if (::mUpdateProgramRunnable.isInitialized) {
handler.removeCallbacks(mUpdateProgramRunnable)
}
}

companion object {
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/com/lizongying/mytv/PlayerFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class PlayerFragment : Fragment(), SurfaceHolder.Callback {
super.onPlayerError(error)

Log.e(TAG, "PlaybackException $error")
tvViewModel?.changed()
}
})
}
Expand Down Expand Up @@ -107,10 +108,12 @@ class PlayerFragment : Fragment(), SurfaceHolder.Callback {
if (playerView != null && playerView!!.player?.isPlaying == false) {
Log.i(TAG, "replay")
playerView!!.player?.prepare()
playerView!!.player?.play()
}
if (exoPlayer?.isPlaying == false) {
Log.i(TAG, "replay")
exoPlayer?.prepare()
exoPlayer?.play()
}
}

Expand Down
Loading

0 comments on commit dc81112

Please sign in to comment.