2nd attempt to fix double unregistering receivers

This commit is contained in:
Mygod
2019-09-19 11:33:50 +08:00
parent add1c96d5c
commit 95ddd5c2d5
3 changed files with 9 additions and 2 deletions

View File

@@ -35,6 +35,12 @@ fun Long.toPluralInt(): Int {
return (this % 1000000000).toInt() + 1000000000
}
fun Context.ensureReceiverUnregistered(receiver: BroadcastReceiver) {
try {
unregisterReceiver(receiver)
} catch (_: IllegalArgumentException) { }
}
@SuppressLint("Recycle")
fun <T> useParcel(block: (Parcel) -> T) = Parcel.obtain().run {
try {