Simplified implementation of onClick listeners.
This commit is contained in:
@@ -25,7 +25,7 @@ class AccountListAdapter(private val cxt: Context, private val rows: ArrayList<A
|
|||||||
aorView.text = row.aor.split(":")[0]
|
aorView.text = row.aor.split(":")[0]
|
||||||
aorView.textSize = 20f
|
aorView.textSize = 20f
|
||||||
aorView.setPadding(6, 6, 0, 6)
|
aorView.setPadding(6, 6, 0, 6)
|
||||||
aorView.setOnClickListener { _ ->
|
aorView.setOnClickListener {
|
||||||
val i = Intent(cxt, AccountActivity::class.java)
|
val i = Intent(cxt, AccountActivity::class.java)
|
||||||
val b = Bundle()
|
val b = Bundle()
|
||||||
b.putString("aor", UserAgent.uas()[position].account.aor)
|
b.putString("aor", UserAgent.uas()[position].account.aor)
|
||||||
@@ -35,24 +35,28 @@ class AccountListAdapter(private val cxt: Context, private val rows: ArrayList<A
|
|||||||
val ua = UserAgent.uas()[position]
|
val ua = UserAgent.uas()[position]
|
||||||
val actionView = rowView.findViewById(R.id.action) as ImageButton
|
val actionView = rowView.findViewById(R.id.action) as ImageButton
|
||||||
actionView.setImageResource(row.action)
|
actionView.setImageResource(row.action)
|
||||||
actionView.setOnClickListener { _ ->
|
actionView.setOnClickListener {
|
||||||
val deleteDialog = AlertDialog.Builder(cxt)
|
val titleView = View.inflate(cxt, R.layout.alert_title, null) as TextView
|
||||||
deleteDialog.setMessage(String.format(cxt.getString(R.string.delete_account),
|
titleView.text = cxt.getString(R.string.confirmation)
|
||||||
|
with (AlertDialog.Builder(cxt)) {
|
||||||
|
setCustomTitle(titleView)
|
||||||
|
setMessage(String.format(cxt.getString(R.string.delete_account),
|
||||||
aorView.text))
|
aorView.text))
|
||||||
deleteDialog.setPositiveButton(cxt.getText(R.string.delete)) { dialog, _ ->
|
setPositiveButton(cxt.getText(R.string.delete)) { dialog, _ ->
|
||||||
Api.ua_destroy(ua.uap)
|
Api.ua_destroy(ua.uap)
|
||||||
CallHistory.clear(ua.account.aor)
|
CallHistory.clear(ua.account.aor)
|
||||||
Message.clear(ua.account.aor)
|
Message.clear(ua.account.aor)
|
||||||
ua.remove()
|
ua.remove()
|
||||||
AccountsActivity.generateAccounts()
|
AccountsActivity.generateAccounts()
|
||||||
AccountsActivity.saveAccounts()
|
AccountsActivity.saveAccounts()
|
||||||
this.notifyDataSetChanged()
|
this@AccountListAdapter.notifyDataSetChanged()
|
||||||
dialog.dismiss()
|
dialog.dismiss()
|
||||||
}
|
}
|
||||||
deleteDialog.setNegativeButton(cxt.getText(R.string.cancel)) { dialog, _ ->
|
setNegativeButton(cxt.getText(R.string.cancel)) { dialog, _ ->
|
||||||
dialog.dismiss()
|
dialog.dismiss()
|
||||||
}
|
}
|
||||||
deleteDialog.create().show()
|
show()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return rowView
|
return rowView
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user