mirror of
https://github.com/lizongying/my-tv.git
synced 2026-10-26 22:26:29 +08:00
show current version
This commit is contained in:
@@ -21,8 +21,6 @@ import kotlinx.coroutines.withContext
|
||||
class CardPresenter(private val lifecycleScope: LifecycleCoroutineScope) : Presenter() {
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup): ViewHolder {
|
||||
Log.d(TAG, "onCreateViewHolder")
|
||||
|
||||
val cardView = object :
|
||||
ImageCardView(ContextThemeWrapper(parent.context, R.style.CustomImageCardTheme)) {
|
||||
override fun setSelected(selected: Boolean) {
|
||||
@@ -40,7 +38,6 @@ class CardPresenter(private val lifecycleScope: LifecycleCoroutineScope) : Prese
|
||||
val tv = item as TV
|
||||
val cardView = viewHolder.view as ImageCardView
|
||||
|
||||
Log.d(TAG, "onBindViewHolder")
|
||||
if (tv.videoUrl != null) {
|
||||
cardView.titleText = tv.title
|
||||
cardView.setMainImageDimensions(CARD_WIDTH, CARD_HEIGHT)
|
||||
@@ -57,7 +54,6 @@ class CardPresenter(private val lifecycleScope: LifecycleCoroutineScope) : Prese
|
||||
}
|
||||
|
||||
override fun onUnbindViewHolder(viewHolder: ViewHolder) {
|
||||
Log.d(TAG, "onUnbindViewHolder")
|
||||
val cardView = viewHolder.view as ImageCardView
|
||||
// Remove references to images so that the garbage collector can free up memory
|
||||
cardView.badgeImage = null
|
||||
|
||||
@@ -13,6 +13,7 @@ import android.widget.Toast
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
|
||||
|
||||
/**
|
||||
* Loads [MainFragment].
|
||||
*/
|
||||
@@ -64,7 +65,7 @@ class MainActivity : FragmentActivity() {
|
||||
mainFragment.focus()
|
||||
}
|
||||
|
||||
fun fragmentIsHidden(): Boolean {
|
||||
fun mainFragmentIsHidden(): Boolean {
|
||||
return mainFragment.isHidden
|
||||
}
|
||||
|
||||
@@ -79,12 +80,16 @@ class MainActivity : FragmentActivity() {
|
||||
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
|
||||
when (keyCode) {
|
||||
KeyEvent.KEYCODE_BACK -> {
|
||||
if (!mainFragmentIsHidden()) {
|
||||
hideMainFragment()
|
||||
return true
|
||||
}
|
||||
|
||||
if (doubleBackToExitPressedOnce) {
|
||||
super.onBackPressed()
|
||||
return true
|
||||
}
|
||||
|
||||
hideMainFragment()
|
||||
this.doubleBackToExitPressedOnce = true
|
||||
Toast.makeText(this, "再按一次退出", Toast.LENGTH_SHORT).show()
|
||||
|
||||
@@ -112,9 +117,14 @@ class MainActivity : FragmentActivity() {
|
||||
layoutParams.gravity = Gravity.BOTTOM
|
||||
imageView.layoutParams = layoutParams
|
||||
|
||||
|
||||
val packageInfo = packageManager.getPackageInfo(packageName, 0)
|
||||
|
||||
val versionName = packageInfo.versionName
|
||||
|
||||
val builder: AlertDialog.Builder = AlertDialog.Builder(this)
|
||||
builder
|
||||
.setTitle("https://github.com/lizongying/my-tv/releases")
|
||||
.setTitle("当前版本: $versionName, 获取最新: https://github.com/lizongying/my-tv/releases/")
|
||||
.setView(linearLayout)
|
||||
|
||||
val dialog: AlertDialog = builder.create()
|
||||
|
||||
@@ -150,7 +150,6 @@ class MainFragment : BrowseSupportFragment() {
|
||||
) {
|
||||
if (item is TV) {
|
||||
Log.i(TAG, "Item: ${item.id}")
|
||||
|
||||
}
|
||||
if (itemViewHolder == null) {
|
||||
view?.post {
|
||||
|
||||
@@ -20,30 +20,31 @@ class PlaybackControlGlue(
|
||||
}
|
||||
|
||||
KeyEvent.KEYCODE_DPAD_UP -> {
|
||||
if ((context as? MainActivity)?.fragmentIsHidden() == true) {
|
||||
if ((context as? MainActivity)?.mainFragmentIsHidden() == true) {
|
||||
(context as? MainActivity)?.prev()
|
||||
}
|
||||
}
|
||||
|
||||
KeyEvent.KEYCODE_DPAD_DOWN -> {
|
||||
if ((context as? MainActivity)?.fragmentIsHidden() == true) {
|
||||
if ((context as? MainActivity)?.mainFragmentIsHidden() == true) {
|
||||
(context as? MainActivity)?.next()
|
||||
}
|
||||
}
|
||||
|
||||
KeyEvent.KEYCODE_DPAD_LEFT -> {
|
||||
if ((context as? MainActivity)?.fragmentIsHidden() == true) {
|
||||
if ((context as? MainActivity)?.mainFragmentIsHidden() == true) {
|
||||
(context as? MainActivity)?.prev()
|
||||
}
|
||||
}
|
||||
|
||||
KeyEvent.KEYCODE_DPAD_RIGHT -> {
|
||||
if ((context as? MainActivity)?.fragmentIsHidden() == true) {
|
||||
if ((context as? MainActivity)?.mainFragmentIsHidden() == true) {
|
||||
(context as? MainActivity)?.next()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return super.onKey(v, keyCode, event)
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,6 @@ class PlaybackFragment : VideoSupportFragment() {
|
||||
try {
|
||||
playerAdapter?.setDataSource(Uri.parse(tv.videoUrl))
|
||||
} catch (e: IOException) {
|
||||
// Handle the exception
|
||||
return
|
||||
}
|
||||
hideControlsOverlay(false)
|
||||
|
||||
Reference in New Issue
Block a user