diff --git a/README.md b/README.md index 20aa468..0876599 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,37 @@ -[![Release](https://jitpack.io/v/jitpack/android-example.svg)](https://jitpack.io/#rommansabbir/NetworkX) - ![NetworkX](https://user-images.githubusercontent.com/25950083/185731068-480fd969-f18d-439c-938a-6285a50c2be2.png) ---- +[![-----------------------------------------------------](https://raw.githubusercontent.com/andreasbm/readme/master/assets/lines/colored.png)](#getting-started-quick) + +

+ Maintained +

+ +

+ Maintained +

+ +

+ JitPack +

-## Documentation +

⚡ Latest Version: 4.1.0 | Change Logs 🔰

-### Installation +- NetworkX now works with both __Activity__ or __Application__ Scope (NetworkX lifecycle is bounded to `NetworkXLifecycle.Activity` or `NetworkXLifecycle.Application`) +- Introduced `SmartConfig` to replace old config [`NetworkXConfig` has been deprecated] +- New __API__ to initialize `NetworkX`, enabled smart refactoring to replace old __API__ with new one +- New __API__ [`NoInternetDialogV2.forceClose()`] added to close `Dialog` forcefully +- Added support for custom _Drawable_ to be shown in `NoInternetDialogV2` +- Several __Classes__, __APIs__ has been deprecated. +- Removed unused classes/packages +- Colorful Documentation 😂 -Step 1. Add the JitPack repository to your build file . +[![-----------------------------------------------------](https://raw.githubusercontent.com/andreasbm/readme/master/assets/lines/colored.png)](#getting-started-quick) + +

Installation

+ +## ➤ Step 1: + +Add the JitPack repository to your build file . ```gradle allprojects { @@ -18,96 +41,105 @@ Step 1. Add the JitPack repository to your build file . } ``` -Step 2. Add the dependency. +## ➤ Step 2: + +Add the dependency. ```gradle dependencies { - implementation 'com.github.rommansabbir:NetworkX:Tag' + implementation 'com.github.rommansabbir:NetworkX:4.1.0' } ``` ---- - -### Version available - -| Releases -| ------------- | -| 4.0.0 | - - -# Usages - -## Step 1: +## ➤ Step 3: Initialize `NetworkX` from your `Application.onCreate()` ```` + //Deprecated way val builder = NetworkXConfig.Builder() .withApplication(this) // You can disable speed meter if not required .withEnableSpeedMeter(true) .build() NetworkXProvider.enable(builder) + + //New smart way + NetworkXProvider.enable(SmartConfig(this, true, NetworkXLifecycle.Application)) ```` -## Step 2: +## ➤ Step 4: - To check Internet Connection status, simply call extension variable `isInternetConnected` or `isInternetConnectedLiveData` or `isInternetConnectedFlow`. ```` -isInternetConnectedFlow.collectLatest { - lifecycleScope.launch { - textView.text = "Internet connection status: $it" + isInternetConnectedFlow.collectLatest { + lifecycleScope.launch { + textView.text = "Internet connection status: $it" + } } - } ```` - To get connected network speed/last known speed [`LastKnownSpeed`] call extension variable `lastKnownSpeed` or `lastKnownSpeedLiveData` or `lastKnownSpeedFlow` ```` -lastKnownSpeed?.let { - textView2.text ="S-${it.speed}|T-${it.networkTypeNetwork}|SS-${it.simplifiedSpeed}" -} + lastKnownSpeed?.let { + textView2.text ="S-${it.speed}|T-${it.networkTypeNetwork}|SS-${it.simplifiedSpeed}" + } ```` - ## Notes: - - **NetworkX** (including **Speed Meter**) only works when the **Activity** is in state between **OnCreate()** to **onDestroy()**. - - To emit (**`MutableStateFlow`**) **Last Known Speed** or **Internet Connection Status**,required **`CoroutineScope`** works under a **`Dispatchers.IO`** context. - - The default value for **Internet Connection Status** is `false`. - - The default value for **LastKnownSpeed** is `NONE`. +[![-----------------------------------------------------](https://raw.githubusercontent.com/andreasbm/readme/master/assets/lines/colored.png)](#getting-started-quick) + ---- +

NoInternetDialogV2

-### How to show the **`NoInternetDialogV2`**? +- Show Dialog +```kotlin + NoInternetDialogV2( + activity = WeakReference(this@MainActivity), + title = "No Internet Bro", + message = "This is just a dummy message", + buttonTitle = "Okay", + isCancelable = true + ) { /* Button Presses */ } +``` +- Close Dialog (Forcefully) + +```kotlin + NoInternetDialogV2.forceClose() +``` +- Determine if the `NoInternetDialogV2` is currently visible or not. ```kotlin -NoInternetDialogV2( - activity = WeakReference(this@MainActivity), - title = "No Internet Bro", - message = "This is just a dummy message", - buttonTitle = "Okay", - isCancelable = true -) { /* Button Presses */ } + NoInternetDialogV2.isVisible ``` -* Also, you can determine if the `NoInternetDialogV2` is currently visible or not by calling this variable `NoInternetDialogV2.isVisible` which return an `Boolean`. +[![-----------------------------------------------------](https://raw.githubusercontent.com/andreasbm/readme/master/assets/lines/colored.png)](#getting-started-quick) + + +

Notes:

+ + - **NetworkX** (including **Speed Meter**) can work on both **Application** scope or **Activity** scope. If scope is **Activity**, NetworkX will *start/release* it's components based on _ActivityLifecycleCallback_ (**onCreate - onDestroy**). Else, it will *start* it's components only once and there will be no components *release* event. + - To emit (**`MutableStateFlow`**) **Last Known Speed** or **Internet Connection Status**,required **`CoroutineScope`** works under a **`Dispatchers.IO`** context. + - The default value for **Internet Connection Status** is `false`. + - The default value for **LastKnownSpeed** is `NONE`. + ---- +[![-----------------------------------------------------](https://raw.githubusercontent.com/andreasbm/readme/master/assets/lines/colored.png)](#getting-started-quick) -### Happy Coding.... +## Contact me ---- +✔ [LinkedIn](https://www.linkedin.com/in/rommansabbir/) -### Contact me +✔ [Website](https://rommansabbir.com) -[LinkedIn](https://www.linkedin.com/in/rommansabbir/) ---- +[![-----------------------------------------------------](https://raw.githubusercontent.com/andreasbm/readme/master/assets/lines/colored.png)](#getting-started-quick) ### License [Apache Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.html) ````html -Copyright (C) 2021 Romman Sabbir +Copyright (C) 2022 Romman Sabbir Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.