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
To do a Request, you have to construct one of the available `ProxerRequest`
97
-
subclasses and pass it to the `ProxerConnection`.
98
+
To do a Request, you have to construct one of the available `ProxerRequest` subclasses and pass it to the `ProxerConnection`.
98
99
99
100
A simple query for the latest News looks like this:
100
101
@@ -113,27 +114,18 @@ proxerConnection.execute(new NewsRequest(0), // 0 is the first page
113
114
});
114
115
```
115
116
116
-
As you can see, you have to pass a `ProxerRequest` subclass, a `ProxerCallback`
117
-
and a `ProxerErrorCallback`. The ProxerCallback always returns the specific
118
-
result entity (Or `null` for `POST` requests).
117
+
As you can see, you have to pass a `ProxerRequest` subclass, a `ProxerCallback` and a `ProxerErrorCallback`. The ProxerCallback always returns the specific result entity (Or `null` for `POST` requests).
119
118
120
-
Many requests are configurable through either their constructor if the
121
-
parameters are obligatory or through `withParameter` builder methods if the
122
-
parameters are not obligatory.
119
+
Many requests are configurable through either their constructor if the parameters are obligatory or through `withParameter` builder methods if the parameters are not obligatory.
123
120
124
-
The `NewsRequest` has an optional `limit` parameter to limit the amount of items
125
-
returned.
121
+
The `NewsRequest` has an optional `limit` parameter to limit the amount of items returned.<br>
As you have seen, you use the `execute` method for asynchronous requests with
133
-
callbacks. If you want to execute the request synchronous, you can use the
134
-
`executeSynchronized` method. This is useful if you want to manage the threading
135
-
yourself or if you are on a background thread already (e.g. `AsyncTask`,
136
-
`IntentService`).
128
+
As you have seen, you use the `execute` method for asynchronous requests with callbacks. If you want to execute the request synchronous, you can use the `executeSynchronized` method. This is useful if you want to manage the threading yourself or if you are on a background thread already (e.g. `AsyncTask`, `IntentService`).
137
129
138
130
A synchronous query for the latest News looks like this:
139
131
@@ -148,27 +140,21 @@ try {
148
140
}
149
141
```
150
142
151
-
One thing to note is that all results from `execute` are delivered on the main
152
-
thread for you so you can directly update the UI (Note: You still have to check
153
-
if your `View`s are available at that time).
143
+
One thing to note is that all results from `execute` are delivered on the main thread for you so you can directly update the UI (Note: You still have to check if your `View`s are available at that time).
154
144
155
-
#####Cancelling a request
145
+
### Cancelling a request
156
146
157
-
You might want to cancel a request, especially if using in the Android
158
-
lifecycle:
147
+
You might want to cancel a request, especially if using in the Android lifecycle:
159
148
160
149
```java
161
150
ProxerCall call = proxerConnection.execute(...);
162
151
163
152
call.cancel();
164
153
```
165
154
166
-
The `execute` method returns a `ProxerCall` object, which you can invoke
167
-
`cancel` on. Moreover it has methods for retrieving the current status of the
168
-
request (`isCancelled` and `isExecuted`).
155
+
The `execute` method returns a `ProxerCall` object, which you can invoke `cancel` on. Moreover it has methods for retrieving the current status of the request (`isCancelled` and `isExecuted`).
169
156
170
-
It is important to always cancel your requests if directly used in an `Activity`
171
-
or `Fragment`.
157
+
It is important to always cancel your requests if directly used in an `Activity` or `Fragment`.<br>
172
158
A simple example for an Activity, retrieving the latest News:
173
159
174
160
```java
@@ -204,10 +190,9 @@ public class NewsActivity extends AppCompatActivity {
204
190
}
205
191
```
206
192
207
-
#####Error handling
193
+
### Error handling
208
194
209
-
If a request fails, a ProxerException is thrown or passed to your callback.
210
-
This Exception contains useful information on what went wrong.
195
+
If a request fails, a ProxerException is thrown or passed to your callback. This Exception contains useful information on what went wrong.
The `ProxerConnection` allows for customization. The internally used libs are
293
-
plugable and you can specify some other arguments.
273
+
The `ProxerConnection` allows for customization. The internally used libs are plugable and you can specify some other arguments.<br>
294
274
Here is an example with all available customizations:
295
275
296
276
```java
@@ -305,63 +285,41 @@ ProxerConnection proxerConnection = new ProxerConnection.Builder("yourApiKey", c
305
285
.build();
306
286
```
307
287
308
-
The first line uses the alternate constructor, in which you pass a custom
309
-
`CookieJar` instead of a `Context`. The `Context` is only used to construct a
310
-
persistent `CookieJar` internally, based on `SharedPreferences`.
288
+
The first line uses the alternate constructor, in which you pass a custom `CookieJar` instead of a `Context`. The `Context` is only used to construct a persistent `CookieJar` internally, based on `SharedPreferences`.
311
289
312
-
The second line passes a custom `OkHttpClient`. Note that it has no effect to
313
-
set your `CookieJar` to it as that will be overridden.
290
+
The second line passes a custom `OkHttpClient`. Note that it has no effect to set your `CookieJar` to it as that will be overridden.
314
291
315
292
The third line passes a custom `Moshi` instance.
316
293
317
-
The last line enables cancelled request delivery. This is disabled by default,
318
-
meaning that your callbacks will not be called if an request was cancelled.
294
+
The last line enables cancelled request delivery. This is disabled by default, meaning that your callbacks will not be called if an request was cancelled.
You can find detailed JavaDoc [here](https://jitpack.io/com/github/proxer/ProxerLibAndroid/2.2.0/javadoc/).
324
299
325
-
###Architecture
300
+
## Architecture
326
301
327
-
#####Organisation
302
+
### Organisation
328
303
329
-
The actual REST API is organized in classes. This library tries to mirror those
330
-
as closely as possible. For each class there is a package with all requests in
331
-
the `connection` package. The `NewsRequest` for example is in the `notification`
332
-
package just as in the REST API.
304
+
The actual REST API is organized in classes. This library tries to mirror those as closely as possible. For each class there is a package with all requests in the `connection` package. The `NewsRequest` for example is in the `notification` package just as in the REST API.
333
305
334
-
[This page](https://proxer.me/wiki/Proxer_API/v1) contains more information
335
-
about the REST API.
306
+
[This page](https://proxer.me/wiki/Proxer_API/v1) contains more information about the REST API.
336
307
337
-
#####Experimental APIs
308
+
### Experimental APIs
338
309
339
-
In some versions there might be an `experimental` package. This package contains
340
-
requests or other features which *should* work, but are not documented and
341
-
officially supported. Note that those are potentially dangerous as they might
342
-
get removed without further notice.
310
+
In some versions there might be an `experimental` package. This package contains requests or other features which _should_ work, but are not documented and officially supported. Note that those are potentially dangerous as they might get removed without further notice.
343
311
344
-
###Extensions
312
+
## Extensions
345
313
346
-
You can easily write your own requests if this library does not provide a
347
-
request yet. To do so, have a look at the `entity`, `result` and `request`
348
-
packages for each API class. You have to define a `Entity`, a `ProxerResult`
349
-
subclass and a `ProxerRequest` subclass, each with an easy to implement
350
-
interface.
314
+
You can easily write your own requests if this library does not provide a request yet. To do so, have a look at the `entity`, `result` and `request` packages for each API class. You have to define a `Entity`, a `ProxerResult` subclass and a `ProxerRequest` subclass, each with an easy to implement interface.<br>
351
315
Don't forget to do a Pull Request!
352
316
353
-
###Dependencies
317
+
## Dependencies
354
318
355
-
This library highly relies on [OkHttp](http://square.github.io/okhttp/) by
356
-
[Square](https://github.com/square) for the network communication.
357
-
Moreover it uses
358
-
[Moshi](https://github.com/square/moshi) for response parsing,
359
-
[PersistentCookieJar](https://github.com/franmontiel/PersistentCookieJar) for
360
-
Cookie management and
361
-
[Android Support Annotations](http://tools.android.com/tech-docs/support-annotations)
362
-
to improve the code style and provide IDE support.
319
+
This library highly relies on [OkHttp](http://square.github.io/okhttp/) by [Square](https://github.com/square) for the network communication.<br>
320
+
Moreover it uses [Moshi](https://github.com/square/moshi) for response parsing, [PersistentCookieJar](https://github.com/franmontiel/PersistentCookieJar) for Cookie management and [Android Support Annotations](http://tools.android.com/tech-docs/support-annotations) to improve the code style and provide IDE support.
363
321
364
-
###Contributions and contributors
322
+
## Contributions and contributors
365
323
366
324
A guide for contribution can be found [here](.github/CONTRIBUTING.md).
0 commit comments