bind activities lazily

This commit is contained in:
fatih ergin 2023-08-15 23:13:08 +03:00
parent 3d09de6939
commit 4087769c7e
2 changed files with 2 additions and 4 deletions

View File

@ -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()

View File

@ -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()