You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+18-5Lines changed: 18 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,20 @@
1
1
# AsyncHttpClient library
2
2
3
-
Lightweight async HTTP client based on[OkHttp](https://square.github.io/okhttp/). It tries to follow a similar API inspired by this [library](https://github.com/android-async-http/android-async-http)
3
+
This is a lightweight asynchronous HTTP client powered by[OkHttp](https://square.github.io/okhttp/) but with a significantly simplified and easier to use API design.
4
4
5
+
The goal of this library is to have an API that clearly and cleanly supports the following features:
6
+
7
+
* Asynchronous network requests without any need for manual thread handling
8
+
* Response `onSuccess` callbacks run on the mainthread (by default)
9
+
* Easy way to catch all errors and failures and handle them
10
+
* Easy pluggable Text, JSON, and Bitmap response handlers to parse the response
11
+
12
+
This client tries to follow a similar API inspired by this [older now deprecated android-async-http library](https://github.com/android-async-http/android-async-http).
5
13
6
14
## Setup
7
15
16
+
To use this library, add the following to your `.gradle` file:
3. Add any networking calls by leveraging the `AsyncHttpClient`
28
38
29
39
```java
30
-
31
40
AsyncHttpClient client = new AsyncHttpClient();
32
41
client.get("https://api.thecatapi.com/v1/images/search", new TextHttpResponseHandler() {
33
42
@Override
@@ -42,4 +51,8 @@ dependencies {
42
51
});
43
52
```
44
53
45
-
See [example calls](https://github.com/codepath/AsyncHttpClient/blob/master/example/src/main/java/com/codepath/example/TestActivity.java)
54
+
This example uses `TextHttpResponseHandler` which presents the response as raw text. We could use the `JsonHttpResponseHandler` instead to have the API response automatically parsed for us into JSON. See [other example calls here](https://github.com/codepath/AsyncHttpClient/blob/master/example/src/main/java/com/codepath/example/TestActivity.java).
55
+
56
+
## More documentation
57
+
58
+
For a more detailed usage, check out the [CodePath Async Http Client Guide](https://guides.codepath.com/android/Using-CodePath-Async-Http-Client)
0 commit comments