1.將重試功能改成VideoView內部呼叫
2.加上16分割
This commit is contained in:
parent
f7aa9f74d2
commit
6378f4d80f
@ -92,6 +92,12 @@ class MainActivity : AppCompatActivity() {
|
||||
viewModel.setSplitMode(MainViewModel.PAGE_MODE_NINE)
|
||||
Log.e(TAG, "+++ split style: 9")
|
||||
}
|
||||
|
||||
button4.setOnClickListener {
|
||||
if (splitMode == MainViewModel.PAGE_MODE_SIXTEEN) return@setOnClickListener
|
||||
viewModel.setSplitMode(MainViewModel.PAGE_MODE_SIXTEEN)
|
||||
Log.e(TAG, "+++ split style: 9")
|
||||
}
|
||||
//endregion
|
||||
}
|
||||
|
||||
|
||||
@ -142,5 +142,6 @@ class MainViewModel: ViewModel() {
|
||||
const val PAGE_MODE_ONE = 1
|
||||
const val PAGE_MODE_FOUR = 4
|
||||
const val PAGE_MODE_NINE = 9
|
||||
const val PAGE_MODE_SIXTEEN = 16
|
||||
}
|
||||
}
|
||||
@ -112,6 +112,10 @@ class SplitViewFragment : Fragment() {
|
||||
|
||||
// 調整間距
|
||||
when (splitMode) {
|
||||
MainViewModel.PAGE_MODE_ONE -> {
|
||||
width = (baseView.width / maxRow)
|
||||
height = (baseView.height / maxCol)
|
||||
}
|
||||
MainViewModel.PAGE_MODE_FOUR -> {
|
||||
when (col) {
|
||||
0 -> bottomMargin = 2.dp
|
||||
@ -136,9 +140,25 @@ class SplitViewFragment : Fragment() {
|
||||
width = (baseView.width / maxRow) - maxRow.dp
|
||||
height = (baseView.height / maxCol) - maxCol.dp
|
||||
}
|
||||
MainViewModel.PAGE_MODE_ONE -> {
|
||||
width = (baseView.width / maxRow)
|
||||
height = (baseView.height / maxCol)
|
||||
MainViewModel.PAGE_MODE_SIXTEEN -> {
|
||||
if (col == 1) {
|
||||
topMargin = 4.dp
|
||||
bottomMargin = 2.dp
|
||||
}
|
||||
if (col == 2) {
|
||||
topMargin = 2.dp
|
||||
bottomMargin = 4.dp
|
||||
}
|
||||
if (row == 1) {
|
||||
marginStart = 4.dp
|
||||
marginEnd = 2.dp
|
||||
}
|
||||
if (row == 2) {
|
||||
marginStart = 2.dp
|
||||
marginEnd = 4.dp
|
||||
}
|
||||
width = (baseView.width / maxRow) - maxRow.dp
|
||||
height = (baseView.height / maxCol) - maxCol.dp
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -154,17 +174,11 @@ class SplitViewFragment : Fragment() {
|
||||
videoViews[position].setOnClickListener {
|
||||
if (position >= data.size) return@setOnClickListener
|
||||
if (!videoViews[position].isPlaying) {
|
||||
if (!videoViews[position].isLoading) {
|
||||
videoViews[position].resetRetryCount()
|
||||
videoViews[position].play()
|
||||
}
|
||||
return@setOnClickListener
|
||||
}
|
||||
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]
|
||||
val bundle = Bundle().apply {
|
||||
//putInt(MonitoringActivity.BUNDLE_DEVICE_ID, item.id)
|
||||
@ -187,7 +201,9 @@ class SplitViewFragment : Fragment() {
|
||||
private fun setAllUrl() {
|
||||
for (index in data.indices) {
|
||||
videoViews[index].setData(data[index])
|
||||
videoViews[index].setTextVisible((splitMode != MainViewModel.PAGE_MODE_NINE))
|
||||
videoViews[index].setTextVisible(
|
||||
(splitMode != MainViewModel.PAGE_MODE_NINE && splitMode != MainViewModel.PAGE_MODE_SIXTEEN)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -84,6 +84,12 @@ class VideoView : ConstraintLayout, GstCallback {
|
||||
view.textDeviceName.isVisible = false
|
||||
isPlaying = false
|
||||
isLoading = false
|
||||
|
||||
view.btnRetry.setOnClickListener {
|
||||
it.isVisible = false
|
||||
resetRetryCount()
|
||||
play()
|
||||
}
|
||||
}
|
||||
|
||||
fun setData(device: Device?, streamType: Int = SUB_STREAM) {
|
||||
@ -181,8 +187,10 @@ class VideoView : ConstraintLayout, GstCallback {
|
||||
mHandler.post(retryRunnable)
|
||||
retryCount++
|
||||
isLoading = true
|
||||
view.btnRetry.isVisible = false
|
||||
} else {
|
||||
stopRetryCount()
|
||||
view.btnRetry.isVisible = true
|
||||
isLoading = false
|
||||
Log.e("${TAG}_$tag", "Retry count = 5, stopped retry...")
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user