A library that observes your network status.

Update in progress ...

Download

Using gradle

In your root build.gradle at the end of repositories add

allprojects {
 	repositories {
	...
	maven { url 'https://jitpack.io' }
	}
}

Add the dependency

dependencies {
    implementation 'com.github.MosesWangira:moses.altruism.network:v1.0.3'
}

Using maven

Add the JitPack repository to your build file

<repositories>
	<repository>
		<id>jitpack.io</id>
		<url>https://jitpack.io</url>
	</repository>
</repositories>

Add the dependency

dependency>
	<groupId>com.github.MosesWangira</groupId>
	<artifactId>moses.altruism.network</artifactId>
	<version>v1.0.0</version>
</dependency>

How to use the library

extend NetworkState() class //for activity

Example

class MainActivity : NetworkState() {

}

extend NetworkStates() class //for fragments

Example

class HomeFragment : NetworkStates() {

}

Override the following functions to do what you want

onPositive - network active

onNegative - network inactive

Hint : You do not need to override the functions if you only want to observe the network

  override fun onPositive() {
        super.onPositive()
       
    }
    
  override fun onNegative() {
        super.onNegative()
    }

GitHub

https://github.com/MosesWangira/moses.altruism.network