updating commons

This commit is contained in:
tibbi 2022-07-05 15:25:46 +02:00
parent a7c33fc5a0
commit b117c15ae6
2 changed files with 11 additions and 7 deletions

View File

@ -63,7 +63,7 @@ android {
} }
dependencies { dependencies {
implementation 'com.github.SimpleMobileTools:Simple-Commons:bcf4a22735' implementation 'com.github.SimpleMobileTools:Simple-Commons:7daedc5c5d'
implementation 'me.grantland:autofittextview:0.2.1' implementation 'me.grantland:autofittextview:0.2.1'
implementation 'net.objecthunter:exp4j:0.4.8' implementation 'net.objecthunter:exp4j:0.4.8'

View File

@ -12,23 +12,27 @@ import com.simplemobiletools.commons.extensions.toast
import com.simplemobiletools.commons.helpers.ensureBackgroundThread import com.simplemobiletools.commons.helpers.ensureBackgroundThread
import kotlinx.android.synthetic.main.dialog_history.view.* import kotlinx.android.synthetic.main.dialog_history.view.*
class HistoryDialog() { class HistoryDialog(activity: SimpleActivity, items: List<History>, calculator: CalculatorImpl) {
constructor(activity: SimpleActivity, items: List<History>, calculator: CalculatorImpl) : this() { var dialog: AlertDialog? = null
init {
val view = activity.layoutInflater.inflate(R.layout.dialog_history, null) val view = activity.layoutInflater.inflate(R.layout.dialog_history, null)
val dialog = AlertDialog.Builder(activity) AlertDialog.Builder(activity)
.setPositiveButton(R.string.ok, null) .setPositiveButton(R.string.ok, null)
.setNeutralButton(R.string.clear_history) { _, _ -> .setNeutralButton(R.string.clear_history) { _, _ ->
ensureBackgroundThread { ensureBackgroundThread {
activity.applicationContext.calculatorDB.deleteHistory() activity.applicationContext.calculatorDB.deleteHistory()
activity.toast(R.string.history_cleared) activity.toast(R.string.history_cleared)
} }
}.create().apply { }.apply {
activity.setupDialogStuff(view, this, R.string.history) activity.setupDialogStuff(view, this, R.string.history) { alertDialog ->
dialog = alertDialog
}
} }
view.history_list.adapter = HistoryAdapter(activity, items, calculator) { view.history_list.adapter = HistoryAdapter(activity, items, calculator) {
dialog.dismiss() dialog?.dismiss()
} }
} }
} }