Use property delegates for viewbinding in activities

This commit is contained in:
Ensar Sarajčić 2023-08-15 13:36:53 +02:00
parent e1ca1d4a86
commit 975e5543d1
7 changed files with 7 additions and 12 deletions

View file

@ -74,7 +74,7 @@ class EditContactActivity : ContactActivity() {
private var numberViewToColor: EditText? = null
private var emailViewToColor: EditText? = null
private var originalContactSource = ""
private lateinit var binding: ActivityEditContactBinding
private val binding: ActivityEditContactBinding by viewBinding(ActivityEditContactBinding::inflate)
enum class PrimaryNumberStatus {
UNCHANGED, STARRED, UNSTARRED
@ -83,7 +83,6 @@ class EditContactActivity : ContactActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
showTransparentTop = true
super.onCreate(savedInstanceState)
binding = ActivityEditContactBinding.inflate(layoutInflater)
setContentView(binding.root)
if (checkAppSideloading()) {

View file

@ -27,7 +27,7 @@ class GroupContactsActivity : SimpleActivity(), RemoveFromGroupListener, Refresh
private var groupContacts = ArrayList<Contact>()
private var wasInit = false
lateinit var group: Group
private lateinit var binding: ActivityGroupContactsBinding
private val binding: ActivityGroupContactsBinding by viewBinding(ActivityGroupContactsBinding::inflate)
protected val INTENT_SELECT_RINGTONE = 600
@ -36,7 +36,6 @@ class GroupContactsActivity : SimpleActivity(), RemoveFromGroupListener, Refresh
override fun onCreate(savedInstanceState: Bundle?) {
isMaterialActivity = true
super.onCreate(savedInstanceState)
binding = ActivityGroupContactsBinding.inflate(layoutInflater)
setContentView(binding.root)
updateTextColors(binding.groupContactsCoordinator)
setupOptionsMenu()

View file

@ -33,7 +33,7 @@ class InsertOrEditContactActivity : SimpleActivity(), RefreshContactsListener {
private var isSelectContactIntent = false
private var specialMimeType: String? = null
private lateinit var binding: ActivityInsertEditContactBinding
private val binding: ActivityInsertEditContactBinding by viewBinding(ActivityInsertEditContactBinding::inflate)
private val contactsFavoritesList = arrayListOf(
TAB_CONTACTS,

View file

@ -61,11 +61,10 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
private var storedStartNameWithSurname = false
private var storedFontSize = 0
private var storedShowTabs = 0
private lateinit var binding: ActivityMainBinding
private val binding: ActivityMainBinding by viewBinding(ActivityMainBinding::inflate)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
appLaunched(BuildConfig.APPLICATION_ID)
setupOptionsMenu()

View file

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

View file

@ -42,7 +42,7 @@ class ViewContactActivity : ContactActivity() {
private var fullContact: Contact? = null // contact with all fields filled from duplicates
private var duplicateInitialized = false
private val mergeDuplicate: Boolean get() = config.mergeDuplicateContacts
private lateinit var binding: ActivityViewContactBinding
private val binding: ActivityViewContactBinding by viewBinding(ActivityViewContactBinding::inflate)
companion object {
private const val COMPARABLE_PHONE_NUMBER_LENGTH = 9
@ -51,7 +51,6 @@ class ViewContactActivity : ContactActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
showTransparentTop = true
super.onCreate(savedInstanceState)
binding = ActivityViewContactBinding.inflate(layoutInflater)
setContentView(binding.root)
if (checkAppSideloading()) {

View file

@ -27,7 +27,7 @@ import com.simplemobiletools.contacts.pro.interfaces.RefreshContactsListener
class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment<MyViewPagerFragment.LetterLayout>(context, attributeSet) {
private var favouriteContacts = listOf<Contact>()
private var zoomListener: MyRecyclerView.MyZoomListener? = null
lateinit var binding: FragmentFavoritesBinding
private lateinit var binding: FragmentFavoritesBinding
override fun onFinishInflate() {
super.onFinishInflate()