mirror of
https://github.com/lizongying/my-tv.git
synced 2026-10-26 22:26:29 +08:00
keep screen on
This commit is contained in:
@@ -11,7 +11,7 @@ class Encryptor {
|
||||
|
||||
companion object {
|
||||
init {
|
||||
System.loadLibrary("native-lib")
|
||||
System.loadLibrary("native")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.util.Log
|
||||
import android.view.KeyEvent
|
||||
import android.view.WindowManager
|
||||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
@@ -32,6 +33,8 @@ class MainActivity : FragmentActivity() {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_main)
|
||||
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
|
||||
if (savedInstanceState == null) {
|
||||
supportFragmentManager.beginTransaction()
|
||||
.add(R.id.main_browse_fragment, playbackFragment)
|
||||
|
||||
@@ -36,6 +36,16 @@ class MainFragment : BrowseSupportFragment() {
|
||||
|
||||
private var sharedPref: SharedPreferences? = null
|
||||
|
||||
// override fun onCreateView(
|
||||
// inflater: LayoutInflater,
|
||||
// container: ViewGroup?,
|
||||
// savedInstanceState: Bundle?
|
||||
// ): View? {
|
||||
// super.onCreate()
|
||||
// // 使用自定义的布局文件
|
||||
// return inflater.inflate(R.layout.custom_browse_fragment, container, false)
|
||||
// }
|
||||
|
||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||
super.onActivityCreated(savedInstanceState)
|
||||
|
||||
@@ -66,7 +76,6 @@ class MainFragment : BrowseSupportFragment() {
|
||||
|
||||
private fun setupUIElements() {
|
||||
brandColor = ContextCompat.getColor(context!!, R.color.fastlane_background)
|
||||
// headersState = HEADERS_DISABLED
|
||||
}
|
||||
|
||||
private fun updateRows(tv: TV) {
|
||||
@@ -111,17 +120,29 @@ class MainFragment : BrowseSupportFragment() {
|
||||
adapter = rowsAdapter
|
||||
|
||||
itemPosition = sharedPref?.getInt("position", 0)!!
|
||||
if (itemPosition >= tvListViewModel.size()) {
|
||||
itemPosition = 0
|
||||
savePosition(0)
|
||||
}
|
||||
|
||||
val tv = list2[itemPosition].item
|
||||
|
||||
val tvModel = tvListViewModel.getTVModel(itemPosition)
|
||||
if (tvModel?.ysp() != null) {
|
||||
Log.i(TAG, "ysp ${tvModel.getTV()}")
|
||||
lifecycleScope.launch(Dispatchers.IO) {
|
||||
tvModel.let { request?.fetchData(it) }
|
||||
}
|
||||
} else {
|
||||
(activity as? MainActivity)?.play(list2[itemPosition].item)
|
||||
// (activity as? MainActivity)?.switchInfoFragment(list2[itemPosition].item)
|
||||
(activity as? MainActivity)?.play(tv)
|
||||
// (activity as? MainActivity)?.switchInfoFragment(tv)
|
||||
}
|
||||
|
||||
Toast.makeText(
|
||||
activity,
|
||||
tv.title,
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
(activity as? MainActivity)?.switchMainFragment()
|
||||
}
|
||||
|
||||
|
||||
@@ -89,6 +89,7 @@ class Request(var context: Context) {
|
||||
override fun onResponse(call: Call<LiveInfo>, response: Response<LiveInfo>) {
|
||||
if (response.isSuccessful) {
|
||||
val liveInfo = response.body()
|
||||
Log.i(TAG, "liveInfo $liveInfo")
|
||||
if (liveInfo?.data?.playurl != null) {
|
||||
val chanll = liveInfo.data.chanll
|
||||
val decodedBytes = Base64.decode(
|
||||
@@ -117,6 +118,7 @@ class Request(var context: Context) {
|
||||
}
|
||||
|
||||
override fun onFailure(call: Call<LiveInfo>, t: Throwable) {
|
||||
Log.i(TAG, "get data error")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.lizongying.mytv.models
|
||||
|
||||
import android.util.Log
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import com.lizongying.mytv.TV
|
||||
@@ -41,4 +40,8 @@ class TVListViewModel : ViewModel() {
|
||||
fun getTVModel(id: Int): TVViewModel? {
|
||||
return tvModelListLiveData.value?.get(id)
|
||||
}
|
||||
|
||||
fun size(): Int {
|
||||
return tvListLiveData.value!!.size
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user