-
Notifications
You must be signed in to change notification settings - Fork 576
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Sync Surveys Dialog Compose (#2162)
- Loading branch information
1 parent
0e8e54c
commit a2f9acf
Showing
15 changed files
with
571 additions
and
110 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
core/common/src/main/java/com/mifos/core/common/utils/NetworkUtilsWrapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.mifos.core.common.utils | ||
|
||
import android.content.Context | ||
import android.net.ConnectivityManager | ||
import android.net.NetworkCapabilities | ||
import androidx.annotation.MainThread | ||
import dagger.hilt.android.qualifiers.ApplicationContext | ||
import javax.inject.Inject | ||
import javax.inject.Singleton | ||
|
||
@Singleton | ||
class NetworkUtilsWrapper @Inject constructor( | ||
@ApplicationContext private val context: Context | ||
) { | ||
|
||
@MainThread | ||
fun isNetworkConnected(): Boolean { | ||
val connectivityManager = | ||
context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager | ||
val network = connectivityManager.activeNetwork ?: return false | ||
val networkCapabilities = | ||
connectivityManager.getNetworkCapabilities(network) ?: return false | ||
|
||
return networkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.