compatible 16:10
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 25 KiB |
|
|
@ -85,7 +85,6 @@ class MainActivity : FragmentActivity() {
|
||||||
val transaction = supportFragmentManager.beginTransaction()
|
val transaction = supportFragmentManager.beginTransaction()
|
||||||
|
|
||||||
if (mainFragment.isHidden) {
|
if (mainFragment.isHidden) {
|
||||||
// focusMainFragment()
|
|
||||||
transaction.show(mainFragment)
|
transaction.show(mainFragment)
|
||||||
} else {
|
} else {
|
||||||
transaction.hide(mainFragment)
|
transaction.hide(mainFragment)
|
||||||
|
|
@ -94,10 +93,6 @@ class MainActivity : FragmentActivity() {
|
||||||
transaction.commit()
|
transaction.commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun focusMainFragment() {
|
|
||||||
mainFragment.focus()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun mainFragmentIsHidden(): Boolean {
|
private fun mainFragmentIsHidden(): Boolean {
|
||||||
return mainFragment.isHidden
|
return mainFragment.isHidden
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -114,6 +114,10 @@ class MainFragment : BrowseSupportFragment() {
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
handler.removeCallbacks(mUpdateProgramRunnable)
|
handler.removeCallbacks(mUpdateProgramRunnable)
|
||||||
|
with(sharedPref!!.edit()) {
|
||||||
|
putInt("position", itemPosition)
|
||||||
|
apply()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateProgram(tvViewModel: TVViewModel) {
|
fun updateProgram(tvViewModel: TVViewModel) {
|
||||||
|
|
@ -202,7 +206,7 @@ class MainFragment : BrowseSupportFragment() {
|
||||||
itemPosition = sharedPref?.getInt("position", 0)!!
|
itemPosition = sharedPref?.getInt("position", 0)!!
|
||||||
if (itemPosition >= tvListViewModel.size()) {
|
if (itemPosition >= tvListViewModel.size()) {
|
||||||
itemPosition = 0
|
itemPosition = 0
|
||||||
savePosition(0)
|
tvListViewModel.setItemPosition(itemPosition)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -227,21 +231,13 @@ class MainFragment : BrowseSupportFragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun savePosition(position: Int) {
|
|
||||||
tvListViewModel.setItemPosition(position)
|
|
||||||
with(sharedPref!!.edit()) {
|
|
||||||
putInt("position", position)
|
|
||||||
apply()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun prev() {
|
fun prev() {
|
||||||
view?.post {
|
view?.post {
|
||||||
itemPosition--
|
itemPosition--
|
||||||
if (itemPosition == -1) {
|
if (itemPosition == -1) {
|
||||||
itemPosition = tvListViewModel.size() - 1
|
itemPosition = tvListViewModel.size() - 1
|
||||||
}
|
}
|
||||||
savePosition(itemPosition)
|
tvListViewModel.setItemPosition(itemPosition)
|
||||||
|
|
||||||
val tvViewModel = tvListViewModel.getTVViewModel(itemPosition)
|
val tvViewModel = tvListViewModel.getTVViewModel(itemPosition)
|
||||||
tvViewModel?.changed()
|
tvViewModel?.changed()
|
||||||
|
|
@ -254,7 +250,7 @@ class MainFragment : BrowseSupportFragment() {
|
||||||
if (itemPosition == tvListViewModel.size()) {
|
if (itemPosition == tvListViewModel.size()) {
|
||||||
itemPosition = 0
|
itemPosition = 0
|
||||||
}
|
}
|
||||||
savePosition(itemPosition)
|
tvListViewModel.setItemPosition(itemPosition)
|
||||||
|
|
||||||
val tvViewModel = tvListViewModel.getTVViewModel(itemPosition)
|
val tvViewModel = tvListViewModel.getTVViewModel(itemPosition)
|
||||||
tvViewModel?.changed()
|
tvViewModel?.changed()
|
||||||
|
|
@ -310,7 +306,7 @@ class MainFragment : BrowseSupportFragment() {
|
||||||
if (item is TVViewModel) {
|
if (item is TVViewModel) {
|
||||||
if (itemPosition != item.id.value!!) {
|
if (itemPosition != item.id.value!!) {
|
||||||
itemPosition = item.id.value!!
|
itemPosition = item.id.value!!
|
||||||
savePosition(itemPosition)
|
tvListViewModel.setItemPosition(itemPosition)
|
||||||
|
|
||||||
val tvViewModel = tvListViewModel.getTVViewModel(itemPosition)
|
val tvViewModel = tvListViewModel.getTVViewModel(itemPosition)
|
||||||
tvViewModel?.changed()
|
tvViewModel?.changed()
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.lizongying.mytv
|
package com.lizongying.mytv
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
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
|
||||||
|
|
@ -43,11 +44,20 @@ class PlayerFragment : Fragment() {
|
||||||
override fun onVideoSizeChanged(videoSize: VideoSize) {
|
override fun onVideoSizeChanged(videoSize: VideoSize) {
|
||||||
val aspectRatio = 16f / 9f
|
val aspectRatio = 16f / 9f
|
||||||
val layoutParams = playerView?.layoutParams
|
val layoutParams = playerView?.layoutParams
|
||||||
layoutParams?.width =
|
val ratio = playerView?.measuredWidth?.div(playerView?.measuredHeight!!)
|
||||||
(playerView?.measuredHeight?.times(aspectRatio))?.toInt()
|
if (ratio != null) {
|
||||||
playerView?.layoutParams = layoutParams
|
if (ratio < aspectRatio) {
|
||||||
|
layoutParams?.height =
|
||||||
|
(playerView?.measuredWidth?.div(aspectRatio))?.toInt()
|
||||||
|
playerView?.layoutParams = layoutParams
|
||||||
|
} else if (ratio > aspectRatio) {
|
||||||
|
layoutParams?.width =
|
||||||
|
(playerView?.measuredHeight?.times(aspectRatio))?.toInt()
|
||||||
|
playerView?.layoutParams = layoutParams
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//
|
|
||||||
// override fun onPlayerError(error: PlaybackException) {
|
// override fun onPlayerError(error: PlaybackException) {
|
||||||
// super.onPlayerError(error)
|
// super.onPlayerError(error)
|
||||||
// }
|
// }
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,6 @@ class TVListViewModel : ViewModel() {
|
||||||
|
|
||||||
var maxNum = mutableListOf<Int>()
|
var maxNum = mutableListOf<Int>()
|
||||||
|
|
||||||
private var sharedPref: SharedPreferences? = null
|
|
||||||
|
|
||||||
private val tvListViewModel = MutableLiveData<MutableList<TVViewModel>>()
|
private val tvListViewModel = MutableLiveData<MutableList<TVViewModel>>()
|
||||||
|
|
||||||
private val _itemPosition = MutableLiveData<Int>()
|
private val _itemPosition = MutableLiveData<Int>()
|
||||||
|
|
@ -48,13 +46,6 @@ class TVListViewModel : ViewModel() {
|
||||||
_itemPositionCurrent.value = position
|
_itemPositionCurrent.value = position
|
||||||
}
|
}
|
||||||
|
|
||||||
fun savePosition(position: Int) {
|
|
||||||
with(sharedPref!!.edit()) {
|
|
||||||
putInt("position", position)
|
|
||||||
apply()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun size(): Int {
|
fun size(): Int {
|
||||||
return tvListViewModel.value!!.size
|
return tvListViewModel.value!!.size
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<background android:drawable="@color/ic_launcher_background"/>
|
||||||
|
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||||
|
</adaptive-icon>
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<background android:drawable="@color/ic_launcher_background"/>
|
||||||
|
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
|
||||||
|
</adaptive-icon>
|
||||||
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 912 B |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 6.6 KiB |
|
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 4.2 KiB |
|
After Width: | Height: | Size: 4.8 KiB |
|
After Width: | Height: | Size: 9.2 KiB |
|
|
@ -0,0 +1,4 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<color name="ic_launcher_background">#223239</color>
|
||||||
|
</resources>
|
||||||