fix some crashes at inflating some views

This commit is contained in:
tibbi 2018-01-03 11:44:10 +01:00
parent 013bb713d6
commit 2b636f7240

View File

@ -40,7 +40,6 @@ import com.simplemobiletools.contacts.models.Email
import com.simplemobiletools.contacts.models.Event import com.simplemobiletools.contacts.models.Event
import com.simplemobiletools.contacts.models.PhoneNumber import com.simplemobiletools.contacts.models.PhoneNumber
import kotlinx.android.synthetic.main.activity_contact.* import kotlinx.android.synthetic.main.activity_contact.*
import kotlinx.android.synthetic.main.activity_contact.view.*
import kotlinx.android.synthetic.main.item_email.view.* import kotlinx.android.synthetic.main.item_email.view.*
import kotlinx.android.synthetic.main.item_event.view.* import kotlinx.android.synthetic.main.item_event.view.*
import kotlinx.android.synthetic.main.item_phone_number.view.* import kotlinx.android.synthetic.main.item_phone_number.view.*
@ -609,35 +608,32 @@ class ContactActivity : SimpleActivity() {
} }
private fun addNewPhoneNumberField() { private fun addNewPhoneNumberField() {
layoutInflater.inflate(R.layout.item_phone_number, contact_numbers_holder, false).apply { val numberHolder = layoutInflater.inflate(R.layout.item_phone_number, contact_numbers_holder, false) as ViewGroup
updateTextColors(this as ViewGroup) updateTextColors(numberHolder)
setupPhoneNumberTypePicker(contact_number_type) setupPhoneNumberTypePicker(numberHolder.contact_number_type)
contact_numbers_holder.addView(this) contact_numbers_holder.addView(numberHolder)
contact_numbers_holder.onGlobalLayout { contact_numbers_holder.onGlobalLayout {
contact_number.requestFocus() numberHolder.contact_number.requestFocus()
showKeyboard(contact_number) showKeyboard(numberHolder.contact_number)
}
} }
} }
private fun addNewEmailField() { private fun addNewEmailField() {
layoutInflater.inflate(R.layout.item_email, contact_emails_holder, false).apply { val emailHolder = layoutInflater.inflate(R.layout.item_email, contact_emails_holder, false) as ViewGroup
updateTextColors(this as ViewGroup) updateTextColors(emailHolder)
setupEmailTypePicker(contact_email_type) setupEmailTypePicker(emailHolder.contact_email_type)
contact_emails_holder.addView(this) contact_emails_holder.addView(emailHolder)
contact_emails_holder.onGlobalLayout { contact_emails_holder.onGlobalLayout {
contact_email.requestFocus() emailHolder.contact_email.requestFocus()
showKeyboard(contact_email) showKeyboard(emailHolder.contact_email)
}
} }
} }
private fun addNewEventField() { private fun addNewEventField() {
layoutInflater.inflate(R.layout.item_event, contact_events_holder, false).apply { val eventHolder = layoutInflater.inflate(R.layout.item_event, contact_events_holder, false) as ViewGroup
updateTextColors(this as ViewGroup) updateTextColors(eventHolder)
setupEventTypePicker(this) setupEventTypePicker(eventHolder)
contact_events_holder.addView(this) contact_events_holder.addView(eventHolder)
}
} }
private fun deleteContact() { private fun deleteContact() {