Seeing if the performance improves when the factory becomes just another lambda
This commit is contained in:
@@ -669,43 +669,6 @@ private fun RenderVideoPlayer(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val factory =
|
|
||||||
remember(controller) {
|
|
||||||
{ context: Context ->
|
|
||||||
PlayerView(context).apply {
|
|
||||||
player = controller
|
|
||||||
layoutParams =
|
|
||||||
FrameLayout.LayoutParams(
|
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
|
||||||
ViewGroup.LayoutParams.WRAP_CONTENT,
|
|
||||||
)
|
|
||||||
setBackgroundColor(Color.Transparent.toArgb())
|
|
||||||
setShutterBackgroundColor(Color.Transparent.toArgb())
|
|
||||||
controllerAutoShow = false
|
|
||||||
thumbData?.thumb?.let { defaultArtwork = it }
|
|
||||||
hideController()
|
|
||||||
resizeMode =
|
|
||||||
if (maxHeight.isFinite) {
|
|
||||||
AspectRatioFrameLayout.RESIZE_MODE_FIT
|
|
||||||
} else {
|
|
||||||
AspectRatioFrameLayout.RESIZE_MODE_FIXED_WIDTH
|
|
||||||
}
|
|
||||||
onDialog?.let { innerOnDialog ->
|
|
||||||
setFullscreenButtonClickListener {
|
|
||||||
controller.pause()
|
|
||||||
innerOnDialog(it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setControllerVisibilityListener(
|
|
||||||
PlayerView.ControllerVisibilityListener { visible ->
|
|
||||||
controllerVisible.value = visible == View.VISIBLE
|
|
||||||
onControllerVisibilityChanged?.let { callback -> callback(visible == View.VISIBLE) }
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val ratio = remember { aspectRatio(dimensions) }
|
val ratio = remember { aspectRatio(dimensions) }
|
||||||
|
|
||||||
if (ratio != null) {
|
if (ratio != null) {
|
||||||
@@ -719,7 +682,39 @@ private fun RenderVideoPlayer(
|
|||||||
|
|
||||||
AndroidView(
|
AndroidView(
|
||||||
modifier = myModifier,
|
modifier = myModifier,
|
||||||
factory = factory,
|
factory = { context: Context ->
|
||||||
|
PlayerView(context).apply {
|
||||||
|
player = controller
|
||||||
|
layoutParams =
|
||||||
|
FrameLayout.LayoutParams(
|
||||||
|
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||||
|
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||||
|
)
|
||||||
|
setBackgroundColor(Color.Transparent.toArgb())
|
||||||
|
setShutterBackgroundColor(Color.Transparent.toArgb())
|
||||||
|
controllerAutoShow = false
|
||||||
|
thumbData?.thumb?.let { defaultArtwork = it }
|
||||||
|
hideController()
|
||||||
|
resizeMode =
|
||||||
|
if (maxHeight.isFinite) {
|
||||||
|
AspectRatioFrameLayout.RESIZE_MODE_FIT
|
||||||
|
} else {
|
||||||
|
AspectRatioFrameLayout.RESIZE_MODE_FIXED_WIDTH
|
||||||
|
}
|
||||||
|
onDialog?.let { innerOnDialog ->
|
||||||
|
setFullscreenButtonClickListener {
|
||||||
|
controller.pause()
|
||||||
|
innerOnDialog(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setControllerVisibilityListener(
|
||||||
|
PlayerView.ControllerVisibilityListener { visible ->
|
||||||
|
controllerVisible.value = visible == View.VISIBLE
|
||||||
|
onControllerVisibilityChanged?.let { callback -> callback(visible == View.VISIBLE) }
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
waveform?.let { Waveform(it, controller, remember { Modifier.align(Alignment.Center) }) }
|
waveform?.let { Waveform(it, controller, remember { Modifier.align(Alignment.Center) }) }
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ import androidx.compose.foundation.lazy.itemsIndexed
|
|||||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.foundation.text.KeyboardOptions
|
import androidx.compose.foundation.text.KeyboardOptions
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
|
||||||
import androidx.compose.material3.HorizontalDivider
|
import androidx.compose.material3.HorizontalDivider
|
||||||
import androidx.compose.material3.IconButton
|
import androidx.compose.material3.IconButton
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
@@ -290,7 +289,6 @@ private fun SearchBar(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun SearchTextField(
|
private fun SearchTextField(
|
||||||
searchBarViewModel: SearchBarViewModel,
|
searchBarViewModel: SearchBarViewModel,
|
||||||
|
|||||||
Reference in New Issue
Block a user