Skip to content

Commit

Permalink
Merge pull request #1 from muhammadisa/version-1.0.0
Browse files Browse the repository at this point in the history
Add documentation
  • Loading branch information
muhammadisa committed Jul 30, 2020
2 parents 217f102 + 316a155 commit 2079e52
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

98 changes: 98 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@


<h1 align="center">Welcome to Lifemark 👋</h1>
<p>
<img alt="Version" src="https://img.shields.io/badge/version-1.0.0-blue.svg?cacheSeconds=2592000" />
<a href="#" target="_blank">
<img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-yellow.svg" />
</a>
<img alt="documentation: yes" src="https://img.shields.io/badge/Documentation-Yes-green.svg" />
<img alt="maintained: yes" src="https://img.shields.io/badge/Maintained-Yes-green.svg" />
</p>


> Short introduction, this is very simple internet checker, you can execute a function when the device disconnected and otherwise, you can check is connected to the internet for once on execution.
## Demo

<img src="lifemark-demo.gif" width="250">

## Simple Usage

1. Forever Checking

```kotlin
val networkConnection = Lifemark(applicationContext)
networkConnection.ObservableNetworkCondition()
.observe(this@MainActivity, Observer { isConnected ->
if (isConnected) {
// do something when device connected to internet
} else {
// do something when device disconnected to internet
}
})
```

2. Checking for once execution

```kotlin
val networkConnection = Lifemark(applicationContext)
if(networkConnection.isNetworkConnected()){
// do something when device connected to internet
}else{
// do something when device disconnected to internet
}
```

##### Full Example

```kotlin
class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

val networkConnection = Lifemark(applicationContext)

// Forever Checking example
networkConnection.ObservableNetworkCondition()
.observe(this@MainActivity, Observer { isConnected ->
if (isConnected) {
disconnected_layout.visibility = View.GONE
connected_layout.visibility = View.VISIBLE
} else {
connected_layout.visibility = View.GONE
disconnected_layout.visibility = View.VISIBLE
}
})

if (networkConnection.isNetworkConnected()) {
// do something when device connected to internet
Log.d("INTERNET_CHECKER", "true")
} else {
// do something when device disconnected to internet
Log.d("INTERNET_CHECKER", "false")
}
}

}
```

## Author

👤 **Dimas Prasetya**

* Github: [@Dimas-Prasetya](https://github.com/Dimas-Prasetya)

👤 **Muhammad Isa Wijaya Kusuma**

* Github: [@muhammadisa](https://github.com/muhammadisa)

## Show your support

Give a ⭐️ if this project helped you!

***
_This README was generated with ❤️ by [readme-md-generator](https://github.com/kefranabg/readme-md-generator)_

Binary file added lifemark-demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2079e52

Please sign in to comment.