Use property delegates for viewbinding in activities

This commit is contained in:
Ensar Sarajčić 2023-08-17 17:13:40 +02:00
parent b9e55d4934
commit c049b41c1a
3 changed files with 4 additions and 6 deletions

View File

@ -5,6 +5,7 @@ import android.content.pm.PackageManager
import android.os.Bundle import android.os.Bundle
import com.simplemobiletools.commons.extensions.beVisibleIf import com.simplemobiletools.commons.extensions.beVisibleIf
import com.simplemobiletools.commons.extensions.normalizeString import com.simplemobiletools.commons.extensions.normalizeString
import com.simplemobiletools.commons.extensions.viewBinding
import com.simplemobiletools.commons.helpers.NavigationIcon import com.simplemobiletools.commons.helpers.NavigationIcon
import com.simplemobiletools.commons.helpers.ensureBackgroundThread import com.simplemobiletools.commons.helpers.ensureBackgroundThread
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
@ -17,12 +18,11 @@ import com.simplemobiletools.launcher.extensions.hiddenIconsDB
import com.simplemobiletools.launcher.models.HiddenIcon import com.simplemobiletools.launcher.models.HiddenIcon
class HiddenIconsActivity : SimpleActivity(), RefreshRecyclerViewListener { class HiddenIconsActivity : SimpleActivity(), RefreshRecyclerViewListener {
private lateinit var binding: ActivityHiddenIconsBinding private val binding by viewBinding(ActivityHiddenIconsBinding::inflate)
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
isMaterialActivity = true isMaterialActivity = true
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
binding = ActivityHiddenIconsBinding.inflate(layoutInflater)
setContentView(binding.root) setContentView(binding.root)
updateIcons() updateIcons()

View File

@ -73,7 +73,7 @@ class MainActivity : SimpleActivity(), FlingListener {
private var wasJustPaused: Boolean = false private var wasJustPaused: Boolean = false
private lateinit var mDetector: GestureDetectorCompat private lateinit var mDetector: GestureDetectorCompat
private lateinit var binding: ActivityMainBinding private val binding by viewBinding(ActivityMainBinding::inflate)
val menuListener: ItemMenuListener = object : ItemMenuListener { val menuListener: ItemMenuListener = object : ItemMenuListener {
override fun onAnyClick() { override fun onAnyClick() {
@ -131,7 +131,6 @@ class MainActivity : SimpleActivity(), FlingListener {
useDynamicTheme = false useDynamicTheme = false
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root) setContentView(binding.root)
appLaunched(BuildConfig.APPLICATION_ID) appLaunched(BuildConfig.APPLICATION_ID)

View File

@ -21,11 +21,10 @@ import kotlin.system.exitProcess
class SettingsActivity : SimpleActivity() { class SettingsActivity : SimpleActivity() {
private lateinit var binding: ActivitySettingsBinding private val binding by viewBinding(ActivitySettingsBinding::inflate)
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
isMaterialActivity = true isMaterialActivity = true
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
binding = ActivitySettingsBinding.inflate(layoutInflater)
setContentView(binding.root) setContentView(binding.root)
updateMaterialActivityViews(binding.settingsCoordinator, binding.settingsHolder, useTransparentNavigation = true, useTopSearchMenu = false) updateMaterialActivityViews(binding.settingsCoordinator, binding.settingsHolder, useTransparentNavigation = true, useTopSearchMenu = false)