From 975e5543d11e7346bfb0876c8bc18755db17042a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ensar=20Saraj=C4=8Di=C4=87?= Date: Tue, 15 Aug 2023 13:36:53 +0200 Subject: [PATCH] Use property delegates for viewbinding in activities --- .../contacts/pro/activities/EditContactActivity.kt | 3 +-- .../contacts/pro/activities/GroupContactsActivity.kt | 3 +-- .../contacts/pro/activities/InsertOrEditContactActivity.kt | 2 +- .../simplemobiletools/contacts/pro/activities/MainActivity.kt | 3 +-- .../contacts/pro/activities/SettingsActivity.kt | 3 +-- .../contacts/pro/activities/ViewContactActivity.kt | 3 +-- .../contacts/pro/fragments/FavoritesFragment.kt | 2 +- 7 files changed, 7 insertions(+), 12 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/EditContactActivity.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/EditContactActivity.kt index 3da6aaca..7a4cc6a2 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/EditContactActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/EditContactActivity.kt @@ -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()) { diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/GroupContactsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/GroupContactsActivity.kt index 6d365278..f84f7011 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/GroupContactsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/GroupContactsActivity.kt @@ -27,7 +27,7 @@ class GroupContactsActivity : SimpleActivity(), RemoveFromGroupListener, Refresh private var groupContacts = ArrayList() 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() diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/InsertOrEditContactActivity.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/InsertOrEditContactActivity.kt index 6557ff83..ce72a492 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/InsertOrEditContactActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/InsertOrEditContactActivity.kt @@ -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, diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/MainActivity.kt index d299e497..d1bbd95c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/MainActivity.kt @@ -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() diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/SettingsActivity.kt index 44f241cd..ae5bae61 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/SettingsActivity.kt @@ -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) diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/ViewContactActivity.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/ViewContactActivity.kt index d2f5007e..fa5793c9 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/ViewContactActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/activities/ViewContactActivity.kt @@ -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()) { diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/fragments/FavoritesFragment.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/fragments/FavoritesFragment.kt index 1f9fd738..bdc20bf7 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/pro/fragments/FavoritesFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/pro/fragments/FavoritesFragment.kt @@ -27,7 +27,7 @@ import com.simplemobiletools.contacts.pro.interfaces.RefreshContactsListener class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment(context, attributeSet) { private var favouriteContacts = listOf() private var zoomListener: MyRecyclerView.MyZoomListener? = null - lateinit var binding: FragmentFavoritesBinding + private lateinit var binding: FragmentFavoritesBinding override fun onFinishInflate() { super.onFinishInflate()