Handle offline mode in shelf

This commit is contained in:
Koitharu
2022-10-14 17:04:04 +03:00
parent 9b54ed6bc7
commit 74717e2b93
9 changed files with 170 additions and 19 deletions

View File

@@ -44,6 +44,14 @@ val Context.activityManager: ActivityManager?
val Context.connectivityManager: ConnectivityManager
get() = getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
val ConnectivityManager.isNetworkAvailable: Boolean
get() = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
activeNetwork != null
} else {
@Suppress("DEPRECATION")
activeNetworkInfo?.isConnectedOrConnecting == true
}
fun String.toUriOrNull() = if (isEmpty()) null else Uri.parse(this)
suspend fun CoroutineWorker.trySetForeground(): Boolean = runCatchingCancellable {