Skip to content

Commit

Permalink
number selection
Browse files Browse the repository at this point in the history
  • Loading branch information
lizongying committed Jan 17, 2024
1 parent 1aade3a commit 4631103
Show file tree
Hide file tree
Showing 11 changed files with 367 additions and 49 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@

## 更新日志

### v1.4.4(安卓4专用)

* 优化图标显示
* 增加换台反转

### v1.3.3

* 部分错误会提示用户
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<uses-permission android:name="android.permission.INTERNET" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:icon="@drawable/logo"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/Theme.MyTV">
Expand Down
74 changes: 74 additions & 0 deletions app/src/main/java/com/lizongying/mytv/ChannelFragment.kt
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"
}
}
Loading

0 comments on commit 4631103

Please sign in to comment.