Minor code improvement
This commit is contained in:
parent
1c54678adc
commit
d675552203
1 changed files with 23 additions and 27 deletions
|
@ -100,7 +100,11 @@ class MasterContactsFragment : MasterFragment<ContactMasterFragmentBinding, Cont
|
||||||
val swipeConfiguration = RecyclerViewSwipeConfiguration()
|
val swipeConfiguration = RecyclerViewSwipeConfiguration()
|
||||||
val white = ContextCompat.getColor(requireContext(), R.color.white_color)
|
val white = ContextCompat.getColor(requireContext(), R.color.white_color)
|
||||||
|
|
||||||
swipeConfiguration.rightToLeftAction = RecyclerViewSwipeConfiguration.Action("Delete", white, ContextCompat.getColor(requireContext(), R.color.red_color))
|
swipeConfiguration.rightToLeftAction = RecyclerViewSwipeConfiguration.Action(
|
||||||
|
"Delete",
|
||||||
|
white,
|
||||||
|
ContextCompat.getColor(requireContext(), R.color.red_color)
|
||||||
|
)
|
||||||
val swipeListener = object : RecyclerViewSwipeListener {
|
val swipeListener = object : RecyclerViewSwipeListener {
|
||||||
override fun onLeftToRightSwipe(viewHolder: RecyclerView.ViewHolder) {}
|
override fun onLeftToRightSwipe(viewHolder: RecyclerView.ViewHolder) {}
|
||||||
|
|
||||||
|
@ -184,9 +188,12 @@ class MasterContactsFragment : MasterFragment<ContactMasterFragmentBinding, Cont
|
||||||
}
|
}
|
||||||
|
|
||||||
val id = arguments?.getString("id")
|
val id = arguments?.getString("id")
|
||||||
|
val sipUri = arguments?.getString("sipUri")
|
||||||
|
val addressString = arguments?.getString("address")
|
||||||
|
arguments?.clear()
|
||||||
|
|
||||||
if (id != null) {
|
if (id != null) {
|
||||||
Log.i("[Contacts] Found contact id parameter in arguments: $id")
|
Log.i("[Contacts] Found contact id parameter in arguments: $id")
|
||||||
arguments?.clear()
|
|
||||||
val contact = coreContext.contactsManager.findContactById(id)
|
val contact = coreContext.contactsManager.findContactById(id)
|
||||||
if (contact != null) {
|
if (contact != null) {
|
||||||
Log.i("[Contacts] Found matching contact $contact")
|
Log.i("[Contacts] Found matching contact $contact")
|
||||||
|
@ -195,31 +202,20 @@ class MasterContactsFragment : MasterFragment<ContactMasterFragmentBinding, Cont
|
||||||
Log.w("[Contacts] Matching contact not found yet, waiting for contacts updated callback")
|
Log.w("[Contacts] Matching contact not found yet, waiting for contacts updated callback")
|
||||||
contactIdToDisplay = id
|
contactIdToDisplay = id
|
||||||
}
|
}
|
||||||
} else {
|
} else if (sipUri != null) {
|
||||||
val sipUri = arguments?.getString("sipUri")
|
Log.i("[Contacts] Found sipUri parameter in arguments: $sipUri")
|
||||||
if (sipUri != null) {
|
sipUriToAdd = sipUri
|
||||||
Log.i("[Contacts] Found sipUri parameter in arguments: $sipUri")
|
val activity = requireActivity() as MainActivity
|
||||||
sipUriToAdd = sipUri
|
activity.showSnackBar(R.string.contact_choose_existing_or_new_to_add_number)
|
||||||
arguments?.clear()
|
editOnClick = true
|
||||||
|
} else if (addressString != null) {
|
||||||
val activity = requireActivity() as MainActivity
|
val address = Factory.instance().createAddress(addressString)
|
||||||
activity.showSnackBar(R.string.contact_choose_existing_or_new_to_add_number)
|
if (address != null) {
|
||||||
editOnClick = true
|
Log.i("[Contacts] Found friend native pointer parameter in arguments: ${address.asStringUriOnly()}")
|
||||||
} else {
|
val contact = coreContext.contactsManager.findContactByAddress(address)
|
||||||
// When trying to display a non-native contact from history
|
if (contact != null) {
|
||||||
val addressString = arguments?.getString("address")
|
Log.i("[Contacts] Found matching contact $contact")
|
||||||
if (addressString != null) {
|
adapter.selectedContactEvent.value = Event(contact)
|
||||||
val address = Factory.instance().createAddress(addressString)
|
|
||||||
if (address != null) {
|
|
||||||
Log.i("[Contacts] Found friend native pointer parameter in arguments: ${address.asStringUriOnly()}")
|
|
||||||
arguments?.clear()
|
|
||||||
|
|
||||||
val contact = coreContext.contactsManager.findContactByAddress(address)
|
|
||||||
if (contact != null) {
|
|
||||||
Log.i("[Contacts] Found matching contact $contact")
|
|
||||||
adapter.selectedContactEvent.value = Event(contact)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue