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.*
abstract class ContactActivity : SimpleActivity() {
var isEditActivity = false
var contact: Contact? = null
var currentContactPhotoPath = ""

View File

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