Simplified implementation of alertView() function.
This commit is contained in:
@@ -15,6 +15,7 @@ import android.os.Bundle
|
|||||||
import android.text.Editable
|
import android.text.Editable
|
||||||
import android.text.TextWatcher
|
import android.text.TextWatcher
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.core.app.ActivityCompat
|
import androidx.core.app.ActivityCompat
|
||||||
@@ -54,19 +55,18 @@ object Utils {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("InflateParams")
|
|
||||||
fun alertView(context: Context, title: String, message: String, action: () -> (Unit) = {}) {
|
fun alertView(context: Context, title: String, message: String, action: () -> (Unit) = {}) {
|
||||||
val titleView = LayoutInflater.from(context).inflate(R.layout.alert_title, null) as TextView
|
val titleView = View.inflate(context, R.layout.alert_title, null) as TextView
|
||||||
titleView.text = title
|
titleView.text = title
|
||||||
val builder = AlertDialog.Builder(context)
|
with (AlertDialog.Builder(context)) {
|
||||||
builder.setCustomTitle(titleView)
|
setCustomTitle(titleView)
|
||||||
.setMessage(message)
|
setMessage(message)
|
||||||
.setPositiveButton(R.string.ok)
|
setPositiveButton(R.string.ok) { dialog, _ ->
|
||||||
{ dialog, _ ->
|
|
||||||
dialog.dismiss()
|
dialog.dismiss()
|
||||||
action()
|
action()
|
||||||
}
|
}
|
||||||
.show()
|
show()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun uriHostPart(uri: String): String {
|
fun uriHostPart(uri: String): String {
|
||||||
|
|||||||
Reference in New Issue
Block a user