show info
This commit is contained in:
parent
e6530b4e9e
commit
72e893b73a
|
|
@ -1,16 +1,23 @@
|
||||||
package com.lizongying.mytv
|
package com.lizongying.mytv
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.os.Handler
|
||||||
|
import android.util.Log
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
|
import com.bumptech.glide.Glide
|
||||||
import com.lizongying.mytv.databinding.InfoBinding
|
import com.lizongying.mytv.databinding.InfoBinding
|
||||||
|
import com.lizongying.mytv.models.TVViewModel
|
||||||
|
|
||||||
class InfoFragment : Fragment() {
|
class InfoFragment : Fragment() {
|
||||||
private var _binding: InfoBinding? = null
|
private var _binding: InfoBinding? = null
|
||||||
private val binding get() = _binding!!
|
private val binding get() = _binding!!
|
||||||
|
|
||||||
|
private val handler = Handler()
|
||||||
|
private val delay: Long = 3000
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater, container: ViewGroup?,
|
inflater: LayoutInflater, container: ViewGroup?,
|
||||||
savedInstanceState: Bundle?
|
savedInstanceState: Bundle?
|
||||||
|
|
@ -19,8 +26,41 @@ class InfoFragment : Fragment() {
|
||||||
return binding.root
|
return binding.root
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setInfo(info: TV) {
|
override fun onResume() {
|
||||||
binding.textView.text = info.title
|
super.onResume()
|
||||||
|
|
||||||
|
// Use a Handler to delay the fragment transaction
|
||||||
|
handler.postDelayed(removeRunnable, delay)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun show() {
|
||||||
|
Log.i("", "show")
|
||||||
|
handler.removeCallbacks(removeRunnable)
|
||||||
|
view?.visibility = View.VISIBLE
|
||||||
|
handler.postDelayed(removeRunnable, delay)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPause() {
|
||||||
|
super.onPause()
|
||||||
|
Log.i("", "onPause")
|
||||||
|
// Cancel the delayed task when the fragment is paused
|
||||||
|
handler.removeCallbacks(removeRunnable)
|
||||||
|
}
|
||||||
|
|
||||||
|
private val removeRunnable = Runnable {
|
||||||
|
Log.i("", "hide")
|
||||||
|
view?.visibility = View.GONE
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setInfo(tvViewModel: TVViewModel) {
|
||||||
|
binding.textView.text = tvViewModel.title.value
|
||||||
|
Glide.with(this)
|
||||||
|
.load(tvViewModel.logo.value)
|
||||||
|
.into(binding.infoLogo)
|
||||||
|
val program = tvViewModel.getProgramOne()
|
||||||
|
if (program != null) {
|
||||||
|
binding.infoDesc.text = program.name
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView() {
|
override fun onDestroyView() {
|
||||||
|
|
|
||||||
|
|
@ -55,25 +55,9 @@ class MainActivity : FragmentActivity() {
|
||||||
gestureDetector = GestureDetector(this, GestureListener())
|
gestureDetector = GestureDetector(this, GestureListener())
|
||||||
}
|
}
|
||||||
|
|
||||||
fun switchInfoFragment(tv: TV) {
|
fun showInfoFragment(tvViewModel: TVViewModel) {
|
||||||
infoFragment.setInfo(tv)
|
infoFragment.setInfo(tvViewModel)
|
||||||
|
infoFragment.show()
|
||||||
if (infoFragment.isHidden) {
|
|
||||||
supportFragmentManager.beginTransaction().show(infoFragment).commit()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun showInfoFragment(tv: TV) {
|
|
||||||
infoFragment.setInfo(tv)
|
|
||||||
supportFragmentManager.beginTransaction()
|
|
||||||
.show(infoFragment)
|
|
||||||
.commit()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun hideInfoFragment() {
|
|
||||||
supportFragmentManager.beginTransaction()
|
|
||||||
.hide(infoFragment)
|
|
||||||
.commit()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun play(tvViewModel: TVViewModel) {
|
fun play(tvViewModel: TVViewModel) {
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ import android.content.Context
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.widget.Toast
|
|
||||||
import androidx.leanback.app.BrowseSupportFragment
|
import androidx.leanback.app.BrowseSupportFragment
|
||||||
import androidx.leanback.widget.ArrayObjectAdapter
|
import androidx.leanback.widget.ArrayObjectAdapter
|
||||||
import androidx.leanback.widget.HeaderItem
|
import androidx.leanback.widget.HeaderItem
|
||||||
|
|
@ -64,7 +63,6 @@ class MainFragment : BrowseSupportFragment() {
|
||||||
) {
|
) {
|
||||||
Log.i(TAG, "ready ${tvViewModel.title.value}")
|
Log.i(TAG, "ready ${tvViewModel.title.value}")
|
||||||
(activity as? MainActivity)?.play(tvViewModel)
|
(activity as? MainActivity)?.play(tvViewModel)
|
||||||
// (activity as? MainActivity)?.switchInfoFragment(item)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tvViewModel.change.observe(viewLifecycleOwner) { _ ->
|
tvViewModel.change.observe(viewLifecycleOwner) { _ ->
|
||||||
|
|
@ -76,29 +74,20 @@ class MainFragment : BrowseSupportFragment() {
|
||||||
lifecycleScope.launch(Dispatchers.IO) {
|
lifecycleScope.launch(Dispatchers.IO) {
|
||||||
tvViewModel.let { request?.fetchData(it) }
|
tvViewModel.let { request?.fetchData(it) }
|
||||||
}
|
}
|
||||||
|
(activity as? MainActivity)?.showInfoFragment(tvViewModel)
|
||||||
setSelectedPosition(
|
setSelectedPosition(
|
||||||
tvViewModel.getRowPosition(), true,
|
tvViewModel.getRowPosition(), true,
|
||||||
SelectItemViewHolderTask(tvViewModel.getItemPosition())
|
SelectItemViewHolderTask(tvViewModel.getItemPosition())
|
||||||
)
|
)
|
||||||
Toast.makeText(
|
|
||||||
activity,
|
|
||||||
title,
|
|
||||||
Toast.LENGTH_SHORT
|
|
||||||
).show()
|
|
||||||
} else {
|
} else {
|
||||||
if (check(tvViewModel)) {
|
if (check(tvViewModel)) {
|
||||||
(activity as? MainActivity)?.play(tvViewModel)
|
(activity as? MainActivity)?.play(tvViewModel)
|
||||||
// (activity as? MainActivity)?.switchInfoFragment(item)
|
(activity as? MainActivity)?.showInfoFragment(tvViewModel)
|
||||||
|
|
||||||
setSelectedPosition(
|
setSelectedPosition(
|
||||||
tvViewModel.getRowPosition(), true,
|
tvViewModel.getRowPosition(), true,
|
||||||
SelectItemViewHolderTask(tvViewModel.getItemPosition())
|
SelectItemViewHolderTask(tvViewModel.getItemPosition())
|
||||||
)
|
)
|
||||||
Toast.makeText(
|
|
||||||
activity,
|
|
||||||
title,
|
|
||||||
Toast.LENGTH_SHORT
|
|
||||||
).show()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -69,10 +69,10 @@ CGTN 纪录频道,https://livedoc.cgtn.com/500d/prog_index.m3u8,https://resource
|
||||||
四川卫视,http://39.134.24.166/dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221225768/index.m3u8;http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221225768/index.m3u8,https://resources.yangshipin.cn/assets/oms/image/202306/3276a414ae0eaa0f116f2045cd913367967d0c7c1e978e8621ac3879436c6ed7.png?imageMogr2/format/webp,600002516,2000295003
|
四川卫视,http://39.134.24.166/dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221225768/index.m3u8;http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221225768/index.m3u8,https://resources.yangshipin.cn/assets/oms/image/202306/3276a414ae0eaa0f116f2045cd913367967d0c7c1e978e8621ac3879436c6ed7.png?imageMogr2/format/webp,600002516,2000295003
|
||||||
东南卫视,http://ottrrs.hl.chinamobile.com/PLTV/88888888/224/3221226341/index.m3u8;http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221225766/index.m3u8,https://resources.yangshipin.cn/assets/oms/image/202306/3208fe6564a293c21b711333fb3edb05bb5b406cff840573c9a8d839680a1579.png?imageMogr2/format/webp,600002484,2000292503
|
东南卫视,http://ottrrs.hl.chinamobile.com/PLTV/88888888/224/3221226341/index.m3u8;http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221225766/index.m3u8,https://resources.yangshipin.cn/assets/oms/image/202306/3208fe6564a293c21b711333fb3edb05bb5b406cff840573c9a8d839680a1579.png?imageMogr2/format/webp,600002484,2000292503
|
||||||
海南卫视,http://ottrrs.hl.chinamobile.com/PLTV/88888888/224/3221226465/index.m3u8;http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221225769/index.m3u8,https://resources.yangshipin.cn/assets/oms/image/202306/6e060391fde0469801fc3d84dbf204b4f8d650d251f17d7595a6964c0bb99e81.png?imageMogr2/format/webp,600002506,2000291503
|
海南卫视,http://ottrrs.hl.chinamobile.com/PLTV/88888888/224/3221226465/index.m3u8;http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221225769/index.m3u8,https://resources.yangshipin.cn/assets/oms/image/202306/6e060391fde0469801fc3d84dbf204b4f8d650d251f17d7595a6964c0bb99e81.png?imageMogr2/format/webp,600002506,2000291503
|
||||||
三沙卫视,https://pullsstv90080111.ssws.tv/live/SSTV20220729.m3u8
|
|
||||||
|
|
||||||
移动专区
|
移动专区
|
||||||
|
|
||||||
|
三沙卫视,https://pullsstv90080111.ssws.tv/live/SSTV20220729.m3u8
|
||||||
|
|
||||||
天津卫视,http://ottrrs.hl.chinamobile.com/PLTV/88888888/224/3221225740/index.m3u8;http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226204/index.m3u8
|
天津卫视,http://ottrrs.hl.chinamobile.com/PLTV/88888888/224/3221225740/index.m3u8;http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221226204/index.m3u8
|
||||||
吉林卫视,http://ottrrs.hl.chinamobile.com/PLTV/88888888/224/3221226397/index.m3u8;http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221225792/index.m3u8
|
吉林卫视,http://ottrrs.hl.chinamobile.com/PLTV/88888888/224/3221226397/index.m3u8;http://dbiptv.sn.chinamobile.com/PLTV/88888890/224/3221225792/index.m3u8
|
||||||
|
|
|
||||||
|
|
@ -324,7 +324,7 @@ class TVViewModel(private var tv: TV) : ViewModel() {
|
||||||
_title.value = tv.title
|
_title.value = tv.title
|
||||||
_videoUrl.value = tv.videoUrl
|
_videoUrl.value = tv.videoUrl
|
||||||
_videoIndex.value = tv.videoIndex
|
_videoIndex.value = tv.videoIndex
|
||||||
Log.i(TAG, "tv.title ${tv.title} ${mappingLogo[tv.title]}")
|
Log.d(TAG, "${tv.title} ${mappingLogo[tv.title]}")
|
||||||
if (mappingLogo[tv.title] != null) {
|
if (mappingLogo[tv.title] != null) {
|
||||||
_logo.value = mappingLogo[tv.title]
|
_logo.value = mappingLogo[tv.title]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<solid android:color="@color/white" />
|
||||||
|
<corners android:radius="4dp" /> <!-- Adjust the radius as needed -->
|
||||||
|
</shape>
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<solid android:color="#FF263238" />
|
||||||
|
<corners android:radius="4dp" /> <!-- Adjust the radius as needed -->
|
||||||
|
</shape>
|
||||||
|
|
@ -5,15 +5,50 @@
|
||||||
android:layout_height="80dp"
|
android:layout_height="80dp"
|
||||||
android:layout_gravity="center_horizontal|bottom"
|
android:layout_gravity="center_horizontal|bottom"
|
||||||
android:layout_marginBottom="20dp"
|
android:layout_marginBottom="20dp"
|
||||||
android:background="@color/fastlane_background"
|
android:background="@drawable/rounded_background">
|
||||||
>
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/info_logo"
|
||||||
|
android:layout_width="100dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:contentDescription="@string/logo"
|
||||||
|
android:padding="10dp" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="216dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_marginStart="100dp"
|
||||||
|
android:background="#FF263238"
|
||||||
|
android:gravity="start|center_vertical"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="7dp">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/textView"
|
android:id="@+id/textView"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_horizontal|top"
|
android:layout_gravity="start"
|
||||||
|
android:layout_marginTop="0dp"
|
||||||
|
android:gravity="start"
|
||||||
|
android:textColor="#FFEEEEEE"
|
||||||
|
android:textSize="20sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/info_desc"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="start"
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="10dp"
|
||||||
android:textSize="40sp"
|
android:gravity="start"
|
||||||
/>
|
android:singleLine="true"
|
||||||
|
android:textColor="#B3EEEEEE"
|
||||||
|
android:textSize="16sp" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="8dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="end"
|
||||||
|
android:background="@drawable/rounded_background2" />
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
<resources>
|
<resources>
|
||||||
<color name="fastlane_background">#30000000</color>
|
<color name="fastlane_background">#30000000</color>
|
||||||
<color name="black">#000</color>
|
<color name="black">#000</color>
|
||||||
|
<color name="white">#FFF</color>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">我的电视</string>
|
<string name="app_name">我的电视</string>
|
||||||
|
<string name="logo">logo</string>
|
||||||
</resources>
|
</resources>
|
||||||
Loading…
Reference in New Issue