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)
|
viewModel.setSplitMode(MainViewModel.PAGE_MODE_NINE)
|
||||||
Log.e(TAG, "+++ split style: 9")
|
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
|
//endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -142,5 +142,6 @@ class MainViewModel: ViewModel() {
|
|||||||
const val PAGE_MODE_ONE = 1
|
const val PAGE_MODE_ONE = 1
|
||||||
const val PAGE_MODE_FOUR = 4
|
const val PAGE_MODE_FOUR = 4
|
||||||
const val PAGE_MODE_NINE = 9
|
const val PAGE_MODE_NINE = 9
|
||||||
|
const val PAGE_MODE_SIXTEEN = 16
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -112,6 +112,10 @@ class SplitViewFragment : Fragment() {
|
|||||||
|
|
||||||
// 調整間距
|
// 調整間距
|
||||||
when (splitMode) {
|
when (splitMode) {
|
||||||
|
MainViewModel.PAGE_MODE_ONE -> {
|
||||||
|
width = (baseView.width / maxRow)
|
||||||
|
height = (baseView.height / maxCol)
|
||||||
|
}
|
||||||
MainViewModel.PAGE_MODE_FOUR -> {
|
MainViewModel.PAGE_MODE_FOUR -> {
|
||||||
when (col) {
|
when (col) {
|
||||||
0 -> bottomMargin = 2.dp
|
0 -> bottomMargin = 2.dp
|
||||||
@ -136,9 +140,25 @@ class SplitViewFragment : Fragment() {
|
|||||||
width = (baseView.width / maxRow) - maxRow.dp
|
width = (baseView.width / maxRow) - maxRow.dp
|
||||||
height = (baseView.height / maxCol) - maxCol.dp
|
height = (baseView.height / maxCol) - maxCol.dp
|
||||||
}
|
}
|
||||||
MainViewModel.PAGE_MODE_ONE -> {
|
MainViewModel.PAGE_MODE_SIXTEEN -> {
|
||||||
width = (baseView.width / maxRow)
|
if (col == 1) {
|
||||||
height = (baseView.height / maxCol)
|
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 {
|
videoViews[position].setOnClickListener {
|
||||||
if (position >= data.size) return@setOnClickListener
|
if (position >= data.size) return@setOnClickListener
|
||||||
if (!videoViews[position].isPlaying) {
|
if (!videoViews[position].isPlaying) {
|
||||||
if (!videoViews[position].isLoading) {
|
|
||||||
videoViews[position].resetRetryCount()
|
|
||||||
videoViews[position].play()
|
|
||||||
}
|
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
}
|
}
|
||||||
MainScope().launch {
|
MainScope().launch {
|
||||||
stopAll()
|
stopAll()
|
||||||
//delay(Constants.CONF_DELAY_BASE_MILLIS)
|
|
||||||
delay(splitMode * 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 item = data[position]
|
||||||
val bundle = Bundle().apply {
|
val bundle = Bundle().apply {
|
||||||
//putInt(MonitoringActivity.BUNDLE_DEVICE_ID, item.id)
|
//putInt(MonitoringActivity.BUNDLE_DEVICE_ID, item.id)
|
||||||
@ -187,7 +201,9 @@ class SplitViewFragment : Fragment() {
|
|||||||
private fun setAllUrl() {
|
private fun setAllUrl() {
|
||||||
for (index in data.indices) {
|
for (index in data.indices) {
|
||||||
videoViews[index].setData(data[index])
|
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
|
view.textDeviceName.isVisible = false
|
||||||
isPlaying = false
|
isPlaying = false
|
||||||
isLoading = false
|
isLoading = false
|
||||||
|
|
||||||
|
view.btnRetry.setOnClickListener {
|
||||||
|
it.isVisible = false
|
||||||
|
resetRetryCount()
|
||||||
|
play()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setData(device: Device?, streamType: Int = SUB_STREAM) {
|
fun setData(device: Device?, streamType: Int = SUB_STREAM) {
|
||||||
@ -181,8 +187,10 @@ class VideoView : ConstraintLayout, GstCallback {
|
|||||||
mHandler.post(retryRunnable)
|
mHandler.post(retryRunnable)
|
||||||
retryCount++
|
retryCount++
|
||||||
isLoading = true
|
isLoading = true
|
||||||
|
view.btnRetry.isVisible = false
|
||||||
} else {
|
} else {
|
||||||
stopRetryCount()
|
stopRetryCount()
|
||||||
|
view.btnRetry.isVisible = true
|
||||||
isLoading = false
|
isLoading = false
|
||||||
Log.e("${TAG}_$tag", "Retry count = 5, stopped retry...")
|
Log.e("${TAG}_$tag", "Retry count = 5, stopped retry...")
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user