Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yusukeiwaki/android-helper
https://github.com/yusukeiwaki/android-helper
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/yusukeiwaki/android-helper
- Owner: YusukeIwaki
- Created: 2017-02-08T05:15:35.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-07-21T13:30:41.000Z (over 7 years ago)
- Last Synced: 2024-10-18T08:34:09.977Z (3 months ago)
- Language: Java
- Size: 87.9 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# [DEPRECATED!] android-helper
Some trivial helpers for Android.
## OkHttp3 Helpers
```
repositories {
maven { url 'https://jitpack.io' }
}dependencies {
compile 'io.reactivex.rxjava2:rxjava:2.x.x' // for using RxHttpClient
// or compile 'com.parse.bolts:bolts-tasks:1.4.0' if you use BoltsHttpClientcompile 'com.github.yusukeiwaki.android-helper:okhttp3_helper:0.0.0'
}
```### RxHttpClient
Just wrapping OkHttp asynchronous callback with `rx.Single`.
HTTP error statuses (401, 403, 404, 500, ...) are notified with `onSuccess` callback.#### example
```
Request req = new Request.Builder()
.url("http://www.yahoo.co.jp/")
.build();RxHttpClient client = new RxHttpClient(new OkHttpClient());
client.execute(req)
.filter(response -> response.isSuccessful())
.map(response -> response.body().string())
.subscribe(body -> {
TextView textView = (TextView) findViewById(R.id.text);
textView.setText(body);
});
```### BoltsHttpClient
Wrapping OkHttp asynchronous callback with `bolts.Task`.
Unlike RxHttpClient, HTTP error statuses are notified as `HttpError` callback.