Repository: skyline-emu/skyline
File: app/src/main/java/emu/skyline/EmulationActivity.kt (Kotlin)

Code before:
        binding.gameView.setAspectRatio(
            when (preferenceSettings.aspectRatio) {
                0 -> Rational(16, 9)
                1 -> Rational(21, 9)
                else -> null
            }
        )

        if (preferenceSettings.perfStats) {
            if (preferenceSettings.disableFrameThrottling)
                binding.perfStats.setTextColor(getColor(R.color.colorPerfStatsSecondary))

            binding.perfStats.apply {
                postDelayed(object : Runnable {
                    override fun run() {
                        updatePerformanceStatistics()
                        text = "$fps FPS\n${"%.1f".format(averageFrametime)}±${"%.2f".format(averageFrametimeDeviation)}ms"
                        postDelayed(this, 250)
                    }
                }, 250)
            }
        }

        force60HzRefreshRate(!preferenceSettings.maxRefreshRate)
        getSystemService<DisplayManager>()?.registerDisplayListener(this, null)

        binding.gameView.setOnTouchListener(this)

        // Hide on screen controls when first controller is not set
        binding.onScreenControllerView.apply {
            controllerType = inputHandler.getFirstControllerType()
            isGone = controllerType == ControllerType.None || !preferenceSettings.onScreenControl
            setOnButtonStateChangedListener(::onButtonStateChanged)
            setOnStickStateChangedListener(::onStickStateChanged)
            hapticFeedback = preferenceSettings.onScreenControl && preferenceSettings.onScreenControlFeedback
            recenterSticks = preferenceSettings.onScreenControlRecenterSticks
        }

        binding.onScreenControllerToggle.apply {
            isGone = binding.onScreenControllerView.isGone
            setOnClickListener { binding.onScreenControllerView.isInvisible = !binding.onScreenControllerView.isInvisible }
        }

        executeApplication(intent!!)
    }

    override fun onPause() {
        super.onPause()

        if (preferenceSettings.forceMaxGpuClocks)
            GpuDriverHelper.forceMaxGpuClocks(false)

Review comment (suggestion):
Replace this call with updating the setting value in SharedPreference, while waiting for Kotlin code to be ready to handle runtime change of settings.

Code after:
        }

        binding.gameView.holder.addCallback(this)

        binding.gameView.setAspectRatio(
            when (preferenceSettings.aspectRatio) {
                0 -> Rational(16, 9)
                1 -> Rational(21, 9)
                else -> null
            }
        )

        if (preferenceSettings.perfStats) {
            if (preferenceSettings.disableFrameThrottling)
                binding.perfStats.setTextColor(getColor(R.color.colorPerfStatsSecondary))

            binding.perfStats.apply {
                postDelayed(object : Runnable {
                    override fun run() {
                        updatePerformanceStatistics()
                        text = "$fps FPS\n${"%.1f".format(averageFrametime)}±${"%.2f".format(averageFrametimeDeviation)}ms"
                        postDelayed(this, 250)
                    }
                }, 250)
                setOnClickListener {
                    val newValue = !preferenceSettings.disableFrameThrottling
                    preferenceSettings.disableFrameThrottling = newValue
                    nativeSettings.disableFrameThrottling = newValue

                    var color = if (newValue) getColor(R.color.colorPerfStatsSecondary) else getColor(R.color.colorPerfStatsPrimary)
                    binding.perfStats.setTextColor(color)
                    nativeSettings.updateNative()
                }
            }
        }

        force60HzRefreshRate(!preferenceSettings.maxRefreshRate)
        getSystemService<DisplayManager>()?.registerDisplayListener(this, null)

        binding.gameView.setOnTouchListener(this)

        // Hide on screen controls when first controller is not set
        binding.onScreenControllerView.apply {
            controllerType = inputHandler.getFirstControllerType()
            isGone = controllerType == ControllerType.None || !preferenceSettings.onScreenControl
            setOnButtonStateChangedListener(::onButtonStateChanged)
            setOnStickStateChangedListener(::onStickStateChanged)
            hapticFeedback = preferenceSettings.onScreenControl && preferenceSettings.onScreenControlFeedback
            recenterSticks = preferenceSettings.onScreenControlRecenterSticks
        }