mirror of https://github.com/iSoron/uhabits.git
parent
e189d17fd5
commit
a767e433d2
@ -1,15 +0,0 @@
|
||||
package org.isoron.uhabits.activities.common.dialogs
|
||||
|
||||
import android.app.Dialog
|
||||
import java.lang.ref.WeakReference
|
||||
|
||||
class MultipleDialogsHandler {
|
||||
companion object {
|
||||
var currentDialog: WeakReference<Dialog> = WeakReference(null)
|
||||
|
||||
fun Dialog.dismissCurrent() {
|
||||
currentDialog.get()?.dismiss()
|
||||
currentDialog = WeakReference(this)
|
||||
}
|
||||
}
|
||||
}
|
@ -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