diff --git a/app/build.gradle b/app/build.gradle index 3fe80f9a..cbe65f13 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -63,7 +63,7 @@ android { } dependencies { - implementation 'com.github.SimpleMobileTools:Simple-Commons:bcf4a22735' + implementation 'com.github.SimpleMobileTools:Simple-Commons:7daedc5c5d' implementation 'me.grantland:autofittextview:0.2.1' implementation 'net.objecthunter:exp4j:0.4.8' diff --git a/app/src/main/kotlin/com/simplemobiletools/calculator/dialogs/HistoryDialog.kt b/app/src/main/kotlin/com/simplemobiletools/calculator/dialogs/HistoryDialog.kt index 9931f70d..bc1b4b20 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calculator/dialogs/HistoryDialog.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calculator/dialogs/HistoryDialog.kt @@ -12,23 +12,27 @@ 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, calculator: CalculatorImpl) : this() { +class HistoryDialog(activity: SimpleActivity, items: List, calculator: CalculatorImpl) { + var dialog: AlertDialog? = null + + init { val view = activity.layoutInflater.inflate(R.layout.dialog_history, null) - val dialog = AlertDialog.Builder(activity) + AlertDialog.Builder(activity) .setPositiveButton(R.string.ok, null) .setNeutralButton(R.string.clear_history) { _, _ -> ensureBackgroundThread { activity.applicationContext.calculatorDB.deleteHistory() activity.toast(R.string.history_cleared) } - }.create().apply { - activity.setupDialogStuff(view, this, R.string.history) + }.apply { + activity.setupDialogStuff(view, this, R.string.history) { alertDialog -> + dialog = alertDialog + } } view.history_list.adapter = HistoryAdapter(activity, items, calculator) { - dialog.dismiss() + dialog?.dismiss() } } }