From 4087769c7e5a441146095b690d12ef7e411a8d69 Mon Sep 17 00:00:00 2001 From: fatih ergin Date: Tue, 15 Aug 2023 23:13:08 +0300 Subject: [PATCH] bind activities lazily --- .../com/simplemobiletools/camera/activities/MainActivity.kt | 3 +-- .../simplemobiletools/camera/activities/SettingsActivity.kt | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/camera/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/camera/activities/MainActivity.kt index 4a8b6478..bc36ff90 100644 --- a/app/src/main/kotlin/com/simplemobiletools/camera/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/camera/activities/MainActivity.kt @@ -59,7 +59,6 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera private lateinit var mOrientationEventListener: OrientationEventListener private lateinit var mFocusCircleView: FocusCircleView private lateinit var mediaSoundHelper: MediaSoundHelper - private lateinit var binding: ActivityMainBinding private var mPreview: MyPreview? = null private var mediaSizeToggleGroup: MaterialButtonToggleGroup? = null private var mPreviewUri: Uri? = null @@ -67,6 +66,7 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera private var mLastHandledOrientation = 0 private var countDownTimer: CountDownTimer? = null + private val binding by lazy(LazyThreadSafetyMode.NONE) { ActivityMainBinding.inflate(layoutInflater) } private val tabSelectedListener = object : TabSelectedListener { override fun onTabSelected(tab: TabLayout.Tab) { handlePermission(PERMISSION_RECORD_AUDIO) { @@ -90,7 +90,6 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera override fun onCreate(savedInstanceState: Bundle?) { useDynamicTheme = false super.onCreate(savedInstanceState) - binding = ActivityMainBinding.inflate(layoutInflater) appLaunched(BuildConfig.APPLICATION_ID) requestWindowFeature(Window.FEATURE_NO_TITLE) initVariables() diff --git a/app/src/main/kotlin/com/simplemobiletools/camera/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/camera/activities/SettingsActivity.kt index fd684d7e..5a7e05b8 100644 --- a/app/src/main/kotlin/com/simplemobiletools/camera/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/camera/activities/SettingsActivity.kt @@ -17,12 +17,11 @@ import java.util.* import kotlin.system.exitProcess class SettingsActivity : SimpleActivity() { - private lateinit var binding: ActivitySettingsBinding + private val binding by lazy(LazyThreadSafetyMode.NONE) { ActivitySettingsBinding.inflate(layoutInflater) } override fun onCreate(savedInstanceState: Bundle?) { isMaterialActivity = true super.onCreate(savedInstanceState) - binding = ActivitySettingsBinding.inflate(layoutInflater) binding.apply { setContentView(root) setupOptionsMenu()