Merge branch 'master' into q-beta

This commit is contained in:
Mygod
2019-04-04 11:09:47 +08:00
11 changed files with 42 additions and 30 deletions

View File

@@ -6,6 +6,7 @@ import android.os.Build
import android.text.Spannable
import android.text.SpannableString
import android.text.SpannableStringBuilder
import android.view.MenuItem
import android.view.View
import android.widget.ImageView
import androidx.annotation.DrawableRes
@@ -94,6 +95,13 @@ fun Context.stopAndUnbind(connection: ServiceConnection) {
unbindService(connection)
}
var MenuItem.isNotGone: Boolean
get() = isVisible || isEnabled
set(value) {
isVisible = value
isEnabled = value
}
fun <K, V> MutableMap<K, V>.computeIfAbsentCompat(key: K, value: () -> V) = if (Build.VERSION.SDK_INT >= 24)
computeIfAbsent(key) { value() } else this[key] ?: value().also { put(key, it) }
fun <K, V> MutableMap<K, V>.putIfAbsentCompat(key: K, value: V) = if (Build.VERSION.SDK_INT >= 24)