-
Notifications
You must be signed in to change notification settings - Fork 0
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 #1 from muhammadisa/version-1.0.0
Add documentation
- Loading branch information
Showing
3 changed files
with
104 additions
and
0 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
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)_ | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.