fixing a couple crashes
This commit is contained in:
parent
dfb31b40a5
commit
170d7438f8
5 changed files with 27 additions and 10 deletions
|
@ -104,9 +104,7 @@ abstract class ContactActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
fun shareContact() {
|
||||
if (contact != null) {
|
||||
shareContacts(arrayListOf(contact!!))
|
||||
}
|
||||
shareContacts(arrayListOf(contact!!))
|
||||
}
|
||||
|
||||
fun trySendSMS() {
|
||||
|
|
|
@ -94,6 +94,10 @@ class EditContactActivity : ContactActivity() {
|
|||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
if (contact == null) {
|
||||
return true
|
||||
}
|
||||
|
||||
when (item.itemId) {
|
||||
R.id.save -> saveContact()
|
||||
R.id.share -> shareContact()
|
||||
|
@ -232,7 +236,11 @@ class EditContactActivity : ContactActivity() {
|
|||
Intent().apply {
|
||||
action = Intent.ACTION_EDIT
|
||||
data = getContactPublicUri(contact!!)
|
||||
startActivity(this)
|
||||
if (resolveActivity(packageManager) != null) {
|
||||
startActivity(this)
|
||||
} else {
|
||||
toast(R.string.no_app_found)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -713,7 +721,7 @@ class EditContactActivity : ContactActivity() {
|
|||
}
|
||||
|
||||
private fun saveContact() {
|
||||
if (isSaving || contact == null) {
|
||||
if (isSaving) {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -354,10 +354,14 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
|
|||
return
|
||||
}
|
||||
|
||||
val inputStream = contentResolver.openInputStream(uri)
|
||||
val out = FileOutputStream(tempFile)
|
||||
inputStream.copyTo(out)
|
||||
showImportContactsDialog(tempFile.absolutePath)
|
||||
try {
|
||||
val inputStream = contentResolver.openInputStream(uri)
|
||||
val out = FileOutputStream(tempFile)
|
||||
inputStream.copyTo(out)
|
||||
showImportContactsDialog(tempFile.absolutePath)
|
||||
} catch (e: Exception) {
|
||||
showErrorToast(e)
|
||||
}
|
||||
}
|
||||
else -> toast(R.string.invalid_file_format)
|
||||
}
|
||||
|
|
|
@ -57,6 +57,10 @@ class ViewContactActivity : ContactActivity() {
|
|||
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
if (contact == null) {
|
||||
return true
|
||||
}
|
||||
|
||||
when (item.itemId) {
|
||||
R.id.edit -> editContact(contact!!)
|
||||
R.id.share -> shareContact()
|
||||
|
|
|
@ -145,7 +145,10 @@ class ContactsAdapter(activity: SimpleActivity, var contactItems: ArrayList<Cont
|
|||
|
||||
val contactsToRemove = ArrayList<Contact>()
|
||||
selectedPositions.sortedDescending().forEach {
|
||||
contactsToRemove.add(contactItems[it])
|
||||
val contact = contactItems.getOrNull(it)
|
||||
if (contact != null) {
|
||||
contactsToRemove.add(contact)
|
||||
}
|
||||
}
|
||||
contactItems.removeAll(contactsToRemove)
|
||||
|
||||
|
|
Loading…
Reference in a new issue