fix dialog
This commit is contained in:
parent
21d5eabea7
commit
7b6a7a96a1
|
|
@ -5,7 +5,6 @@ import android.media.MediaMetadataRetriever
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.ContextThemeWrapper
|
import android.view.ContextThemeWrapper
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.core.content.ContextCompat
|
|
||||||
import androidx.leanback.widget.ImageCardView
|
import androidx.leanback.widget.ImageCardView
|
||||||
import androidx.leanback.widget.Presenter
|
import androidx.leanback.widget.Presenter
|
||||||
import androidx.lifecycle.LifecycleCoroutineScope
|
import androidx.lifecycle.LifecycleCoroutineScope
|
||||||
|
|
@ -13,7 +12,6 @@ import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import kotlin.properties.Delegates
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -28,7 +26,7 @@ class CardPresenter(private val lifecycleScope: LifecycleCoroutineScope) : Prese
|
||||||
val cardView = object :
|
val cardView = object :
|
||||||
ImageCardView(ContextThemeWrapper(parent.context, R.style.CustomImageCardTheme)) {
|
ImageCardView(ContextThemeWrapper(parent.context, R.style.CustomImageCardTheme)) {
|
||||||
override fun setSelected(selected: Boolean) {
|
override fun setSelected(selected: Boolean) {
|
||||||
// updateCardBackgroundColor(this)
|
updateCardBackgroundColor(this)
|
||||||
super.setSelected(selected)
|
super.setSelected(selected)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,11 @@ import android.app.AlertDialog
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
import android.util.Log
|
import android.view.Gravity
|
||||||
import android.view.KeyEvent
|
import android.view.KeyEvent
|
||||||
|
import android.view.ViewGroup
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
|
import android.widget.LinearLayout
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.fragment.app.FragmentActivity
|
import androidx.fragment.app.FragmentActivity
|
||||||
|
|
@ -19,9 +21,6 @@ class MainActivity : FragmentActivity() {
|
||||||
private val playbackFragment = PlaybackFragment()
|
private val playbackFragment = PlaybackFragment()
|
||||||
private val mainFragment = MainFragment()
|
private val mainFragment = MainFragment()
|
||||||
|
|
||||||
private val handler = Handler(Looper.getMainLooper())
|
|
||||||
private var hideTask: Runnable? = null
|
|
||||||
|
|
||||||
private var doubleBackToExitPressedOnce = false
|
private var doubleBackToExitPressedOnce = false
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
|
@ -33,11 +32,6 @@ class MainActivity : FragmentActivity() {
|
||||||
.add(R.id.main_browse_fragment, playbackFragment)
|
.add(R.id.main_browse_fragment, playbackFragment)
|
||||||
.add(R.id.main_browse_fragment, mainFragment)
|
.add(R.id.main_browse_fragment, mainFragment)
|
||||||
.commit()
|
.commit()
|
||||||
|
|
||||||
hideTask = Runnable {
|
|
||||||
Log.i(TAG, "hideTask")
|
|
||||||
hideMainFragment()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -46,12 +40,10 @@ class MainActivity : FragmentActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun prev() {
|
fun prev() {
|
||||||
Log.i(TAG, "prev")
|
|
||||||
mainFragment.prev()
|
mainFragment.prev()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun next() {
|
fun next() {
|
||||||
Log.i(TAG, "next")
|
|
||||||
mainFragment.next()
|
mainFragment.next()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -84,19 +76,6 @@ class MainActivity : FragmentActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun startHideTask(delayMillis: Long) {
|
|
||||||
hideTask?.let { handler.postDelayed(it, delayMillis) }
|
|
||||||
}
|
|
||||||
|
|
||||||
fun cancelHideTask() {
|
|
||||||
hideTask?.let { handler.removeCallbacks(it) }
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onDestroy() {
|
|
||||||
cancelHideTask()
|
|
||||||
super.onDestroy()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
|
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
|
||||||
when (keyCode) {
|
when (keyCode) {
|
||||||
KeyEvent.KEYCODE_BACK -> {
|
KeyEvent.KEYCODE_BACK -> {
|
||||||
|
|
@ -120,10 +99,23 @@ class MainActivity : FragmentActivity() {
|
||||||
val drawable = ContextCompat.getDrawable(this, R.drawable.appreciate)
|
val drawable = ContextCompat.getDrawable(this, R.drawable.appreciate)
|
||||||
imageView.setImageDrawable(drawable)
|
imageView.setImageDrawable(drawable)
|
||||||
|
|
||||||
|
val parent = imageView.parent as? ViewGroup
|
||||||
|
parent?.removeView(imageView)
|
||||||
|
|
||||||
|
val linearLayout = LinearLayout(this)
|
||||||
|
linearLayout.addView(imageView)
|
||||||
|
|
||||||
|
val layoutParams = LinearLayout.LayoutParams(
|
||||||
|
LinearLayout.LayoutParams.MATCH_PARENT,
|
||||||
|
LinearLayout.LayoutParams.WRAP_CONTENT
|
||||||
|
)
|
||||||
|
layoutParams.gravity = Gravity.BOTTOM
|
||||||
|
imageView.layoutParams = layoutParams
|
||||||
|
|
||||||
val builder: AlertDialog.Builder = AlertDialog.Builder(this)
|
val builder: AlertDialog.Builder = AlertDialog.Builder(this)
|
||||||
builder
|
builder
|
||||||
.setMessage("地址: https://github.com/lizongying/my-tv/")
|
.setTitle("https://github.com/lizongying/my-tv/")
|
||||||
.setView(imageView)
|
.setView(linearLayout)
|
||||||
|
|
||||||
val dialog: AlertDialog = builder.create()
|
val dialog: AlertDialog = builder.create()
|
||||||
dialog.show()
|
dialog.show()
|
||||||
|
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 16 KiB |
Loading…
Reference in New Issue