migrate dialogs to viewbinding

This commit is contained in:
fatih ergin
2023-08-25 01:14:20 +03:00
parent 81ec7fc1de
commit d65d6e884d
8 changed files with 103 additions and 111 deletions

View File

@ -4,22 +4,24 @@ import com.simplemobiletools.commons.activities.BaseSimpleActivity
import com.simplemobiletools.commons.extensions.beGoneIf
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
import com.simplemobiletools.commons.extensions.setupDialogStuff
import com.simplemobiletools.commons.extensions.viewBinding
import com.simplemobiletools.commons.helpers.*
import com.simplemobiletools.dialer.R
import com.simplemobiletools.dialer.databinding.DialogChangeSortingBinding
import com.simplemobiletools.dialer.extensions.config
import kotlinx.android.synthetic.main.dialog_change_sorting.view.*
class ChangeSortingDialog(val activity: BaseSimpleActivity, private val showCustomSorting: Boolean = false, private val callback: () -> Unit) {
private val binding by activity.viewBinding(DialogChangeSortingBinding::inflate)
private var currSorting = 0
private var config = activity.config
private var view = activity.layoutInflater.inflate(R.layout.dialog_change_sorting, null)
init {
activity.getAlertDialogBuilder()
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
.setNegativeButton(R.string.cancel, null)
.apply {
activity.setupDialogStuff(view, this, R.string.sort_by)
activity.setupDialogStuff(binding.root, this, R.string.sort_by)
}
currSorting = if (showCustomSorting && config.isCustomOrderSelected) {
@ -33,43 +35,41 @@ class ChangeSortingDialog(val activity: BaseSimpleActivity, private val showCust
}
private fun setupSortRadio() {
val sortingRadio = view.sorting_dialog_radio_sorting
binding.apply {
sortingDialogRadioSorting.setOnCheckedChangeListener { group, checkedId ->
val isCustomSorting = checkedId == sortingDialogRadioCustom.id
sortingDialogRadioOrder.beGoneIf(isCustomSorting)
divider.beGoneIf(isCustomSorting)
}
sortingRadio.setOnCheckedChangeListener { group, checkedId ->
val isCustomSorting = checkedId == sortingRadio.sorting_dialog_radio_custom.id
view.sorting_dialog_radio_order.beGoneIf(isCustomSorting)
view.divider.beGoneIf(isCustomSorting)
}
val sortBtn = when {
currSorting and SORT_BY_FIRST_NAME != 0 -> sortingDialogRadioFirstName
currSorting and SORT_BY_MIDDLE_NAME != 0 -> sortingDialogRadioMiddleName
currSorting and SORT_BY_SURNAME != 0 -> sortingDialogRadioSurname
currSorting and SORT_BY_FULL_NAME != 0 -> sortingDialogRadioFullName
currSorting and SORT_BY_CUSTOM != 0 -> sortingDialogRadioCustom
else -> sortingDialogRadioDateCreated
}
sortBtn.isChecked = true
val sortBtn = when {
currSorting and SORT_BY_FIRST_NAME != 0 -> sortingRadio.sorting_dialog_radio_first_name
currSorting and SORT_BY_MIDDLE_NAME != 0 -> sortingRadio.sorting_dialog_radio_middle_name
currSorting and SORT_BY_SURNAME != 0 -> sortingRadio.sorting_dialog_radio_surname
currSorting and SORT_BY_FULL_NAME != 0 -> sortingRadio.sorting_dialog_radio_full_name
currSorting and SORT_BY_CUSTOM != 0 -> sortingRadio.sorting_dialog_radio_custom
else -> sortingRadio.sorting_dialog_radio_date_created
if (showCustomSorting) {
sortingDialogRadioCustom.isChecked = config.isCustomOrderSelected
}
sortingDialogRadioCustom.beGoneIf(!showCustomSorting)
}
sortBtn.isChecked = true
if (showCustomSorting) {
sortingRadio.sorting_dialog_radio_custom.isChecked = config.isCustomOrderSelected
}
view.sorting_dialog_radio_custom.beGoneIf(!showCustomSorting)
}
private fun setupOrderRadio() {
val orderRadio = view.sorting_dialog_radio_order
var orderBtn = orderRadio.sorting_dialog_radio_ascending
var orderBtn = binding.sortingDialogRadioAscending
if (currSorting and SORT_DESCENDING != 0) {
orderBtn = orderRadio.sorting_dialog_radio_descending
orderBtn = binding.sortingDialogRadioDescending
}
orderBtn.isChecked = true
}
private fun dialogConfirmed() {
val sortingRadio = view.sorting_dialog_radio_sorting
var sorting = when (sortingRadio.checkedRadioButtonId) {
var sorting = when (binding.sortingDialogRadioSorting.checkedRadioButtonId) {
R.id.sorting_dialog_radio_first_name -> SORT_BY_FIRST_NAME
R.id.sorting_dialog_radio_middle_name -> SORT_BY_MIDDLE_NAME
R.id.sorting_dialog_radio_surname -> SORT_BY_SURNAME
@ -78,7 +78,7 @@ class ChangeSortingDialog(val activity: BaseSimpleActivity, private val showCust
else -> SORT_BY_DATE_CREATED
}
if (sorting != SORT_BY_CUSTOM && view.sorting_dialog_radio_order.checkedRadioButtonId == R.id.sorting_dialog_radio_descending) {
if (sorting != SORT_BY_CUSTOM && binding.sortingDialogRadioOrder.checkedRadioButtonId == R.id.sorting_dialog_radio_descending) {
sorting = sorting or SORT_DESCENDING
}

View File

@ -6,17 +6,17 @@ import androidx.fragment.app.FragmentManager
import com.simplemobiletools.commons.adapters.SimpleListItemAdapter
import com.simplemobiletools.commons.fragments.BaseBottomSheetDialogFragment
import com.simplemobiletools.commons.models.SimpleListItem
import com.simplemobiletools.dialer.R
import kotlinx.android.synthetic.main.layout_simple_recycler_view.*
import com.simplemobiletools.dialer.databinding.LayoutSimpleRecyclerViewBinding
// same as BottomSheetChooserDialog but with dynamic updates
class DynamicBottomSheetChooserDialog : BaseBottomSheetDialogFragment() {
private lateinit var binding: LayoutSimpleRecyclerViewBinding
var onItemClick: ((SimpleListItem) -> Unit)? = null
override fun setupContentView(parent: ViewGroup) {
val child = layoutInflater.inflate(R.layout.layout_simple_recycler_view, parent, false)
parent.addView(child)
binding = LayoutSimpleRecyclerViewBinding.inflate(layoutInflater, parent, false)
parent.addView(binding.root)
setupRecyclerView()
}
@ -27,13 +27,13 @@ class DynamicBottomSheetChooserDialog : BaseBottomSheetDialogFragment() {
}
private fun getRecyclerViewAdapter(): SimpleListItemAdapter {
var adapter = recycler_view.adapter as? SimpleListItemAdapter
var adapter = binding.recyclerView.adapter as? SimpleListItemAdapter
if (adapter == null) {
adapter = SimpleListItemAdapter(requireActivity()) {
onItemClick?.invoke(it)
dismissAllowingStateLoss()
}
recycler_view.adapter = adapter
binding.recyclerView.adapter = adapter
}
return adapter
}

View File

@ -1,24 +1,23 @@
package com.simplemobiletools.dialer.dialogs
import android.view.ViewGroup
import androidx.appcompat.app.AlertDialog
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.dialer.R
import com.simplemobiletools.dialer.activities.SimpleActivity
import kotlinx.android.synthetic.main.dialog_export_call_history.view.export_call_history_filename
import com.simplemobiletools.dialer.databinding.DialogExportCallHistoryBinding
class ExportCallHistoryDialog(val activity: SimpleActivity, callback: (filename: String) -> Unit) {
init {
val view = (activity.layoutInflater.inflate(R.layout.dialog_export_call_history, null) as ViewGroup).apply {
export_call_history_filename.setText("call_history_${activity.getCurrentFormattedDateTime()}")
val binding = DialogExportCallHistoryBinding.inflate(activity.layoutInflater).apply {
exportCallHistoryFilename.setText("call_history_${activity.getCurrentFormattedDateTime()}")
}
activity.getAlertDialogBuilder().setPositiveButton(R.string.ok, null).setNegativeButton(R.string.cancel, null).apply {
activity.setupDialogStuff(view, this, R.string.export_call_history) { alertDialog ->
activity.setupDialogStuff(binding.root, this, R.string.export_call_history) { alertDialog ->
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
val filename = view.export_call_history_filename.value
val filename = binding.exportCallHistoryFilename.value
when {
filename.isEmpty() -> activity.toast(R.string.empty_name)
filename.isAValidFilename() -> {

View File

@ -1,31 +1,30 @@
package com.simplemobiletools.dialer.dialogs
import androidx.appcompat.app.AlertDialog
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
import com.simplemobiletools.commons.extensions.getMyContactsCursor
import com.simplemobiletools.commons.extensions.setupDialogStuff
import com.simplemobiletools.commons.helpers.SMT_PRIVATE
import com.simplemobiletools.commons.extensions.getVisibleContactSources
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.ContactsHelper
import com.simplemobiletools.commons.helpers.MyContactsContentProvider
import com.simplemobiletools.commons.models.contacts.*
import com.simplemobiletools.commons.helpers.SMT_PRIVATE
import com.simplemobiletools.commons.models.contacts.Contact
import com.simplemobiletools.commons.models.contacts.ContactSource
import com.simplemobiletools.dialer.R
import com.simplemobiletools.dialer.activities.SimpleActivity
import com.simplemobiletools.dialer.adapters.FilterContactSourcesAdapter
import com.simplemobiletools.dialer.databinding.DialogFilterContactSourcesBinding
import com.simplemobiletools.dialer.extensions.config
import kotlinx.android.synthetic.main.dialog_filter_contact_sources.view.*
class FilterContactSourcesDialog(val activity: SimpleActivity, private val callback: () -> Unit) {
private val binding by activity.viewBinding(DialogFilterContactSourcesBinding::inflate)
private var dialog: AlertDialog? = null
private val view = activity.layoutInflater.inflate(R.layout.dialog_filter_contact_sources, null)
private var contactSources = ArrayList<ContactSource>()
private var contacts = ArrayList<Contact>()
private var isContactSourcesReady = false
private var isContactsReady = false
init {
val contactHelper = ContactsHelper(activity)
contactHelper.getContactSources { contactSources ->
val contactHelper = ContactsHelper(activity)
contactHelper.getContactSources { contactSources ->
contactSources.mapTo(this@FilterContactSourcesDialog.contactSources) { it.copy() }
isContactSourcesReady = true
processDataIfReady()
@ -61,14 +60,14 @@ class FilterContactSourcesDialog(val activity: SimpleActivity, private val callb
activity.runOnUiThread {
val selectedSources = activity.getVisibleContactSources()
view.filter_contact_sources_list.adapter = FilterContactSourcesAdapter(activity, contactSourcesWithCount, selectedSources)
binding.filterContactSourcesList.adapter = FilterContactSourcesAdapter(activity, contactSourcesWithCount, selectedSources)
if (dialog == null) {
activity.getAlertDialogBuilder()
.setPositiveButton(R.string.ok) { dialogInterface, i -> confirmContactSources() }
.setNegativeButton(R.string.cancel, null)
.apply {
activity.setupDialogStuff(view, this) { alertDialog ->
activity.setupDialogStuff(binding.root, this) { alertDialog ->
dialog = alertDialog
}
}
@ -77,7 +76,7 @@ class FilterContactSourcesDialog(val activity: SimpleActivity, private val callb
}
private fun confirmContactSources() {
val selectedContactSources = (view.filter_contact_sources_list.adapter as FilterContactSourcesAdapter).getSelectedContactSources()
val selectedContactSources = (binding.filterContactSourcesList.adapter as FilterContactSourcesAdapter).getSelectedContactSources()
val ignoredContactSources = contactSources.filter { !selectedContactSources.contains(it) }.map {
if (it.type == SMT_PRIVATE) SMT_PRIVATE else it.getFullIdentifier()
}.toHashSet()

View File

@ -3,16 +3,18 @@ package com.simplemobiletools.dialer.dialogs
import com.simplemobiletools.commons.activities.BaseSimpleActivity
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
import com.simplemobiletools.commons.extensions.setupDialogStuff
import com.simplemobiletools.commons.extensions.viewBinding
import com.simplemobiletools.commons.helpers.TAB_CALL_HISTORY
import com.simplemobiletools.commons.helpers.TAB_CONTACTS
import com.simplemobiletools.commons.helpers.TAB_FAVORITES
import com.simplemobiletools.commons.views.MyAppCompatCheckbox
import com.simplemobiletools.dialer.R
import com.simplemobiletools.dialer.databinding.DialogManageVisibleTabsBinding
import com.simplemobiletools.dialer.extensions.config
import com.simplemobiletools.dialer.helpers.ALL_TABS_MASK
class ManageVisibleTabsDialog(val activity: BaseSimpleActivity) {
private var view = activity.layoutInflater.inflate(R.layout.dialog_manage_visible_tabs, null)
private val binding by activity.viewBinding(DialogManageVisibleTabsBinding::inflate)
private val tabs = LinkedHashMap<Int, Int>()
init {
@ -24,21 +26,21 @@ class ManageVisibleTabsDialog(val activity: BaseSimpleActivity) {
val showTabs = activity.config.showTabs
for ((key, value) in tabs) {
view.findViewById<MyAppCompatCheckbox>(value).isChecked = showTabs and key != 0
binding.root.findViewById<MyAppCompatCheckbox>(value).isChecked = showTabs and key != 0
}
activity.getAlertDialogBuilder()
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
.setNegativeButton(R.string.cancel, null)
.apply {
activity.setupDialogStuff(view, this)
activity.setupDialogStuff(binding.root, this)
}
}
private fun dialogConfirmed() {
var result = 0
for ((key, value) in tabs) {
if (view.findViewById<MyAppCompatCheckbox>(value).isChecked) {
if (binding.root.findViewById<MyAppCompatCheckbox>(value).isChecked) {
result += key
}
}

View File

@ -2,9 +2,7 @@ package com.simplemobiletools.dialer.dialogs
import android.graphics.Color
import android.view.KeyEvent
import android.view.View
import android.view.inputmethod.EditorInfo
import android.widget.EditText
import android.widget.ImageView
import androidx.appcompat.app.AlertDialog
import com.reddit.indicatorfastscroll.FastScrollItemIndicator
@ -14,27 +12,25 @@ import com.simplemobiletools.commons.views.MySearchMenu
import com.simplemobiletools.dialer.R
import com.simplemobiletools.dialer.activities.SimpleActivity
import com.simplemobiletools.dialer.adapters.ContactsAdapter
import kotlinx.android.synthetic.main.dialog_select_contact.view.*
import com.simplemobiletools.dialer.databinding.DialogSelectContactBinding
import java.util.Locale
class SelectContactDialog(val activity: SimpleActivity, val contacts: List<Contact>, val callback: (selectedContact: Contact) -> Unit) {
private val binding by activity.viewBinding(DialogSelectContactBinding::inflate)
private var dialog: AlertDialog? = null
private var view = activity.layoutInflater.inflate(R.layout.dialog_select_contact, null)
private val searchView = view.contact_search_view
private val searchEditText = view.findViewById<EditText>(R.id.top_toolbar_search)
private val searchViewAppBarLayout = view.findViewById<View>(R.id.top_app_bar_layout)
init {
view.apply {
letter_fastscroller.textColor = context.getProperTextColor().getColorStateList()
letter_fastscroller_thumb.setupWithFastScroller(letter_fastscroller)
letter_fastscroller_thumb.textColor = context.getProperPrimaryColor().getContrastColor()
letter_fastscroller_thumb.thumbColor = context.getProperPrimaryColor().getColorStateList()
binding.apply {
letterFastscroller.textColor = activity.getProperTextColor().getColorStateList()
letterFastscrollerThumb.setupWithFastScroller(letterFastscroller)
letterFastscrollerThumb.textColor = activity.getProperPrimaryColor().getContrastColor()
letterFastscrollerThumb.thumbColor = activity.getProperPrimaryColor().getColorStateList()
setupLetterFastScroller(contacts)
configureSearchView()
select_contact_list.adapter = ContactsAdapter(activity, contacts.toMutableList(), select_contact_list, allowLongClick = false) {
selectContactList.adapter = ContactsAdapter(activity, contacts.toMutableList(), selectContactList, allowLongClick = false) {
callback(it as Contact)
dialog?.dismiss()
}
@ -49,14 +45,14 @@ class SelectContactDialog(val activity: SimpleActivity, val contacts: List<Conta
true
}
.apply {
activity.setupDialogStuff(view, this, R.string.choose_contact) { alertDialog ->
activity.setupDialogStuff(binding.root, this, R.string.choose_contact) { alertDialog ->
dialog = alertDialog
}
}
}
private fun setupLetterFastScroller(contacts: List<Contact>) {
view.letter_fastscroller.setupWithRecyclerView(view.select_contact_list, { position ->
binding.letterFastscroller.setupWithRecyclerView(binding.selectContactList, { position ->
try {
val name = contacts[position].getNameToDisplay()
val character = if (name.isNotEmpty()) name.substring(0, 1) else ""
@ -67,9 +63,9 @@ class SelectContactDialog(val activity: SimpleActivity, val contacts: List<Conta
})
}
private fun configureSearchView() = with(searchView) {
private fun configureSearchView() = with(binding.contactSearchView) {
updateHintText(context.getString(R.string.search_contacts))
searchEditText.imeOptions = EditorInfo.IME_ACTION_DONE
binding.topToolbarSearch.imeOptions = EditorInfo.IME_ACTION_DONE
toggleHideOnScroll(true)
setupMenu()
@ -81,7 +77,7 @@ class SelectContactDialog(val activity: SimpleActivity, val contacts: List<Conta
getToolbar().beInvisible()
updateColors()
setBackgroundColor(Color.TRANSPARENT)
searchViewAppBarLayout.setBackgroundColor(Color.TRANSPARENT)
binding.topAppBarLayout.setBackgroundColor(Color.TRANSPARENT)
}
private fun MySearchMenu.setSearchViewListeners() {
@ -89,8 +85,8 @@ class SelectContactDialog(val activity: SimpleActivity, val contacts: List<Conta
updateSearchViewLeftIcon(R.drawable.ic_cross_vector)
}
onSearchClosedListener = {
searchEditText.clearFocus()
activity.hideKeyboard(searchEditText)
binding.topToolbarSearch.clearFocus()
activity.hideKeyboard(binding.topToolbarSearch)
updateSearchViewLeftIcon(R.drawable.ic_search_vector)
}
@ -99,14 +95,14 @@ class SelectContactDialog(val activity: SimpleActivity, val contacts: List<Conta
}
}
private fun updateSearchViewLeftIcon(iconResId: Int) = with(view.findViewById<ImageView>(R.id.top_toolbar_search_icon)) {
private fun updateSearchViewLeftIcon(iconResId: Int) = with(binding.root.findViewById<ImageView>(R.id.top_toolbar_search_icon)) {
post {
setImageResource(iconResId)
}
}
private fun filterContactListBySearchQuery(query: String) {
val adapter = view.select_contact_list.adapter as? ContactsAdapter
val adapter = binding.selectContactList.adapter as? ContactsAdapter
var contactsToShow = contacts
if (query.isNotEmpty()) {
contactsToShow = contacts.filter { it.name.contains(query, true) }
@ -117,7 +113,7 @@ class SelectContactDialog(val activity: SimpleActivity, val contacts: List<Conta
adapter?.updateItems(contactsToShow)
setupLetterFastScroller(contactsToShow)
view.select_contact_list.apply {
binding.selectContactList.apply {
post {
scrollToPosition(0)
}
@ -125,20 +121,20 @@ class SelectContactDialog(val activity: SimpleActivity, val contacts: List<Conta
}
}
private fun checkPlaceholderVisibility(contacts: List<Contact>) = with(view) {
contacts_empty_placeholder.beVisibleIf(contacts.isEmpty())
private fun checkPlaceholderVisibility(contacts: List<Contact>) = with(binding) {
contactsEmptyPlaceholder.beVisibleIf(contacts.isEmpty())
if (contact_search_view.isSearchOpen) {
contacts_empty_placeholder.text = context.getString(R.string.no_items_found)
if (contactSearchView.isSearchOpen) {
contactsEmptyPlaceholder.text = activity.getString(R.string.no_items_found)
}
letter_fastscroller.beVisibleIf(contacts_empty_placeholder.isGone())
letter_fastscroller_thumb.beVisibleIf(contacts_empty_placeholder.isGone())
letterFastscroller.beVisibleIf(contactsEmptyPlaceholder.isGone())
letterFastscrollerThumb.beVisibleIf(contactsEmptyPlaceholder.isGone())
}
private fun backPressed() {
if (searchView.isSearchOpen) {
searchView.closeSearch()
if (binding.contactSearchView.isSearchOpen) {
binding.contactSearchView.closeSearch()
} else {
dialog?.dismiss()
}

View File

@ -9,10 +9,11 @@ import androidx.appcompat.app.AlertDialog
import com.simplemobiletools.commons.activities.BaseSimpleActivity
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
import com.simplemobiletools.commons.extensions.setupDialogStuff
import com.simplemobiletools.commons.extensions.viewBinding
import com.simplemobiletools.dialer.R
import com.simplemobiletools.dialer.databinding.DialogSelectSimBinding
import com.simplemobiletools.dialer.extensions.config
import com.simplemobiletools.dialer.extensions.getAvailableSIMCardLabels
import kotlinx.android.synthetic.main.dialog_select_sim.view.*
@SuppressLint("MissingPermission")
class SelectSIMDialog(
@ -22,14 +23,11 @@ class SelectSIMDialog(
val callback: (handle: PhoneAccountHandle?) -> Unit
) {
private var dialog: AlertDialog? = null
private val view = activity.layoutInflater.inflate(R.layout.dialog_select_sim, null)
private val binding by activity.viewBinding(DialogSelectSimBinding::inflate)
init {
val radioGroup = view.select_sim_radio_group
view.apply {
select_sim_remember_holder.setOnClickListener {
select_sim_remember.toggle()
}
binding.selectSimRememberHolder.setOnClickListener {
binding.selectSimRemember.toggle()
}
activity.getAvailableSIMCardLabels().forEachIndexed { index, SIMAccount ->
@ -38,12 +36,12 @@ class SelectSIMDialog(
id = index
setOnClickListener { selectedSIM(SIMAccount.handle) }
}
radioGroup!!.addView(radioButton, RadioGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT))
binding.selectSimRadioGroup.addView(radioButton, RadioGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT))
}
activity.getAlertDialogBuilder()
.apply {
activity.setupDialogStuff(view, this) { alertDialog ->
activity.setupDialogStuff(binding.root, this) { alertDialog ->
dialog = alertDialog
}
}
@ -54,7 +52,7 @@ class SelectSIMDialog(
}
private fun selectedSIM(handle: PhoneAccountHandle) {
if (view.select_sim_remember.isChecked) {
if (binding.selectSimRemember.isChecked) {
activity.config.saveCustomSIM(phoneNumber, handle)
}

View File

@ -4,33 +4,31 @@ import androidx.appcompat.app.AlertDialog
import com.simplemobiletools.commons.activities.BaseSimpleActivity
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
import com.simplemobiletools.commons.extensions.setupDialogStuff
import com.simplemobiletools.dialer.R
import com.simplemobiletools.commons.extensions.viewBinding
import com.simplemobiletools.dialer.activities.SimpleActivity
import com.simplemobiletools.dialer.adapters.RecentCallsAdapter
import com.simplemobiletools.dialer.databinding.DialogShowGroupedCallsBinding
import com.simplemobiletools.dialer.helpers.RecentsHelper
import com.simplemobiletools.dialer.models.RecentCall
import kotlinx.android.synthetic.main.dialog_show_grouped_calls.view.*
class ShowGroupedCallsDialog(val activity: BaseSimpleActivity, callIds: ArrayList<Int>) {
private var dialog: AlertDialog? = null
private var view = activity.layoutInflater.inflate(R.layout.dialog_show_grouped_calls, null)
private val binding by activity.viewBinding(DialogShowGroupedCallsBinding::inflate)
init {
view.apply {
RecentsHelper(activity).getRecentCalls(false) { allRecents ->
val recents = allRecents.filter { callIds.contains(it.id) }.toMutableList() as ArrayList<RecentCall>
activity.runOnUiThread {
RecentCallsAdapter(activity as SimpleActivity, recents, select_grouped_calls_list, null, false) {
}.apply {
select_grouped_calls_list.adapter = this
}
RecentsHelper(activity).getRecentCalls(false) { allRecents ->
val recents = allRecents.filter { callIds.contains(it.id) }.toMutableList() as ArrayList<RecentCall>
activity.runOnUiThread {
RecentCallsAdapter(activity as SimpleActivity, recents, binding.selectGroupedCallsList, null, false) {
}.apply {
binding.selectGroupedCallsList.adapter = this
}
}
}
activity.getAlertDialogBuilder()
.apply {
activity.setupDialogStuff(view, this) { alertDialog ->
activity.setupDialogStuff(binding.root, this) { alertDialog ->
dialog = alertDialog
}
}