mirror of
https://github.com/lizongying/my-tv.git
synced 2026-10-26 14:16:29 +08:00
fix time
This commit is contained in:
@@ -39,6 +39,7 @@ class ChannelFragment : Fragment() {
|
||||
binding.channel.layoutParams = layoutParams
|
||||
|
||||
binding.content.textSize = application.px2PxFont(binding.content.textSize)
|
||||
binding.time.textSize = application.px2PxFont(binding.time.textSize)
|
||||
|
||||
binding.main.layoutParams.width = application.shouldWidthPx()
|
||||
binding.main.layoutParams.height = application.shouldHeightPx()
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
package com.lizongying.mytv
|
||||
|
||||
import android.content.Context
|
||||
import android.net.ConnectivityManager
|
||||
import android.net.Network
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
@@ -34,7 +31,7 @@ class MainActivity : FragmentActivity(), Request.RequestListener {
|
||||
private val playerFragment = PlayerFragment()
|
||||
private val errorFragment = ErrorFragment()
|
||||
|
||||
// private val loadingFragment = LoadingFragment()
|
||||
private val loadingFragment = LoadingFragment()
|
||||
private val mainFragment = MainFragment()
|
||||
private val infoFragment = InfoFragment()
|
||||
private val channelFragment = ChannelFragment()
|
||||
@@ -86,7 +83,7 @@ class MainActivity : FragmentActivity(), Request.RequestListener {
|
||||
// }
|
||||
|
||||
if (savedInstanceState == null) {
|
||||
supportFragmentManager.beginTransaction()
|
||||
val transaction = supportFragmentManager.beginTransaction()
|
||||
.add(R.id.main_browse_fragment, playerFragment)
|
||||
.add(R.id.main_browse_fragment, errorFragment)
|
||||
// .add(R.id.main_browse_fragment, loadingFragment)
|
||||
@@ -96,9 +93,14 @@ class MainActivity : FragmentActivity(), Request.RequestListener {
|
||||
.add(R.id.main_browse_fragment, mainFragment)
|
||||
.hide(mainFragment)
|
||||
.hide(errorFragment)
|
||||
// .hide(loadingFragment)
|
||||
.hide(timeFragment)
|
||||
.commit()
|
||||
|
||||
if (!SP.time) {
|
||||
transaction.hide(timeFragment)
|
||||
} else {
|
||||
transaction.show(timeFragment)
|
||||
}
|
||||
|
||||
transaction.commitNow()
|
||||
}
|
||||
gestureDetector = GestureDetector(this, GestureListener())
|
||||
|
||||
@@ -120,9 +122,6 @@ class MainActivity : FragmentActivity(), Request.RequestListener {
|
||||
// Log.i(TAG, "net ${Build.VERSION.SDK_INT}")
|
||||
// ready++
|
||||
// }
|
||||
|
||||
showTime()
|
||||
mainFragment.changeMenu()
|
||||
}
|
||||
|
||||
fun showInfoFragment(tvViewModel: TVViewModel) {
|
||||
@@ -152,6 +151,14 @@ class MainActivity : FragmentActivity(), Request.RequestListener {
|
||||
.commit()
|
||||
}
|
||||
|
||||
fun showLoadingFragment() {
|
||||
showFragment(loadingFragment)
|
||||
}
|
||||
|
||||
fun hideLoadingFragment() {
|
||||
hideFragment(loadingFragment)
|
||||
}
|
||||
|
||||
fun showPlayerFragment() {
|
||||
if (playerFragment.isVisible) {
|
||||
return
|
||||
@@ -222,8 +229,6 @@ class MainActivity : FragmentActivity(), Request.RequestListener {
|
||||
fun settingDelayHide() {
|
||||
handler.removeCallbacks(hideSetting)
|
||||
handler.postDelayed(hideSetting, delayHideSetting)
|
||||
showTime()
|
||||
mainFragment.changeMenu()
|
||||
}
|
||||
|
||||
fun settingNeverHide() {
|
||||
@@ -342,14 +347,12 @@ class MainActivity : FragmentActivity(), Request.RequestListener {
|
||||
return
|
||||
}
|
||||
|
||||
Log.i(TAG, "settingFragment ${settingFragment.isVisible}")
|
||||
if (!settingFragment.isVisible) {
|
||||
settingFragment.show(supportFragmentManager, "setting")
|
||||
settingDelayHide()
|
||||
} else {
|
||||
handler.removeCallbacks(hideSetting)
|
||||
settingFragment.dismiss()
|
||||
if (settingFragment.isVisible) {
|
||||
return
|
||||
}
|
||||
|
||||
settingFragment.show(supportFragmentManager, TAG)
|
||||
settingDelayHide()
|
||||
}
|
||||
|
||||
private val hideSetting = Runnable {
|
||||
@@ -421,6 +424,11 @@ class MainActivity : FragmentActivity(), Request.RequestListener {
|
||||
}, 2000)
|
||||
}
|
||||
|
||||
private fun active() {
|
||||
if (settingFragment.isVisible) {
|
||||
settingDelayHide()
|
||||
}
|
||||
}
|
||||
|
||||
fun onKey(keyCode: Int): Boolean {
|
||||
Log.i(TAG, "keyCode $keyCode")
|
||||
@@ -511,6 +519,7 @@ class MainActivity : FragmentActivity(), Request.RequestListener {
|
||||
}
|
||||
|
||||
KeyEvent.KEYCODE_ENTER -> {
|
||||
active()
|
||||
switchMainFragment()
|
||||
}
|
||||
|
||||
@@ -519,6 +528,7 @@ class MainActivity : FragmentActivity(), Request.RequestListener {
|
||||
}
|
||||
|
||||
KeyEvent.KEYCODE_DPAD_UP -> {
|
||||
active()
|
||||
channelUp()
|
||||
}
|
||||
|
||||
@@ -527,6 +537,7 @@ class MainActivity : FragmentActivity(), Request.RequestListener {
|
||||
}
|
||||
|
||||
KeyEvent.KEYCODE_DPAD_DOWN -> {
|
||||
active()
|
||||
channelDown()
|
||||
}
|
||||
|
||||
@@ -535,6 +546,7 @@ class MainActivity : FragmentActivity(), Request.RequestListener {
|
||||
}
|
||||
|
||||
KeyEvent.KEYCODE_DPAD_LEFT -> {
|
||||
active()
|
||||
if (mainFragment.isHidden && !settingFragment.isVisible) {
|
||||
switchMainFragment()
|
||||
return true
|
||||
@@ -542,6 +554,7 @@ class MainActivity : FragmentActivity(), Request.RequestListener {
|
||||
}
|
||||
|
||||
KeyEvent.KEYCODE_DPAD_RIGHT -> {
|
||||
active()
|
||||
if (mainFragment.isHidden && !settingFragment.isVisible) {
|
||||
showSetting()
|
||||
return true
|
||||
@@ -570,6 +583,12 @@ class MainActivity : FragmentActivity(), Request.RequestListener {
|
||||
override fun onResume() {
|
||||
Log.i(TAG, "onResume")
|
||||
super.onResume()
|
||||
}
|
||||
|
||||
override fun onResumeFragments() {
|
||||
super.onResumeFragments()
|
||||
mainFragment.changeMenu()
|
||||
|
||||
if (!mainFragment.isHidden) {
|
||||
handler.postDelayed(hideMain, delayHideMain)
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.lizongying.mytv
|
||||
|
||||
import android.content.res.Resources
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.KeyEvent
|
||||
@@ -162,8 +160,10 @@ class MainFragment : Fragment(), CardAdapter.ItemListener {
|
||||
if (tvViewModel.errInfo.value == "") {
|
||||
(activity as? MainActivity)?.showPlayerFragment()
|
||||
(activity as? MainActivity)?.hideErrorFragment()
|
||||
(activity as? MainActivity)?.hideLoadingFragment()
|
||||
} else {
|
||||
(activity as? MainActivity)?.hidePlayerFragment()
|
||||
(activity as? MainActivity)?.hideLoadingFragment()
|
||||
(activity as? MainActivity)?.showErrorFragment(tvViewModel.errInfo.value.toString())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.lizongying.mytv
|
||||
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
@@ -23,6 +24,11 @@ class SettingFragment : DialogFragment() {
|
||||
dialog?.window?.apply {
|
||||
addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)
|
||||
decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
attributes.layoutInDisplayCutoutMode =
|
||||
WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES
|
||||
setAttributes(attributes)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.lizongying.mytv
|
||||
|
||||
import android.content.res.Resources
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.view.LayoutInflater
|
||||
@@ -36,10 +35,18 @@ class TimeFragment : Fragment() {
|
||||
binding.time.layoutParams = layoutParams
|
||||
|
||||
binding.content.textSize = application.px2PxFont(binding.content.textSize)
|
||||
binding.channel.textSize = application.px2PxFont(binding.channel.textSize)
|
||||
|
||||
binding.main.layoutParams.width = application.shouldWidthPx()
|
||||
binding.main.layoutParams.height = application.shouldHeightPx()
|
||||
|
||||
if (SP.time) {
|
||||
handler.removeCallbacks(showRunnable)
|
||||
handler.postDelayed(showRunnable, 0)
|
||||
} else {
|
||||
handler.removeCallbacks(showRunnable)
|
||||
}
|
||||
|
||||
(activity as MainActivity).fragmentReady(TAG)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
@@ -10,22 +11,34 @@
|
||||
android:layout_height="match_parent"
|
||||
>
|
||||
|
||||
<FrameLayout
|
||||
<RelativeLayout
|
||||
android:id="@+id/channel"
|
||||
android:layout_width="90dp"
|
||||
android:layout_height="60dp"
|
||||
android:layout_gravity="end|top"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginEnd="170dp">
|
||||
android:layout_marginTop="15dp"
|
||||
android:layout_marginEnd="170dp"
|
||||
android:gravity="end|bottom" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/content"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:layout_gravity="end|bottom"
|
||||
android:textColor="@color/white"
|
||||
android:textStyle="bold"
|
||||
android:textSize="40sp" />
|
||||
</FrameLayout>
|
||||
android:textSize="40sp"
|
||||
tools:text="99"
|
||||
android:layout_alignBaseline="@+id/time"/>
|
||||
<TextView
|
||||
android:id="@+id/time"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end|bottom"
|
||||
android:textColor="@color/white"
|
||||
android:textStyle="bold"
|
||||
android:textSize="32sp"
|
||||
tools:text="12:34" />
|
||||
</RelativeLayout>
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
@@ -40,7 +40,6 @@
|
||||
android:id="@+id/check_version"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:textSize="14sp"
|
||||
android:text="@string/check_version"
|
||||
/>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
@@ -10,23 +11,35 @@
|
||||
android:layout_height="match_parent"
|
||||
>
|
||||
|
||||
<FrameLayout
|
||||
<RelativeLayout
|
||||
android:id="@+id/time"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_width="120dp"
|
||||
android:layout_height="60dp"
|
||||
android:layout_gravity="end|top"
|
||||
android:layout_marginTop="25dp"
|
||||
android:layout_marginEnd="50dp">
|
||||
android:layout_marginTop="15dp"
|
||||
android:layout_marginEnd="50dp"
|
||||
android:gravity="end|bottom" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/channel"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end|bottom"
|
||||
android:textColor="@color/white"
|
||||
android:textStyle="bold"
|
||||
android:textSize="40sp"
|
||||
tools:text="99"
|
||||
android:layout_alignBaseline="@+id/content"/>
|
||||
<TextView
|
||||
android:id="@+id/content"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:layout_gravity="end|bottom"
|
||||
android:textColor="@color/white"
|
||||
android:textStyle="bold"
|
||||
android:textSize="32sp" />
|
||||
</FrameLayout>
|
||||
android:textSize="32sp"
|
||||
tools:text="12:34" />
|
||||
</RelativeLayout>
|
||||
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
@@ -6,5 +6,5 @@
|
||||
<string name="title_boot_startup">开机自启</string>
|
||||
<string name="title_grid">频道列表采用网格样式</string>
|
||||
<string name="title_time">显示时间</string>
|
||||
<string name="exit">退出</string>
|
||||
<string name="exit">退出应用</string>
|
||||
</resources>
|
||||
Reference in New Issue
Block a user