-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1aade3a
commit 4631103
Showing
11 changed files
with
367 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,11 @@ | |
|
||
## 更新日志 | ||
|
||
### v1.4.4(安卓4专用) | ||
|
||
* 优化图标显示 | ||
* 增加换台反转 | ||
|
||
### v1.3.3 | ||
|
||
* 部分错误会提示用户 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
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 | ||
import androidx.fragment.app.Fragment | ||
import com.lizongying.mytv.databinding.ChannelBinding | ||
import com.lizongying.mytv.models.TVViewModel | ||
|
||
class ChannelFragment : Fragment() { | ||
private var _binding: ChannelBinding? = null | ||
private val binding get() = _binding!! | ||
|
||
private val handler = Handler() | ||
private val delay: Long = 3000 | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View { | ||
_binding = ChannelBinding.inflate(inflater, container, false) | ||
(activity as MainActivity).fragmentReady() | ||
return binding.root | ||
} | ||
|
||
fun show(tvViewModel: TVViewModel) { | ||
binding.channelContent.text = tvViewModel.id.value.toString() | ||
handler.removeCallbacks(removeRunnable) | ||
view?.visibility = View.VISIBLE | ||
handler.postDelayed(removeRunnable, delay) | ||
} | ||
|
||
fun show(channel: String) { | ||
if (binding.channelContent.text == "") { | ||
binding.channelContent.text = channel | ||
handler.removeCallbacks(removeRunnable) | ||
view?.visibility = View.VISIBLE | ||
handler.postDelayed(removeRunnable, delay) | ||
} else { | ||
val ch = "${binding.channelContent.text}$channel".toInt() | ||
Log.i(TAG, "channel $ch") | ||
(activity as MainActivity).play(ch) | ||
binding.channelContent.text = "" | ||
view?.visibility = View.GONE | ||
} | ||
} | ||
|
||
override fun onResume() { | ||
super.onResume() | ||
handler.postDelayed(removeRunnable, delay) | ||
} | ||
|
||
override fun onPause() { | ||
super.onPause() | ||
handler.removeCallbacks(removeRunnable) | ||
} | ||
|
||
private val removeRunnable = Runnable { | ||
binding.channelContent.text = "" | ||
view?.visibility = View.GONE | ||
} | ||
|
||
override fun onDestroyView() { | ||
super.onDestroyView() | ||
_binding = null | ||
} | ||
|
||
companion object { | ||
private const val TAG = "ChannelFragment" | ||
} | ||
} |
Oops, something went wrong.