move contact init at ViewContactActivity to resume

This commit is contained in:
tibbi 2018-02-10 23:42:11 +01:00
parent dd678cc7d2
commit dd6771fd0c
2 changed files with 15 additions and 10 deletions

View File

@ -32,7 +32,6 @@ import java.text.SimpleDateFormat
import java.util.* import java.util.*
abstract class ContactActivity : SimpleActivity() { abstract class ContactActivity : SimpleActivity() {
var isEditActivity = false
var contact: Contact? = null var contact: Contact? = null
var currentContactPhotoPath = "" var currentContactPhotoPath = ""

View File

@ -24,16 +24,11 @@ class ViewContactActivity : ContactActivity() {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_view_contact) setContentView(R.layout.activity_view_contact)
isEditActivity = false }
handlePermission(PERMISSION_READ_CONTACTS) { override fun onResume() {
if (it) { super.onResume()
initContact() tryInitContact()
} else {
toast(R.string.no_contacts_permission)
finish()
}
}
} }
override fun onCreateOptionsMenu(menu: Menu): Boolean { override fun onCreateOptionsMenu(menu: Menu): Boolean {
@ -51,6 +46,17 @@ class ViewContactActivity : ContactActivity() {
return true return true
} }
private fun tryInitContact() {
handlePermission(PERMISSION_READ_CONTACTS) {
if (it) {
initContact()
} else {
toast(R.string.no_contacts_permission)
finish()
}
}
}
private fun initContact() { private fun initContact() {
var contactId = intent.getIntExtra(CONTACT_ID, 0) var contactId = intent.getIntExtra(CONTACT_ID, 0)
val action = intent.action val action = intent.action