mirror of
https://github.com/lizongying/my-tv.git
synced 2026-10-26 22:26:29 +08:00
17ok
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -1,6 +1,7 @@
|
|||||||
package com.lizongying.mytv
|
package com.lizongying.mytv
|
||||||
|
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
|
import android.util.Log
|
||||||
import android.view.ContextThemeWrapper
|
import android.view.ContextThemeWrapper
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ class MainActivity : FragmentActivity() {
|
|||||||
.add(R.id.main_browse_fragment, infoFragment)
|
.add(R.id.main_browse_fragment, infoFragment)
|
||||||
.add(R.id.main_browse_fragment, mainFragment)
|
.add(R.id.main_browse_fragment, mainFragment)
|
||||||
.hide(infoFragment)
|
.hide(infoFragment)
|
||||||
|
.hide(mainFragment)
|
||||||
.commit()
|
.commit()
|
||||||
mainFragment.view?.requestFocus()
|
mainFragment.view?.requestFocus()
|
||||||
}
|
}
|
||||||
@@ -171,105 +172,132 @@ class MainActivity : FragmentActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
|
private fun showHelp() {
|
||||||
when (keyCode) {
|
val versionName = getPackageInfo().versionName
|
||||||
KeyEvent.KEYCODE_BACK -> {
|
|
||||||
if (!mainFragmentIsHidden()) {
|
|
||||||
hideMainFragment()
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
if (doubleBackToExitPressedOnce) {
|
val textView = TextView(this)
|
||||||
super.onBackPressed()
|
textView.text =
|
||||||
return true
|
"当前版本: $versionName\n获取最新: https://github.com/lizongying/my-tv/releases/"
|
||||||
}
|
textView.setBackgroundColor(0xFF263238.toInt())
|
||||||
|
textView.setPadding(20, 50, 20, 20)
|
||||||
|
|
||||||
this.doubleBackToExitPressedOnce = true
|
val imageView = ImageView(this)
|
||||||
Toast.makeText(this, "再按一次退出", Toast.LENGTH_SHORT).show()
|
val drawable = ContextCompat.getDrawable(this, R.drawable.appreciate)
|
||||||
|
imageView.setImageDrawable(drawable)
|
||||||
|
imageView.setBackgroundColor(Color.WHITE)
|
||||||
|
|
||||||
Handler(Looper.getMainLooper()).postDelayed({
|
val linearLayout = LinearLayout(this)
|
||||||
doubleBackToExitPressedOnce = false
|
linearLayout.orientation = LinearLayout.VERTICAL
|
||||||
}, 2000)
|
linearLayout.addView(textView)
|
||||||
return true
|
linearLayout.addView(imageView)
|
||||||
}
|
|
||||||
|
|
||||||
KeyEvent.KEYCODE_SETTINGS -> {
|
val layoutParams = LinearLayout.LayoutParams(
|
||||||
Toast.makeText(this, "KEYCODE_SETTINGS", Toast.LENGTH_SHORT).show()
|
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||||
}
|
LinearLayout.LayoutParams.WRAP_CONTENT
|
||||||
KeyEvent.KEYCODE_MENU -> {
|
)
|
||||||
Toast.makeText(this, "KEYCODE_MENU", Toast.LENGTH_SHORT).show()
|
imageView.layoutParams = layoutParams
|
||||||
val versionName = getPackageInfo().versionName
|
textView.layoutParams = layoutParams
|
||||||
|
|
||||||
val textView = TextView(this)
|
val builder: AlertDialog.Builder = AlertDialog.Builder(this)
|
||||||
textView.text =
|
builder
|
||||||
"当前版本: $versionName\n获取最新: https://github.com/lizongying/my-tv/releases/"
|
.setView(linearLayout)
|
||||||
textView.setBackgroundColor(0xFF263238.toInt())
|
|
||||||
textView.setPadding(20, 50, 20, 20)
|
|
||||||
|
|
||||||
|
val dialog: AlertDialog = builder.create()
|
||||||
|
dialog.show()
|
||||||
|
}
|
||||||
|
|
||||||
val imageView = ImageView(this)
|
private fun channelUp() {
|
||||||
val drawable = ContextCompat.getDrawable(this, R.drawable.appreciate)
|
if (mainFragment.isHidden) {
|
||||||
imageView.setImageDrawable(drawable)
|
prev()
|
||||||
imageView.setBackgroundColor(Color.WHITE)
|
} else {
|
||||||
|
|
||||||
val linearLayout = LinearLayout(this)
|
|
||||||
linearLayout.orientation = LinearLayout.VERTICAL
|
|
||||||
linearLayout.addView(textView)
|
|
||||||
linearLayout.addView(imageView)
|
|
||||||
|
|
||||||
val layoutParams = LinearLayout.LayoutParams(
|
|
||||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
|
||||||
LinearLayout.LayoutParams.WRAP_CONTENT,
|
|
||||||
)
|
|
||||||
textView.layoutParams = layoutParams
|
|
||||||
val layoutParams2 = LinearLayout.LayoutParams(
|
|
||||||
LinearLayout.LayoutParams.MATCH_PARENT,
|
|
||||||
LinearLayout.LayoutParams.WRAP_CONTENT
|
|
||||||
)
|
|
||||||
imageView.layoutParams = layoutParams2
|
|
||||||
|
|
||||||
val builder: AlertDialog.Builder = AlertDialog.Builder(this)
|
|
||||||
builder
|
|
||||||
.setView(linearLayout)
|
|
||||||
|
|
||||||
val dialog: AlertDialog = builder.create()
|
|
||||||
dialog.show()
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
KeyEvent.KEYCODE_ENTER -> {
|
|
||||||
Toast.makeText(this, "KEYCODE_ENTER", Toast.LENGTH_SHORT).show()
|
|
||||||
switchMainFragment()
|
|
||||||
}
|
|
||||||
|
|
||||||
KeyEvent.KEYCODE_DPAD_CENTER -> {
|
|
||||||
Toast.makeText(this, "KEYCODE_DPAD_CENTER", Toast.LENGTH_SHORT).show()
|
|
||||||
switchMainFragment()
|
|
||||||
}
|
|
||||||
|
|
||||||
KeyEvent.KEYCODE_DPAD_UP -> {
|
|
||||||
if (mainFragment.isHidden) {
|
|
||||||
prev()
|
|
||||||
} else {
|
|
||||||
// if (mainFragment.selectedPosition == 0) {
|
// if (mainFragment.selectedPosition == 0) {
|
||||||
// mainFragment.setSelectedPosition(
|
// mainFragment.setSelectedPosition(
|
||||||
// mainFragment.tvListViewModel.maxNum.size - 1,
|
// mainFragment.tvListViewModel.maxNum.size - 1,
|
||||||
// false
|
// false
|
||||||
// )
|
// )
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyEvent.KEYCODE_DPAD_DOWN -> {
|
private fun channelDown() {
|
||||||
if (mainFragment.isHidden) {
|
if (mainFragment.isHidden) {
|
||||||
next()
|
next()
|
||||||
} else {
|
} else {
|
||||||
// if (mainFragment.selectedPosition == mainFragment.tvListViewModel.maxNum.size - 1) {
|
// if (mainFragment.selectedPosition == mainFragment.tvListViewModel.maxNum.size - 1) {
|
||||||
//// mainFragment.setSelectedPosition(0, false)
|
//// mainFragment.setSelectedPosition(0, false)
|
||||||
// hideMainFragment()
|
// hideMainFragment()
|
||||||
// return false
|
// return false
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun back() {
|
||||||
|
if (!mainFragmentIsHidden()) {
|
||||||
|
hideMainFragment()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (doubleBackToExitPressedOnce) {
|
||||||
|
super.onBackPressed()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
doubleBackToExitPressedOnce = true
|
||||||
|
Toast.makeText(this, "再按一次退出", Toast.LENGTH_SHORT).show()
|
||||||
|
|
||||||
|
Handler(Looper.getMainLooper()).postDelayed({
|
||||||
|
doubleBackToExitPressedOnce = false
|
||||||
|
}, 2000)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
|
||||||
|
// Toast.makeText(this, "keyCode ${keyCodeToString(keyCode)}", Toast.LENGTH_SHORT).show()
|
||||||
|
when (keyCode) {
|
||||||
|
KeyEvent.KEYCODE_ESCAPE -> {
|
||||||
|
back()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
KeyEvent.KEYCODE_BACK -> {
|
||||||
|
back()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
KeyEvent.KEYCODE_UNKNOWN -> {
|
||||||
|
showHelp()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
KeyEvent.KEYCODE_HELP -> {
|
||||||
|
showHelp()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
KeyEvent.KEYCODE_SETTINGS -> {
|
||||||
|
showHelp()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
KeyEvent.KEYCODE_MENU -> {
|
||||||
|
showHelp()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
KeyEvent.KEYCODE_ENTER -> {
|
||||||
|
switchMainFragment()
|
||||||
|
}
|
||||||
|
KeyEvent.KEYCODE_DPAD_CENTER -> {
|
||||||
|
switchMainFragment()
|
||||||
|
}
|
||||||
|
|
||||||
|
KeyEvent.KEYCODE_DPAD_UP -> {
|
||||||
|
channelUp()
|
||||||
|
}
|
||||||
|
KeyEvent.KEYCODE_CHANNEL_UP -> {
|
||||||
|
channelUp()
|
||||||
|
}
|
||||||
|
|
||||||
|
KeyEvent.KEYCODE_DPAD_DOWN -> {
|
||||||
|
channelDown()
|
||||||
|
}
|
||||||
|
KeyEvent.KEYCODE_CHANNEL_DOWN -> {
|
||||||
|
channelDown()
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyEvent.KEYCODE_DPAD_LEFT -> {
|
KeyEvent.KEYCODE_DPAD_LEFT -> {
|
||||||
|
|||||||
@@ -164,6 +164,11 @@ class MainFragment2 : Fragment(), CardAdapter.ItemListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onItemClicked(tvViewModel: TVViewModel) {
|
override fun onItemClicked(tvViewModel: TVViewModel) {
|
||||||
|
if (this.isHidden) {
|
||||||
|
(activity as? MainActivity)?.switchMainFragment()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (itemPosition != tvViewModel.id.value!!) {
|
if (itemPosition != tvViewModel.id.value!!) {
|
||||||
itemPosition = tvViewModel.id.value!!
|
itemPosition = tvViewModel.id.value!!
|
||||||
tvListViewModel.setItemPosition(itemPosition)
|
tvListViewModel.setItemPosition(itemPosition)
|
||||||
@@ -211,7 +216,6 @@ class MainFragment2 : Fragment(), CardAdapter.ItemListener {
|
|||||||
if (ready == 3) {
|
if (ready == 3) {
|
||||||
// request.fetchPage()
|
// request.fetchPage()
|
||||||
tvListViewModel.getTVViewModel(itemPosition)?.changed()
|
tvListViewModel.getTVViewModel(itemPosition)?.changed()
|
||||||
(activity as? MainActivity)?.switchMainFragment()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -98,9 +98,7 @@ class Request {
|
|||||||
val title = tvModel.title.value
|
val title = tvModel.title.value
|
||||||
|
|
||||||
tvModel.seq = 0
|
tvModel.seq = 0
|
||||||
Log.i(TAG, "test1")
|
|
||||||
val data = ysp?.switch(tvModel)
|
val data = ysp?.switch(tvModel)
|
||||||
Log.i(TAG, "test2")
|
|
||||||
val request = data?.let { LiveInfoRequest(it) }
|
val request = data?.let { LiveInfoRequest(it) }
|
||||||
call = request?.let { yspApiService.getLiveInfo("guid=${ysp?.getGuid()}; $cookie", it) }
|
call = request?.let { yspApiService.getLiveInfo("guid=${ysp?.getGuid()}; $cookie", it) }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user