Skip to content

Commit ab5ae25

Browse files
authored
Update README.md
1 parent 6c876dc commit ab5ae25

1 file changed

Lines changed: 109 additions & 1 deletion

File tree

README.md

Lines changed: 109 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,110 @@
11
# NetworkPro
2-
Simple library to handle network connections in different views
2+
Simple library to handle network connections in different views in just few lines of code. Primary goal of this library is to simplify the overall process in few lines of code. More options and customization available in code.
3+
4+
[![Watch the video](https://github.com/Periyanayagam/NetworkPro/blob/master/networkPro.gif)](https://github.com/Periyanayagam/NetworkPro/blob/master/networkPro.gif)
5+
6+
# Usage
7+
8+
### First and foremost in AndroidManifest file register broadcast receiver
9+
```
10+
<receiver
11+
android:name="com.perusudroid.networkchecker.broadcast.NetworkManager"
12+
android:enabled="true"
13+
android:exported="true">
14+
<intent-filter>
15+
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
16+
<action android:name="android.net.wifi.WIFI_STATE_CHANGED" />
17+
</intent-filter>
18+
</receiver>
19+
```
20+
21+
<b>Make sure to use permission</b>
22+
```
23+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
24+
<uses-permission android:name="android.permission.INTERNET" />
25+
```
26+
27+
<b>To handle network connections within activity</b>
28+
29+
```
30+
new NetworkManager.Builder()
31+
.callback(this) // INetworkListener methods will be trigged on network connection/disconnection
32+
.build();
33+
```
34+
35+
<b>To show toast message</b>
36+
```
37+
new NetworkManager.Builder()
38+
.showMessage() // show default toast message to user
39+
.build();
40+
```
41+
42+
43+
<b>To show toast with custom message</b>
44+
```
45+
new NetworkManager.Builder()
46+
.showCustomMessage(getString(R.string.tst_network_connected), getString(R.string.tst_netword_disconnected))
47+
.build();
48+
```
49+
50+
<b>To show snackbar</b>
51+
52+
```
53+
new NetworkManager.Builder()
54+
.showSnack(this) // show default snackbar message
55+
.build();
56+
```
57+
58+
<b>To show snackbar with custom message</b>
59+
```
60+
new NetworkManager.Builder()
61+
.showCustomSnack(this, getString(R.string.snk_network_connected), getString(R.string.snk_netword_disconnected), Color.WHITE, Color.BLACK, Color.RED, Color.GREEN)
62+
.build();
63+
```
64+
65+
<b>To show alert dialog</b>
66+
```
67+
new NetworkManager.Builder()
68+
.showAlert(this, this) // show default alert message
69+
.build();
70+
```
71+
72+
<b>To show alert dialog with custom message and actions</b>
73+
```
74+
new NetworkManager.Builder()
75+
.showCustomAlert(this, "Network has been disconnected", this) // show custom alert
76+
.build();
77+
```
78+
79+
80+
<b>To load activity with default message and action</b>
81+
```
82+
new NetworkManager.Builder()
83+
.loadPage() // load activity
84+
.build();
85+
```
86+
87+
88+
<b>To load activity with custom message and action</b>
89+
```
90+
new NetworkManager.Builder()
91+
.loadCustomPage(Constants.networkMsg.DISCONNECTED_PAGE, false, true) //load activity with custom message
92+
.build();
93+
```
94+
# Download
95+
96+
<b>Step 1. Add the JitPack repository to your build file</b>
97+
Add it in your root build.gradle at the end of repositories:
98+
99+
allprojects {
100+
repositories {
101+
...
102+
maven { url 'https://jitpack.io' }
103+
}
104+
}
105+
106+
<b>Step 2. Add the dependency</b>
107+
108+
dependencies {
109+
implementation 'com.github.Periyanayagam:NetworkPro:1.0'
110+
}

0 commit comments

Comments
 (0)