#34 Change use of deprecated NetworkInfo enhancement (#38)

* replace NetworkInto with the ConnectivityManager. Since this network validation is being done at repository level, I've had to add the network dependency on it's own AndroidManifest.

* moved network_state_permission from repository manifest to app's manifest.
removed wildcard imports.
now, network_info it's been provided and not the connectivity_manager
This commit is contained in:
Victor Vicari
2019-09-24 11:04:02 -03:00
committed by Melih Aksoy
parent 9aa7a5b25f
commit 8344e7f94b
3 changed files with 8 additions and 3 deletions

View File

@@ -4,6 +4,7 @@
package="com.melih.rocketscience"> package="com.melih.rocketscience">
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application <application
android:name=".App" android:name=".App"

View File

@@ -14,6 +14,10 @@ class CoreModule {
fun proivdeAppContext(app: Application): Context = app.applicationContext fun proivdeAppContext(app: Application): Context = app.applicationContext
@Provides @Provides
fun provideNetworkInfo(app: Application): NetworkInfo? = fun provideNetworkInfo(app: Application): NetworkInfo? {
(app.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager).activeNetworkInfo val connectivityManager =
app.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
return connectivityManager.activeNetworkInfo
}
} }

View File

@@ -1,2 +1,2 @@
<manifest package="com.melih.repository"/> <manifest package="com.melih.repository" />