Moved enforceRefreshRate SDK version check to within the function

This commit is contained in:
OpenSauce04 2025-12-09 15:13:56 +00:00
parent ff4100fe34
commit 576eac5e2f
4 changed files with 7 additions and 10 deletions

View File

@ -84,9 +84,7 @@ class EmulationActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
requestWindowFeature(Window.FEATURE_NO_TITLE)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
RefreshRateUtil.enforceRefreshRate(this, sixtyHz = true)
}
RefreshRateUtil.enforceRefreshRate(this, sixtyHz = true)
ThemeUtil.setTheme(this)
settingsViewModel.settings.loadSettings()

View File

@ -51,9 +51,7 @@ class SettingsActivity : AppCompatActivity(), SettingsActivityView {
override val settings: Settings get() = settingsViewModel.settings
override fun onCreate(savedInstanceState: Bundle?) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
RefreshRateUtil.enforceRefreshRate(this)
}
RefreshRateUtil.enforceRefreshRate(this)
ThemeUtil.setTheme(this)

View File

@ -68,9 +68,7 @@ class MainActivity : AppCompatActivity(), ThemeProvider {
override var themeId: Int = 0
override fun onCreate(savedInstanceState: Bundle?) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
RefreshRateUtil.enforceRefreshRate(this)
}
RefreshRateUtil.enforceRefreshRate(this)
val splashScreen = installSplashScreen()
CitraDirectoryUtils.attemptAutomaticUpdateDirectory()

View File

@ -18,8 +18,11 @@ object RefreshRateUtil {
// but is instead the refresh rate chosen by the user in the Android system settings.
// For example, if the user selected 120hz in the settings, but the display is capable
// of 144hz, 120hz will be treated as the maximum within this function.
@RequiresApi(Build.VERSION_CODES.R)
fun enforceRefreshRate(activity: Activity, sixtyHz: Boolean = false) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
return
}
val display = activity.display
val window = activity.window