Skip to content

Commit 3b48a3d

Browse files
committed
Improve appearance of the README
1 parent 8e615fe commit 3b48a3d

1 file changed

Lines changed: 63 additions & 105 deletions

File tree

README.md

Lines changed: 63 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,33 @@
1-
# ProxerLibAndroid [![Release](https://jitpack.io/v/proxer/ProxerLibAndroid.svg)](https://jitpack.io/#proxer/ProxerLibAndroid) [![Release](https://circleci.com/gh/proxer/ProxerLibAndroid.svg?style=shield)](https://circleci.com/gh/proxer/ProxerLibAndroid) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/540bc78bb6d34b1eb88e7baaa4cc19df)](https://www.codacy.com/app/geesruben/ProxerLibAndroid?utm_source=github.com&utm_medium=referral&utm_content=proxer/ProxerLibAndroid&utm_campaign=Badge_Grade)
1+
# ProxerLibAndroid [![Release](https://jitpack.io/v/proxer/ProxerLibAndroid.svg)](https://jitpack.io/#proxer/ProxerLibAndroid) [![Release](https://circleci.com/gh/proxer/ProxerLibAndroid.svg?style=shield)](https://circleci.com/gh/proxer/ProxerLibAndroid) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/540bc78bb6d34b1eb88e7baaa4cc19df)](https://www.codacy.com/app/geesruben/ProxerLibAndroid?utm_source=github.com&utm_medium=referral&utm_content=proxer/ProxerLibAndroid&utm_campaign=Badge_Grade)
22

3-
### What is this?
3+
## What is this?
44

