pull/357/head
gedoor 4 years ago
parent d4db3109f5
commit 5036d15b84
  1. 10
      app/src/main/java/io/legado/app/utils/ContextExtensions.kt

@ -59,8 +59,10 @@ fun Context.getPrefString(@StringRes keyId: Int, defValue: String? = null) =
fun Context.putPrefString(key: String, value: String) = fun Context.putPrefString(key: String, value: String) =
defaultSharedPreferences.edit { putString(key, value) } defaultSharedPreferences.edit { putString(key, value) }
fun Context.getPrefStringSet(key: String, defValue: MutableSet<String>? = null) = fun Context.getPrefStringSet(
defaultSharedPreferences.getStringSet(key, defValue) key: String,
defValue: MutableSet<String>? = null
): MutableSet<String>? = defaultSharedPreferences.getStringSet(key, defValue)
fun Context.putPrefStringSet(key: String, value: MutableSet<String>) = fun Context.putPrefStringSet(key: String, value: MutableSet<String>) =
defaultSharedPreferences.edit { putStringSet(key, value) } defaultSharedPreferences.edit { putStringSet(key, value) }
@ -194,10 +196,10 @@ val Context.channel: String
get() { get() {
try { try {
val pm = packageManager val pm = packageManager
val appInfo = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA); val appInfo = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA)
return appInfo.metaData.getString("channel") ?: "" return appInfo.metaData.getString("channel") ?: ""
} catch (e: Exception) { } catch (e: Exception) {
e.printStackTrace(); e.printStackTrace()
} }
return "" return ""
} }

Loading…
Cancel
Save