-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from Teknasyon-Teknoloji/fix/network
Fix/network
- Loading branch information
Showing
10 changed files
with
109 additions
and
62 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#Fri Apr 09 09:33:39 TRT 2021 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip | ||
distributionPath=wrapper/dists | ||
zipStorePath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME |
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
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
23 changes: 23 additions & 0 deletions
23
livechat/src/main/java/com/desk360/base/util/ContextExtensions.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,23 @@ | ||
package com.desk360.base.util | ||
|
||
import android.content.Context | ||
import android.net.ConnectivityManager | ||
import android.net.NetworkCapabilities | ||
import android.os.Build | ||
|
||
fun Context.isNetworkAvailable(): Boolean { | ||
val connectivityManager = getSystemService(Context.CONNECTIVITY_SERVICE) as? ConnectivityManager? | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { | ||
val nw = connectivityManager?.activeNetwork ?: return false | ||
val actNw = connectivityManager.getNetworkCapabilities(nw) ?: return false | ||
return when { | ||
actNw.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) -> true | ||
actNw.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) -> true | ||
actNw.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET) -> true | ||
actNw.hasTransport(NetworkCapabilities.TRANSPORT_BLUETOOTH) -> true | ||
else -> false | ||
} | ||
} else { | ||
return connectivityManager?.activeNetworkInfo?.isConnected ?: false | ||
} | ||
} |
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