diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..4fba025 --- /dev/null +++ b/README.md @@ -0,0 +1,98 @@ + + +

Welcome to Lifemark 👋

+

+ Version + + License: MIT + + documentation: yes + maintained: yes +

+ + +> 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 + + + +## 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)_ + diff --git a/lifemark-demo.gif b/lifemark-demo.gif new file mode 100644 index 0000000..b46f28e Binary files /dev/null and b/lifemark-demo.gif differ