|
1 | 1 | package io.github.mrtry.todolist.misc.ui.navigator
|
2 | 2 |
|
3 | 3 | import android.app.Activity
|
| 4 | +import android.content.DialogInterface |
4 | 5 | import android.content.Intent
|
5 | 6 | import android.view.View
|
6 | 7 | import android.view.inputmethod.InputMethodManager
|
7 | 8 | import androidx.annotation.StringRes
|
| 9 | +import androidx.appcompat.app.AlertDialog |
8 | 10 | import androidx.databinding.ViewDataBinding
|
9 | 11 | import com.google.android.material.snackbar.Snackbar
|
10 | 12 | import io.github.mrtry.todolist.misc.ui.binding.Bindable
|
@@ -36,6 +38,22 @@ abstract class AbsNavigator(private val activity: Activity) {
|
36 | 38 | activity.finish()
|
37 | 39 | }
|
38 | 40 |
|
| 41 | + fun showAlert( |
| 42 | + @StringRes messageId: Int, |
| 43 | + @StringRes positiveLabel: Int = android.R.string.ok, |
| 44 | + action: ((DialogInterface, Int) -> Unit)? = null, |
| 45 | + @StringRes negativeLabel: Int = android.R.string.cancel, |
| 46 | + negativeAction: ((DialogInterface, Int) -> Unit)? = null, |
| 47 | + cancelable: Boolean = true |
| 48 | + ) { |
| 49 | + AlertDialog.Builder(activity) |
| 50 | + .setMessage(activity.getString(messageId)) |
| 51 | + .setCancelable(cancelable) |
| 52 | + .setPositiveButton(positiveLabel, action) |
| 53 | + .setNegativeButton(negativeLabel, negativeAction) |
| 54 | + .show() |
| 55 | + } |
| 56 | + |
39 | 57 | open fun showSnackBar(
|
40 | 58 | @StringRes messageId: Int, length: Int = Snackbar.LENGTH_SHORT
|
41 | 59 | ) {
|
|
0 commit comments