5-
This is an Android library, implementing the API of the
6-
[Proxer.me](https://proxer.me/) website. This is currently `v1`.
5+
This is an Android library, implementing the API of the [Proxer.me](https://proxer.me/) website. This is currently `v1`.
76

8-
### Table of contents
7+
## Table of contents
98

109
- [Including in your project](#including-in-your-project)
11-
- [Usage](#usage)
12-
- [Initialization](#initialization)
13-
- [Doing a request](#doing-a-request)
14-
- [Cancelling a request](#cancelling-a-request)
15-
- [Error handling](#error-handling)
16-
- [Images and non-API pages](#images-and-non-api-pages)
17-
- [Configuration](#configuration)
18-
- [More](#more)
19-
- [Architecture](#architecture)
10+
- [Usage](#usage)
11+
12+
- [Initialization](#initialization)
13+
- [Doing a request](#doing-a-request)
14+
- [Cancelling a request](#cancelling-a-request)
15+
- [Error handling](#error-handling)
16+
- [Images and non-API pages](#images-and-non-api-pages)
17+
- [Configuration](#configuration)
18+
- [More](#more)
19+
20+
- [Architecture](#architecture)
21+
2022
- [Organisation](#organisation)
21-
- [Experimental APIs](#experimental-apis)
22-
- [Extensions](#extensions)
23+
- [Experimental APIs](#experimental-apis)
24+
25+
- [Extensions](#extensions)
26+
2327
- [Dependencies](#dependencies)
2428
- [Contributions and contributors](#contributions-and-contributors)
2529

26-
### Including in your project
30+
## Including in your project
2731

2832
Add this to your project build.gradle:
2933

@@ -43,12 +47,11 @@ dependencies {
4347
}
4448
```
4549

46-
### Usage
50+
## Usage
4751

48-
##### Initialization
52+
### Initialization
4953

50-
All requests are done through the `ProxerConnection` class. You have to
51-
initialize it with the `ProxerConnection.Builder` before using.
54+
All requests are done through the `ProxerConnection` class. You have to initialize it with the `ProxerConnection.Builder` before using.
5255

5356
The construction looks like this:
5457

@@ -58,7 +61,7 @@ ProxerConnection proxerConnection = new ProxerConnection.Builder("yourApiKey", t
5861

5962
You can customize the connection which will be covered later.
6063

61-
The recommended usage is to use it as a Singleton in an `Application` subclass.
64+
The recommended usage is to use it as a Singleton in an `Application` subclass.<br>
6265
To do so, add an entry for your subclass in the `AndroidManifest`:
6366

6467
```xml
@@ -84,17 +87,15 @@ public class MainApplication extends Application {
8487
}
8588
```
8689

87-
This allows you to access the `ProxerConnection` in every part of your
88-
app like this:
90+
This allows you to access the `ProxerConnection` in every part of your app like this:
8991

9092
```java
9193
ProxerConnection connection = MainApplication.proxerConnection;
9294
```
9395

94-
##### Doing a request
96+
### Doing a request
9597

96-
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`.
9899

99100
A simple query for the latest News looks like this:
100101

@@ -113,27 +114,18 @@ proxerConnection.execute(new NewsRequest(0), // 0 is the first page
113114
});
114115
```
115116

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).
119118

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.
123120

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>
126122
Setting it looks like so:
127123

128124
```java
129125
NewsRequest request = new NewsRequest(0).withLimit(30);
130126
```
131127

132-
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`).
137129

138130
A synchronous query for the latest News looks like this:
139131

@@ -148,27 +140,21 @@ try {
148140
}
149141
```
150142

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).
154144

155-
##### Cancelling a request
145+
### Cancelling a request
156146

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:
159148

160149
```java
161150
ProxerCall call = proxerConnection.execute(...);
162151

163152
call.cancel();
164153
```
165154

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`).
169156

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>
172158
A simple example for an Activity, retrieving the latest News:
173159

174160
```java
@@ -204,10 +190,9 @@ public class NewsActivity extends AppCompatActivity {
204190
}
205191
```
206192

207-
##### Error handling
193+
### Error handling
208194

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.
211196

212197
Handling the Exception might look like this:
213198

@@ -259,25 +244,21 @@ private void handleProxerException(ProxerException exception) {
259244
}
260245
```
261246

262-
This example is not complete as there are many more possible errors which you
263-
can find in the `ProxerException` class.
247+
This example is not complete as there are many more possible errors which you can find in the `ProxerException` class.
264248

265-
In most cases it is enough (and much more easy) to show the error message to the
266-
user:
249+
In most cases it is enough (and much more easy) to show the error message to the user:
267250

268251
```java
269252
if (exception.getErrorCode() == ProxerException.PROXER) {
270253
Toast.makeText(getContext(), exception.getMessage(), Toast.LENGTH_SHORT).show();
271254
}
272255
```
273256

274-
##### Images and non-API pages
257+
### Images and non-API pages
275258

276-
You might want to load images for various entities or open a page which is not
277-
part of the API.
259+
You might want to load images for various entities or open a page which is not part of the API.
278260

279-
For this purpose there is a `ProxerUrlHolder` class, which provides methods to
280-
obtain various often needed Urls.
261+
For this purpose there is a `ProxerUrlHolder` class, which provides methods to obtain various often needed Urls.<br>
281262
One example is the Url of the image of a News:
282263

283264
```java
@@ -287,10 +268,9 @@ private String getUrlToNewsImage(News news) {
287268
}
288269
```
289270

290-
##### Configuration
271+
### Configuration
291272

292-
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>
294274
Here is an example with all available customizations:
295275

296276
```java
@@ -305,63 +285,41 @@ ProxerConnection proxerConnection = new ProxerConnection.Builder("yourApiKey", c
305285
.build();
306286
```
307287

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`.
311289

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.
314291

315292
The third line passes a custom `Moshi` instance.
316293

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.
319295

320-
##### More
296+
### More
321297

322-
You can find detailed JavaDoc
323-
[here](https://jitpack.io/com/github/proxer/ProxerLibAndroid/2.2.0/javadoc/).
298+
You can find detailed JavaDoc [here](https://jitpack.io/com/github/proxer/ProxerLibAndroid/2.2.0/javadoc/).
324299

325-
### Architecture
300+
## Architecture
326301

327-
##### Organisation
302+
### Organisation
328303

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.
333305

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.
336307

337-
##### Experimental APIs
308+
### Experimental APIs
338309

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.
343311

344-
### Extensions
312+
## Extensions
345313

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>
351315
Don't forget to do a Pull Request!
352316

353-
### Dependencies
317+
## Dependencies
354318

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.
363321

364-
### Contributions and contributors
322+
## Contributions and contributors
365323

366324
A guide for contribution can be found [here](.github/CONTRIBUTING.md).
367325

0 commit comments

Comments
 (0)