|
|
@ -1,3 +1,5 @@ |
|
|
|
|
|
|
|
@file:Suppress("unused") |
|
|
|
|
|
|
|
|
|
|
|
package io.legado.app.utils |
|
|
|
package io.legado.app.utils |
|
|
|
|
|
|
|
|
|
|
|
import android.app.Activity |
|
|
|
import android.app.Activity |
|
|
@ -14,7 +16,8 @@ import org.jetbrains.anko.defaultSharedPreferences |
|
|
|
import org.jetbrains.anko.internals.AnkoInternals |
|
|
|
import org.jetbrains.anko.internals.AnkoInternals |
|
|
|
|
|
|
|
|
|
|
|
@Suppress("DEPRECATION") |
|
|
|
@Suppress("DEPRECATION") |
|
|
|
fun Fragment.isOnline() = requireContext().connectivityManager.activeNetworkInfo?.isConnected == true |
|
|
|
fun Fragment.isOnline() = |
|
|
|
|
|
|
|
requireContext().connectivityManager.activeNetworkInfo?.isConnected == true |
|
|
|
|
|
|
|
|
|
|
|
fun Fragment.getPrefBoolean(key: String, defValue: Boolean = false) = |
|
|
|
fun Fragment.getPrefBoolean(key: String, defValue: Boolean = false) = |
|
|
|
requireContext().defaultSharedPreferences.getBoolean(key, defValue) |
|
|
|
requireContext().defaultSharedPreferences.getBoolean(key, defValue) |
|
|
@ -40,7 +43,10 @@ fun Fragment.getPrefString(key: String, defValue: String? = null) = |
|
|
|
fun Fragment.putPrefString(key: String, value: String) = |
|
|
|
fun Fragment.putPrefString(key: String, value: String) = |
|
|
|
requireContext().defaultSharedPreferences.edit { putString(key, value) } |
|
|
|
requireContext().defaultSharedPreferences.edit { putString(key, value) } |
|
|
|
|
|
|
|
|
|
|
|
fun Fragment.getPrefStringSet(key: String, defValue: MutableSet<String>? = null) = |
|
|
|
fun Fragment.getPrefStringSet( |
|
|
|
|
|
|
|
key: String, |
|
|
|
|
|
|
|
defValue: MutableSet<String>? = null |
|
|
|
|
|
|
|
): MutableSet<String>? = |
|
|
|
requireContext().defaultSharedPreferences.getStringSet(key, defValue) |
|
|
|
requireContext().defaultSharedPreferences.getStringSet(key, defValue) |
|
|
|
|
|
|
|
|
|
|
|
fun Fragment.putPrefStringSet(key: String, value: MutableSet<String>) = |
|
|
|
fun Fragment.putPrefStringSet(key: String, value: MutableSet<String>) = |
|
|
@ -51,15 +57,23 @@ fun Fragment.removePref(key: String) = |
|
|
|
|
|
|
|
|
|
|
|
fun Fragment.getCompatColor(@ColorRes id: Int): Int = requireContext().getCompatColor(id) |
|
|
|
fun Fragment.getCompatColor(@ColorRes id: Int): Int = requireContext().getCompatColor(id) |
|
|
|
|
|
|
|
|
|
|
|
fun Fragment.getCompatDrawable(@DrawableRes id: Int): Drawable? = requireContext().getCompatDrawable(id) |
|
|
|
fun Fragment.getCompatDrawable(@DrawableRes id: Int): Drawable? = |
|
|
|
|
|
|
|
requireContext().getCompatDrawable(id) |
|
|
|
|
|
|
|
|
|
|
|
fun Fragment.getCompatColorStateList(@ColorRes id: Int): ColorStateList? = requireContext().getCompatColorStateList(id) |
|
|
|
fun Fragment.getCompatColorStateList(@ColorRes id: Int): ColorStateList? = |
|
|
|
|
|
|
|
requireContext().getCompatColorStateList(id) |
|
|
|
|
|
|
|
|
|
|
|
inline fun <reified T : Activity> Fragment.startActivity(vararg params: Pair<String, Any?>) = |
|
|
|
inline fun <reified T : Activity> Fragment.startActivity(vararg params: Pair<String, Any?>) = |
|
|
|
AnkoInternals.internalStartActivity(requireActivity(), T::class.java, params) |
|
|
|
AnkoInternals.internalStartActivity(requireActivity(), T::class.java, params) |
|
|
|
|
|
|
|
|
|
|
|
inline fun <reified T : Activity> Fragment.startActivityForResult(requestCode: Int, vararg params: Pair<String, Any?>) = |
|
|
|
inline fun <reified T : Activity> Fragment.startActivityForResult( |
|
|
|
startActivityForResult(AnkoInternals.createIntent(requireActivity(), T::class.java, params), requestCode) |
|
|
|
requestCode: Int, |
|
|
|
|
|
|
|
vararg params: Pair<String, Any?> |
|
|
|
|
|
|
|
) = |
|
|
|
|
|
|
|
startActivityForResult( |
|
|
|
|
|
|
|
AnkoInternals.createIntent(requireActivity(), T::class.java, params), |
|
|
|
|
|
|
|
requestCode |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
inline fun <reified T : Service> Fragment.startService(vararg params: Pair<String, Any?>) = |
|
|
|
inline fun <reified T : Service> Fragment.startService(vararg params: Pair<String, Any?>) = |
|
|
|
AnkoInternals.internalStartService(requireActivity(), T::class.java, params) |
|
|
|
AnkoInternals.internalStartService(requireActivity(), T::class.java, params) |
|
|
|