From 168dcc9f71e7e67a7f5738daf07d1cc3381abbf6 Mon Sep 17 00:00:00 2001 From: fatih ergin Date: Fri, 25 Aug 2023 01:14:28 +0300 Subject: [PATCH] migrate fragments to viewbinding --- .../dialer/fragments/ContactsFragment.kt | 76 ++++++++++-------- .../dialer/fragments/FavoritesFragment.kt | 79 +++++++++++-------- .../dialer/fragments/MyViewPagerFragment.kt | 35 +++++--- .../dialer/fragments/RecentsFragment.kt | 57 +++++++------ 4 files changed, 150 insertions(+), 97 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/dialer/fragments/ContactsFragment.kt b/app/src/main/kotlin/com/simplemobiletools/dialer/fragments/ContactsFragment.kt index de4d3bb3..cb15843e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/dialer/fragments/ContactsFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/dialer/fragments/ContactsFragment.kt @@ -11,15 +11,24 @@ import com.simplemobiletools.dialer.R import com.simplemobiletools.dialer.activities.MainActivity import com.simplemobiletools.dialer.activities.SimpleActivity import com.simplemobiletools.dialer.adapters.ContactsAdapter +import com.simplemobiletools.dialer.databinding.FragmentContactsBinding +import com.simplemobiletools.dialer.databinding.FragmentLettersLayoutBinding import com.simplemobiletools.dialer.extensions.launchCreateNewContactIntent import com.simplemobiletools.dialer.extensions.startContactDetailsIntent import com.simplemobiletools.dialer.interfaces.RefreshItemsListener -import kotlinx.android.synthetic.main.fragment_letters_layout.view.* import java.util.Locale -class ContactsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment(context, attributeSet), RefreshItemsListener { +class ContactsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment(context, attributeSet), + RefreshItemsListener { + private lateinit var binding: FragmentLettersLayoutBinding private var allContacts = ArrayList() + override fun onFinishInflate() { + super.onFinishInflate() + binding = FragmentLettersLayoutBinding.bind(FragmentContactsBinding.bind(this).contactsFragment) + innerBinding = LettersInnerBinding(binding) + } + override fun setupFragment() { val placeholderResId = if (context.hasPermission(PERMISSION_READ_CONTACTS)) { R.string.no_contacts_found @@ -27,7 +36,7 @@ class ContactsFragment(context: Context, attributeSet: AttributeSet) : MyViewPag R.string.could_not_access_contacts } - fragment_placeholder.text = context.getString(placeholderResId) + binding.fragmentPlaceholder.text = context.getString(placeholderResId) val placeholderActionResId = if (context.hasPermission(PERMISSION_READ_CONTACTS)) { R.string.create_new_contact @@ -35,7 +44,7 @@ class ContactsFragment(context: Context, attributeSet: AttributeSet) : MyViewPag R.string.request_access } - fragment_placeholder_2.apply { + binding.fragmentPlaceholder2.apply { text = context.getString(placeholderActionResId) underlineText() setOnClickListener { @@ -49,15 +58,17 @@ class ContactsFragment(context: Context, attributeSet: AttributeSet) : MyViewPag } override fun setupColors(textColor: Int, primaryColor: Int, properPrimaryColor: Int) { - (fragment_list?.adapter as? MyRecyclerViewAdapter)?.updateTextColor(textColor) - fragment_placeholder.setTextColor(textColor) - fragment_placeholder_2.setTextColor(properPrimaryColor) + binding.apply { + (fragmentList?.adapter as? MyRecyclerViewAdapter)?.updateTextColor(textColor) + fragmentPlaceholder.setTextColor(textColor) + fragmentPlaceholder2.setTextColor(properPrimaryColor) - letter_fastscroller.textColor = textColor.getColorStateList() - letter_fastscroller.pressedTextColor = properPrimaryColor - letter_fastscroller_thumb.setupWithFastScroller(letter_fastscroller) - letter_fastscroller_thumb.textColor = properPrimaryColor.getContrastColor() - letter_fastscroller_thumb.thumbColor = properPrimaryColor.getColorStateList() + letterFastscroller.textColor = textColor.getColorStateList() + letterFastscroller.pressedTextColor = properPrimaryColor + letterFastscrollerThumb.setupWithFastScroller(letterFastscroller) + letterFastscrollerThumb.textColor = properPrimaryColor.getContrastColor() + letterFastscrollerThumb.thumbColor = properPrimaryColor.getColorStateList() + } } override fun refreshItems(callback: (() -> Unit)?) { @@ -84,39 +95,42 @@ class ContactsFragment(context: Context, attributeSet: AttributeSet) : MyViewPag private fun gotContacts(contacts: ArrayList) { setupLetterFastScroller(contacts) if (contacts.isEmpty()) { - fragment_placeholder.beVisible() - fragment_placeholder_2.beVisible() - fragment_list.beGone() + binding.apply { + fragmentPlaceholder.beVisible() + fragmentPlaceholder2.beVisible() + fragmentList.beGone() + } } else { - fragment_placeholder.beGone() - fragment_placeholder_2.beGone() - fragment_list.beVisible() + binding.apply { + fragmentPlaceholder.beGone() + fragmentPlaceholder2.beGone() + fragmentList.beVisible() + } - val currAdapter = fragment_list.adapter - if (currAdapter == null) { + if (binding.fragmentList.adapter == null) { ContactsAdapter( activity = activity as SimpleActivity, contacts = contacts, - recyclerView = fragment_list, + recyclerView = binding.fragmentList, refreshItemsListener = this ) { val contact = it as Contact activity?.startContactDetailsIntent(contact) }.apply { - fragment_list.adapter = this + binding.fragmentList.adapter = this } if (context.areSystemAnimationsEnabled) { - fragment_list.scheduleLayoutAnimation() + binding.fragmentList.scheduleLayoutAnimation() } } else { - (currAdapter as ContactsAdapter).updateItems(contacts) + (binding.fragmentList.adapter as ContactsAdapter).updateItems(contacts) } } } private fun setupLetterFastScroller(contacts: ArrayList) { - letter_fastscroller.setupWithRecyclerView(fragment_list, { position -> + binding.letterFastscroller.setupWithRecyclerView(binding.fragmentList, { position -> try { val name = contacts[position].getNameToDisplay() val character = if (name.isNotEmpty()) name.substring(0, 1) else "" @@ -128,8 +142,8 @@ class ContactsFragment(context: Context, attributeSet: AttributeSet) : MyViewPag } override fun onSearchClosed() { - fragment_placeholder.beVisibleIf(allContacts.isEmpty()) - (fragment_list.adapter as? ContactsAdapter)?.updateItems(allContacts) + binding.fragmentPlaceholder.beVisibleIf(allContacts.isEmpty()) + (binding.fragmentList.adapter as? ContactsAdapter)?.updateItems(allContacts) setupLetterFastScroller(allContacts) } @@ -155,16 +169,16 @@ class ContactsFragment(context: Context, attributeSet: AttributeSet) : MyViewPag !getProperText(nameToDisplay, shouldNormalize).startsWith(text, true) && !nameToDisplay.contains(text, true) } - fragment_placeholder.beVisibleIf(filtered.isEmpty()) - (fragment_list.adapter as? ContactsAdapter)?.updateItems(filtered, text) + binding.fragmentPlaceholder.beVisibleIf(filtered.isEmpty()) + (binding.fragmentList.adapter as? ContactsAdapter)?.updateItems(filtered, text) setupLetterFastScroller(filtered) } private fun requestReadContactsPermission() { activity?.handlePermission(PERMISSION_READ_CONTACTS) { if (it) { - fragment_placeholder.text = context.getString(R.string.no_contacts_found) - fragment_placeholder_2.text = context.getString(R.string.create_new_contact) + binding.fragmentPlaceholder.text = context.getString(R.string.no_contacts_found) + binding.fragmentPlaceholder2.text = context.getString(R.string.create_new_contact) ContactsHelper(context).getContacts(showOnlyContactsWithNumbers = true) { contacts -> activity?.runOnUiThread { gotContacts(contacts) diff --git a/app/src/main/kotlin/com/simplemobiletools/dialer/fragments/FavoritesFragment.kt b/app/src/main/kotlin/com/simplemobiletools/dialer/fragments/FavoritesFragment.kt index 794438fd..5a41181c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/dialer/fragments/FavoritesFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/dialer/fragments/FavoritesFragment.kt @@ -14,15 +14,24 @@ import com.simplemobiletools.commons.views.MyLinearLayoutManager import com.simplemobiletools.dialer.R import com.simplemobiletools.dialer.activities.SimpleActivity import com.simplemobiletools.dialer.adapters.ContactsAdapter +import com.simplemobiletools.dialer.databinding.FragmentFavoritesBinding +import com.simplemobiletools.dialer.databinding.FragmentLettersLayoutBinding import com.simplemobiletools.dialer.extensions.config import com.simplemobiletools.dialer.helpers.Converters import com.simplemobiletools.dialer.interfaces.RefreshItemsListener -import kotlinx.android.synthetic.main.fragment_letters_layout.view.* import java.util.Locale -class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment(context, attributeSet), RefreshItemsListener { +class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment(context, attributeSet), + RefreshItemsListener { + private lateinit var binding: FragmentLettersLayoutBinding private var allContacts = ArrayList() + override fun onFinishInflate() { + super.onFinishInflate() + binding = FragmentLettersLayoutBinding.bind(FragmentFavoritesBinding.bind(this).favoritesFragment) + innerBinding = LettersInnerBinding(binding) + } + override fun setupFragment() { val placeholderResId = if (context.hasPermission(PERMISSION_READ_CONTACTS)) { R.string.no_contacts_found @@ -30,19 +39,21 @@ class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPa R.string.could_not_access_contacts } - fragment_placeholder.text = context.getString(placeholderResId) - fragment_placeholder_2.beGone() + binding.fragmentPlaceholder.text = context.getString(placeholderResId) + binding.fragmentPlaceholder2.beGone() } override fun setupColors(textColor: Int, primaryColor: Int, properPrimaryColor: Int) { - fragment_placeholder.setTextColor(textColor) - (fragment_list?.adapter as? MyRecyclerViewAdapter)?.updateTextColor(textColor) + binding.apply { + fragmentPlaceholder.setTextColor(textColor) + (fragmentList.adapter as? MyRecyclerViewAdapter)?.updateTextColor(textColor) - letter_fastscroller.textColor = textColor.getColorStateList() - letter_fastscroller.pressedTextColor = properPrimaryColor - letter_fastscroller_thumb.setupWithFastScroller(letter_fastscroller) - letter_fastscroller_thumb.textColor = properPrimaryColor.getContrastColor() - letter_fastscroller_thumb.thumbColor = properPrimaryColor.getColorStateList() + letterFastscroller.textColor = textColor.getColorStateList() + letterFastscroller.pressedTextColor = properPrimaryColor + letterFastscrollerThumb.setupWithFastScroller(letterFastscroller) + letterFastscrollerThumb.textColor = properPrimaryColor.getContrastColor() + letterFastscrollerThumb.thumbColor = properPrimaryColor.getColorStateList() + } } override fun refreshItems(callback: (() -> Unit)?) { @@ -76,14 +87,16 @@ class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPa private fun gotContacts(contacts: ArrayList) { setupLetterFastScroller(contacts) - if (contacts.isEmpty()) { - fragment_placeholder.beVisible() - fragment_list.beGone() - } else { - fragment_placeholder.beGone() - fragment_list.beVisible() + binding.apply { + if (contacts.isEmpty()) { + fragmentPlaceholder.beVisible() + fragmentList.beGone() + } else { + fragmentPlaceholder.beGone() + fragmentList.beVisible() - updateListAdapter() + updateListAdapter() + } } } @@ -91,12 +104,12 @@ class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPa val viewType = context.config.viewType setViewType(viewType) - val currAdapter = fragment_list.adapter as ContactsAdapter? + val currAdapter = binding.fragmentList.adapter as ContactsAdapter? if (currAdapter == null) { ContactsAdapter( activity = activity as SimpleActivity, contacts = allContacts, - recyclerView = fragment_list, + recyclerView = binding.fragmentList, refreshItemsListener = this, viewType = viewType, showDeleteButton = false, @@ -114,10 +127,10 @@ class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPa } } }.apply { - fragment_list.adapter = this + binding.fragmentList.adapter = this onDragEndListener = { - val adapter = fragment_list?.adapter + val adapter = binding.fragmentList.adapter if (adapter is ContactsAdapter) { val items = adapter.contacts saveCustomOrderToPrefs(items) @@ -131,7 +144,7 @@ class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPa } if (context.areSystemAnimationsEnabled) { - fragment_list.scheduleLayoutAnimation() + binding.fragmentList.scheduleLayoutAnimation() } } else { currAdapter.viewType = viewType @@ -140,8 +153,8 @@ class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPa } fun columnCountChanged() { - (fragment_list.layoutManager as MyGridLayoutManager).spanCount = context!!.config.contactsGridColumnCount - fragment_list?.adapter?.apply { + (binding.fragmentList.layoutManager as MyGridLayoutManager).spanCount = context!!.config.contactsGridColumnCount + binding.fragmentList.adapter?.apply { notifyItemRangeChanged(0, allContacts.size) } } @@ -169,7 +182,7 @@ class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPa } private fun setupLetterFastScroller(contacts: List) { - letter_fastscroller.setupWithRecyclerView(fragment_list, { position -> + binding.letterFastscroller.setupWithRecyclerView(binding.fragmentList, { position -> try { val name = contacts[position].getNameToDisplay() val character = if (name.isNotEmpty()) name.substring(0, 1) else "" @@ -181,8 +194,8 @@ class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPa } override fun onSearchClosed() { - fragment_placeholder.beVisibleIf(allContacts.isEmpty()) - (fragment_list.adapter as? ContactsAdapter)?.updateItems(allContacts) + binding.fragmentPlaceholder.beVisibleIf(allContacts.isEmpty()) + (binding.fragmentList.adapter as? ContactsAdapter)?.updateItems(allContacts) setupLetterFastScroller(allContacts) } @@ -193,8 +206,8 @@ class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPa it.name.startsWith(text, true) }.toMutableList() as ArrayList - fragment_placeholder.beVisibleIf(contacts.isEmpty()) - (fragment_list.adapter as? ContactsAdapter)?.updateItems(contacts, text) + binding.fragmentPlaceholder.beVisibleIf(contacts.isEmpty()) + (binding.fragmentList.adapter as? ContactsAdapter)?.updateItems(contacts, text) setupLetterFastScroller(contacts) } @@ -202,12 +215,12 @@ class FavoritesFragment(context: Context, attributeSet: AttributeSet) : MyViewPa val spanCount = context.config.contactsGridColumnCount val layoutManager = if (viewType == VIEW_TYPE_GRID) { - letter_fastscroller.beGone() + binding.letterFastscroller.beGone() MyGridLayoutManager(context, spanCount) } else { - letter_fastscroller.beVisible() + binding.letterFastscroller.beVisible() MyLinearLayoutManager(context) } - fragment_list.layoutManager = layoutManager + binding.fragmentList.layoutManager = layoutManager } } diff --git a/app/src/main/kotlin/com/simplemobiletools/dialer/fragments/MyViewPagerFragment.kt b/app/src/main/kotlin/com/simplemobiletools/dialer/fragments/MyViewPagerFragment.kt index faff87ae..e9df7c73 100644 --- a/app/src/main/kotlin/com/simplemobiletools/dialer/fragments/MyViewPagerFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/dialer/fragments/MyViewPagerFragment.kt @@ -9,18 +9,20 @@ import com.simplemobiletools.commons.extensions.getProperTextColor import com.simplemobiletools.commons.extensions.getTextSize import com.simplemobiletools.commons.helpers.SORT_BY_FIRST_NAME import com.simplemobiletools.commons.helpers.SORT_BY_SURNAME +import com.simplemobiletools.commons.views.MyRecyclerView import com.simplemobiletools.dialer.activities.MainActivity import com.simplemobiletools.dialer.activities.SimpleActivity import com.simplemobiletools.dialer.adapters.ContactsAdapter import com.simplemobiletools.dialer.adapters.RecentCallsAdapter +import com.simplemobiletools.dialer.databinding.FragmentLettersLayoutBinding +import com.simplemobiletools.dialer.databinding.FragmentRecentsBinding import com.simplemobiletools.dialer.extensions.config import com.simplemobiletools.dialer.helpers.Config -import kotlinx.android.synthetic.main.fragment_letters_layout.view.fragment_list -import kotlinx.android.synthetic.main.fragment_recents.view.recents_list -abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet) : RelativeLayout(context, attributeSet) { +abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet) : + RelativeLayout(context, attributeSet) { protected var activity: SimpleActivity? = null - + protected lateinit var innerBinding: BINDING private lateinit var config: Config fun setupFragment(activity: SimpleActivity) { @@ -35,7 +37,7 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet) fun startNameWithSurnameChanged(startNameWithSurname: Boolean) { if (this !is RecentsFragment) { - (fragment_list.adapter as? ContactsAdapter)?.apply { + (innerBinding.fragmentList?.adapter as? ContactsAdapter)?.apply { config.sorting = if (startNameWithSurname) SORT_BY_SURNAME else SORT_BY_FIRST_NAME (this@MyViewPagerFragment.activity!! as MainActivity).refreshFragments() } @@ -43,18 +45,18 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet) } fun finishActMode() { - (fragment_list?.adapter as? MyRecyclerViewAdapter)?.finishActMode() - (recents_list?.adapter as? MyRecyclerViewAdapter)?.finishActMode() + (innerBinding.fragmentList?.adapter as? MyRecyclerViewAdapter)?.finishActMode() + (innerBinding.recentsList?.adapter as? MyRecyclerViewAdapter)?.finishActMode() } fun fontSizeChanged() { if (this is RecentsFragment) { - (recents_list?.adapter as? RecentCallsAdapter)?.apply { + (innerBinding.recentsList?.adapter as? RecentCallsAdapter)?.apply { fontSize = activity.getTextSize() notifyDataSetChanged() } } else { - (fragment_list?.adapter as? ContactsAdapter)?.apply { + (innerBinding.fragmentList?.adapter as? ContactsAdapter)?.apply { fontSize = activity.getTextSize() notifyDataSetChanged() } @@ -68,4 +70,19 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet) abstract fun onSearchClosed() abstract fun onSearchQueryChanged(text: String) + + interface InnerBinding { + val fragmentList: MyRecyclerView? + val recentsList: MyRecyclerView? + } + + class LettersInnerBinding(val binding: FragmentLettersLayoutBinding) : InnerBinding { + override val fragmentList: MyRecyclerView = binding.fragmentList + override val recentsList = null + } + + class RecentsInnerBinding(val binding: FragmentRecentsBinding) : InnerBinding { + override val fragmentList = null + override val recentsList = binding.recentsList + } } diff --git a/app/src/main/kotlin/com/simplemobiletools/dialer/fragments/RecentsFragment.kt b/app/src/main/kotlin/com/simplemobiletools/dialer/fragments/RecentsFragment.kt index 2ef37e88..9921835a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/dialer/fragments/RecentsFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/dialer/fragments/RecentsFragment.kt @@ -13,19 +13,25 @@ import com.simplemobiletools.commons.views.MyRecyclerView import com.simplemobiletools.dialer.R import com.simplemobiletools.dialer.activities.SimpleActivity import com.simplemobiletools.dialer.adapters.RecentCallsAdapter +import com.simplemobiletools.dialer.databinding.FragmentRecentsBinding import com.simplemobiletools.dialer.extensions.config import com.simplemobiletools.dialer.helpers.MIN_RECENTS_THRESHOLD import com.simplemobiletools.dialer.helpers.RecentsHelper import com.simplemobiletools.dialer.interfaces.RefreshItemsListener import com.simplemobiletools.dialer.models.RecentCall -import kotlinx.android.synthetic.main.fragment_recents.view.recents_list -import kotlinx.android.synthetic.main.fragment_recents.view.recents_placeholder -import kotlinx.android.synthetic.main.fragment_recents.view.recents_placeholder_2 -class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment(context, attributeSet), RefreshItemsListener { +class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment(context, attributeSet), + RefreshItemsListener { + private lateinit var binding: FragmentRecentsBinding private var allRecentCalls = listOf() private var recentsAdapter: RecentCallsAdapter? = null + override fun onFinishInflate() { + super.onFinishInflate() + binding = FragmentRecentsBinding.bind(this) + innerBinding = RecentsInnerBinding(binding) + } + override fun setupFragment() { val placeholderResId = if (context.hasPermission(PERMISSION_READ_CALL_LOG)) { R.string.no_previous_calls @@ -33,8 +39,8 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage R.string.could_not_access_the_call_history } - recents_placeholder.text = context.getString(placeholderResId) - recents_placeholder_2.apply { + binding.recentsPlaceholder.text = context.getString(placeholderResId) + binding.recentsPlaceholder2.apply { underlineText() setOnClickListener { requestCallLogPermission() @@ -43,8 +49,8 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage } override fun setupColors(textColor: Int, primaryColor: Int, properPrimaryColor: Int) { - recents_placeholder.setTextColor(textColor) - recents_placeholder_2.setTextColor(properPrimaryColor) + binding.recentsPlaceholder.setTextColor(textColor) + binding.recentsPlaceholder.setTextColor(properPrimaryColor) recentsAdapter?.apply { initDrawables() @@ -73,17 +79,20 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage private fun gotRecents(recents: List) { if (recents.isEmpty()) { - recents_placeholder.beVisible() - recents_placeholder_2.beGoneIf(context.hasPermission(PERMISSION_READ_CALL_LOG)) - recents_list.beGone() + binding.apply { + recentsPlaceholder.beVisible() + recentsPlaceholder2.beGoneIf(context.hasPermission(PERMISSION_READ_CALL_LOG)) + recentsList.beGone() + } } else { - recents_placeholder.beGone() - recents_placeholder_2.beGone() - recents_list.beVisible() + binding.apply { + recentsPlaceholder.beGone() + recentsPlaceholder2.beGone() + recentsList.beVisible() + } - val currAdapter = recents_list.adapter - if (currAdapter == null) { - recentsAdapter = RecentCallsAdapter(activity as SimpleActivity, recents.toMutableList(), recents_list, this, true) { + if (binding.recentsList.adapter == null) { + recentsAdapter = RecentCallsAdapter(activity as SimpleActivity, recents.toMutableList(), binding.recentsList, this, true) { val recentCall = it as RecentCall if (context.config.showCallConfirmation) { CallConfirmationDialog(activity as SimpleActivity, recentCall.name) { @@ -94,13 +103,13 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage } } - recents_list.adapter = recentsAdapter + binding.recentsList.adapter = recentsAdapter if (context.areSystemAnimationsEnabled) { - recents_list.scheduleLayoutAnimation() + binding.recentsList.scheduleLayoutAnimation() } - recents_list.endlessScrollListener = object : MyRecyclerView.EndlessScrollListener { + binding.recentsList.endlessScrollListener = object : MyRecyclerView.EndlessScrollListener { override fun updateTop() {} override fun updateBottom() { @@ -136,8 +145,8 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage private fun requestCallLogPermission() { activity?.handlePermission(PERMISSION_READ_CALL_LOG) { if (it) { - recents_placeholder.text = context.getString(R.string.no_previous_calls) - recents_placeholder_2.beGone() + binding.recentsPlaceholder.text = context.getString(R.string.no_previous_calls) + binding.recentsPlaceholder2.beGone() val groupSubsequentCalls = context?.config?.groupSubsequentCalls ?: false RecentsHelper(context).getRecentCalls(groupSubsequentCalls) { recents -> @@ -150,7 +159,7 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage } override fun onSearchClosed() { - recents_placeholder.beVisibleIf(allRecentCalls.isEmpty()) + binding.recentsPlaceholder.beVisibleIf(allRecentCalls.isEmpty()) recentsAdapter?.updateItems(allRecentCalls) } @@ -161,7 +170,7 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage it.name.startsWith(text, true) }.toMutableList() as ArrayList - recents_placeholder.beVisibleIf(recentCalls.isEmpty()) + binding.recentsPlaceholder.beVisibleIf(recentCalls.isEmpty()) recentsAdapter?.updateItems(recentCalls, text) } }