VideoViewAdapter.kt加上對所有的SplitViewFragment.kt下指令的功能
This commit is contained in:
parent
0ffafcbaf7
commit
f7aa9f74d2
@ -53,9 +53,7 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
for (i in 0 until splitVideoViewAdapter.itemCount) {
|
||||
splitVideoViewAdapter.destroy(i)
|
||||
}
|
||||
splitVideoViewAdapter.destroy()
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
@ -113,8 +111,8 @@ class MainActivity : AppCompatActivity() {
|
||||
private fun reloadVideoViews(list: List<List<Device>>?) = MainScope().launch {
|
||||
binding.viewPager.setCurrentItem(0, false)
|
||||
for (i in 0 until splitVideoViewAdapter.itemCount) {
|
||||
splitVideoViewAdapter.pause(i)
|
||||
splitVideoViewAdapter.destroy(i)
|
||||
splitVideoViewAdapter.pause()
|
||||
splitVideoViewAdapter.destroy()
|
||||
}
|
||||
//delay(oldSplitMode * Constants.CONF_DELAY_BASE_MILLIS)
|
||||
delay((oldSplitMode * 100) + Constants.CONF_DELAY_BASE_MILLIS)
|
||||
|
||||
@ -162,6 +162,7 @@ class SplitViewFragment : Fragment() {
|
||||
}
|
||||
MainScope().launch {
|
||||
stopAll()
|
||||
//delay(Constants.CONF_DELAY_BASE_MILLIS)
|
||||
delay(splitMode * Constants.CONF_DELAY_BASE_MILLIS)
|
||||
//delay((splitMode * 100) + Constants.CONF_DELAY_BASE_MILLIS)
|
||||
val item = data[position]
|
||||
@ -211,13 +212,13 @@ class SplitViewFragment : Fragment() {
|
||||
}
|
||||
}.start()
|
||||
|
||||
fun destroyAll() /*= MainScope().launch(Dispatchers.Main)*/ {
|
||||
if (videoViews.isEmpty()) return
|
||||
fun destroyAll() = MainScope().launch(Dispatchers.Main) {
|
||||
if (videoViews.isEmpty()) return@launch
|
||||
for (index in data.indices) {
|
||||
//videoViews[index].destroy()
|
||||
videoViews[index].destroySurface()
|
||||
}
|
||||
}//.start()
|
||||
}.start()
|
||||
|
||||
companion object {
|
||||
private val TAG = SplitViewFragment::class.java.simpleName
|
||||
|
||||
@ -41,6 +41,12 @@ class VideoViewAdapter(
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
fun pause() {
|
||||
for (i in fragments.indices) {
|
||||
pause(i)
|
||||
}
|
||||
}
|
||||
|
||||
fun pause(index: Int) {
|
||||
pause(fragments[index])
|
||||
}
|
||||
@ -57,6 +63,12 @@ class VideoViewAdapter(
|
||||
fragment.playAll()
|
||||
}
|
||||
|
||||
fun destroy() {
|
||||
for (i in fragments.indices) {
|
||||
destroy(i)
|
||||
}
|
||||
}
|
||||
|
||||
fun destroy(index: Int) {
|
||||
destroy(fragments[index])
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user