Update HistoryDialog.kt

This commit is contained in:
Tibor Kaputa 2022-01-14 18:37:04 +01:00 committed by GitHub
parent d3f55a96e3
commit 21eeeab19f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,6 +1,5 @@
package com.simplemobiletools.calculator.dialogs
import android.view.LayoutInflater
import androidx.appcompat.app.AlertDialog
import com.simplemobiletools.calculator.R
import com.simplemobiletools.calculator.activities.SimpleActivity
@ -8,15 +7,15 @@ import com.simplemobiletools.calculator.adapters.HistoryAdapter
import com.simplemobiletools.calculator.extensions.calculatorDB
import com.simplemobiletools.calculator.helpers.CalculatorImpl
import com.simplemobiletools.calculator.models.History
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.extensions.setupDialogStuff
import com.simplemobiletools.commons.extensions.toast
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
import kotlinx.android.synthetic.main.dialog_history.view.*
class HistoryDialog() {
constructor(activity: SimpleActivity, items: List<History>, calc: CalculatorImpl) : this() {
val mInflater = LayoutInflater.from(activity)
val view = mInflater.inflate(R.layout.dialog_history, null)
view.history_list.adapter = HistoryAdapter(activity, items, calc)
constructor(activity: SimpleActivity, items: List<History>, calculator: CalculatorImpl) : this() {
val view = activity.layoutInflater.inflate(R.layout.dialog_history, null)
view.history_list.adapter = HistoryAdapter(activity, items, calculator)
AlertDialog.Builder(activity)
.setPositiveButton(R.string.ok, null)
@ -26,8 +25,7 @@ class HistoryDialog() {
activity.toast(R.string.history_cleared)
}
}
.create()
.apply {
.create().apply {
activity.setupDialogStuff(view, this, R.string.history)
(view.history_list.adapter as HistoryAdapter).setDialog(this)
}