mirror of https://github.com/iSoron/uhabits.git
Reimplementing the multiple popups handling in the new popup solution. Handling multiple dialogs correctly Code style fixes One last ktlint problem Changed the approach, using an extension method Fixed double invocation of show() and target type dialog Removing unrelated changes Formatted some code Removing import wildcardpull/1456/head
parent
0eae43fe55
commit
33405e1e18
@ -0,0 +1,21 @@
|
||||
package org.isoron.uhabits.utils
|
||||
|
||||
import android.app.Dialog
|
||||
import androidx.fragment.app.DialogFragment
|
||||
import androidx.fragment.app.FragmentManager
|
||||
import java.lang.ref.WeakReference
|
||||
|
||||
var currentDialog: WeakReference<Dialog> = WeakReference(null)
|
||||
|
||||
fun Dialog.dismissCurrentAndShow() {
|
||||
currentDialog.get()?.dismiss()
|
||||
currentDialog = WeakReference(this)
|
||||
show()
|
||||
}
|
||||
|
||||
fun DialogFragment.dismissCurrentAndShow(fragmentManager: FragmentManager, tag: String) {
|
||||
currentDialog.get()?.dismiss()
|
||||
show(fragmentManager, tag)
|
||||
fragmentManager.executePendingTransactions()
|
||||
currentDialog = WeakReference(this.dialog)
|
||||
}
|
Loading…
Reference in new issue