@@ -3,6 +3,7 @@ package com.lizongying.mytv0
33import MainViewModel
44import android.os.Bundle
55import android.os.Handler
6+ import android.util.Log
67import android.view.LayoutInflater
78import android.view.View
89import android.view.ViewGroup
@@ -59,13 +60,18 @@ class ChannelFragment : Fragment() {
5960 fun show (tvViewModel : TVModel ) {
6061 handler.removeCallbacks(hideRunnable)
6162 handler.removeCallbacks(playRunnable)
62- binding.content.text = (tvViewModel.tv.id.plus(1 )).toString()
63+ if (_binding != null ) {
64+ binding.content.text =
65+ if (tvViewModel.tv.number == - 1 ) (tvViewModel.tv.id.plus(1 )).toString() else tvViewModel.tv.number.toString()
66+ }
6367 view?.visibility = View .VISIBLE
6468 handler.postDelayed(hideRunnable, delay)
6569 }
6670
6771 fun show (channel : String ) {
68- if (viewModel.groupModel.getCurrent()!! .tv.id > 10 && viewModel.groupModel.getCurrent()!! .tv.id == this .channel - 1 ) {
72+ Log .d(TAG , " input $channel " )
73+ val tv = viewModel.groupModel.getCurrent()!! .tv
74+ if (tv.id > 10 && tv.id == this .channel - 1 ) {
6975 this .channel = 0
7076 channelCount = 0
7177 }
@@ -76,9 +82,10 @@ class ChannelFragment : Fragment() {
7682 this .channel = " ${this .channel}$channel " .toInt()
7783 handler.removeCallbacks(hideRunnable)
7884 handler.removeCallbacks(playRunnable)
85+ Log .d(TAG , " channelCount $channelCount " )
86+ binding.content.text = this .channel.toString()
87+ view?.visibility = View .VISIBLE
7988 if (channelCount < 3 ) {
80- binding.content.text = this .channel.toString()
81- view?.visibility = View .VISIBLE
8289 handler.postDelayed(playRunnable, delay)
8390 } else {
8491 handler.postDelayed(playRunnable, 0 )
@@ -108,8 +115,16 @@ class ChannelFragment : Fragment() {
108115 channelCount = 0
109116 }
110117
118+ fun hideSelf () {
119+ handler.postDelayed(hideRunnable, 0 )
120+ }
121+
111122 private val playRunnable = Runnable {
112- (activity as MainActivity ).play(channel - 1 )
123+ var c = channel - 1
124+ viewModel.listModel.find { it.tv.number == channel }?.let {
125+ c = it.tv.id
126+ }
127+ (activity as MainActivity ).play(c)
113128 handler.postDelayed(hideRunnable, delay)
114129 }
115130
0 commit comments