in app/src/main/java/com/amazon/ivs/broadcast/ui/fragments/settings/graphicpropertiesfragment/GraphicPropertiesFragment.kt [28:113]
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
switchFramerateOptionVisibility(configurationViewModel.useCustomFramerate)
switchResolutionOptionVisibility(configurationViewModel.useCustomResolution)
binding.customResolutionSwitch.isChecked = configurationViewModel.useCustomResolution
binding.customFramerateSwitch.isChecked = configurationViewModel.useCustomFramerate
binding.resolutionOptions.check(getResolutionOption())
binding.framerateOptions.check(getFramerateOption())
binding.customFramerate.text = getString(R.string.framerate_template, configurationViewModel.framerate)
updateOrientationContainer()
updateResolutionValue()
binding.backButton.setOnClickListener {
openFragment(R.id.navigation_settings)
}
binding.orientation.setOnClickListener {
binding.root.showOrientationOptions(
getString(R.string.orientation),
configurationViewModel.orientationId.getOrientation()
) { orientation ->
configurationViewModel.orientationId = orientation.id
binding.orientationValue.text = orientation.value
updateResolutionValue()
}
}
binding.customResolution.setOnClickListener {
showResolutionDialog()
}
binding.customFramerate.setOnClickListener {
showFrameRateDialog()
}
binding.customResolutionSwitch.setOnCheckedChangeListener { _, checked ->
if (checked) {
showResolutionDialog(binding.customResolutionSwitch)
} else {
configurationViewModel.useCustomResolution = false
configurationViewModel.resolution.initialWidth = configurationViewModel.recommendation.width
configurationViewModel.resolution.initialHeight = configurationViewModel.recommendation.height
binding.resolutionOptions.check(getResolutionOption())
switchResolutionOptionVisibility(false)
}
updateOrientationContainer()
}
binding.customFramerateSwitch.setOnCheckedChangeListener { _, checked ->
if (checked) {
showFrameRateDialog(binding.customFramerateSwitch)
} else {
configurationViewModel.useCustomFramerate = false
configurationViewModel.framerate = configurationViewModel.recommendation.frameRate
binding.framerateOptions.check(getFramerateOption())
switchFramerateOptionVisibility(false)
}
}
binding.resolutionOptions.setOnCheckedChangeListener { _, checkedId ->
val resolution = when (checkedId) {
binding.optionHighestResolution.id -> RESOLUTION_HIGH
binding.optionMiddleResolution.id -> RESOLUTION_MIDDLE
else -> RESOLUTION_LOW
}
configurationViewModel.resolution = resolution
configurationViewModel.recommendation.height = resolution.height
configurationViewModel.recommendation.width = resolution.width
}
binding.framerateOptions.setOnCheckedChangeListener { _, checkedId ->
val frameRate = when (checkedId) {
binding.optionHighestFramerate.id -> FRAMERATE_HIGH
binding.optionMiddleFramerate.id -> FRAMERATE_MIDDLE
else -> FRAMERATE_LOW
}
configurationViewModel.recommendation.frameRate = frameRate
configurationViewModel.framerate = frameRate
}
binding.popupContainer.setOnClickListener {
clearPopup()
}
}