Skip to content

Refactor attempt #3 #339

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Oct 19, 2013
Merged

Refactor attempt #3 #339

merged 11 commits into from
Oct 19, 2013

Conversation

sweetlilmre
Copy link
Contributor

This is still a fairly large commit, I can't really get it much smaller than this, but I have tried to address your concerns as much as possible.

The major changes are generally removal of code that is no longer needed.

I have taken care to ensure that the function chains are called as they were previously to maintain backward compatibility. Additionally for the methods that I would have removed I have marked deprecated so that they can be removed at a later date.

The code has been tested using the sample application in a variety of scenarios and I have synced with your HEAD before this to ensure that I have tracked the latest changes.

Please let me know what you think.

- Rework of the handler hierarchy to support a single base class and remove instanceof checks.
- A full implementation of Cancel behaviour with granular cancellation time (downloads are now chunked so can be canceled before completion).
- Progress and retry notification
- Fixed some small stability issues (unhandled exception, connection issues on network switch).
- SyncHttpClient fixes to use any handler (all handlers can now be forced into sync mode)
- Cleanup of JsonHttpResponseHandler.java removing all superfluous helper methods

Ideally JsonHttpResponseHandler.java, TextHttpResponseHandler.java, BinaryHttpResponseHandler.java should be moved into the examples directory
Conflicts:
	library/src/com/loopj/android/http/JsonHttpResponseHandler.java
@ghost ghost assigned smarek Oct 18, 2013
@smarek
Copy link
Member

smarek commented Oct 18, 2013

This looks very nice @sweetlilmre , I'll add some inline comments where I see a boiling points.

responseHandler.sendResponseMessage(response);
}
} else {
throw new InterruptedException("makeRequest was interrupted");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see you removed throwing request interruption and so calling onFailed in handler subclass, how will this be handled now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The interruption check will cause a silent exit (as intended from cancelRequests with the mayInterruptIfRunning flag set)

For any other exceptions: they are caught in the base handler and wrapped as IOExceptions.

@smarek
Copy link
Member

smarek commented Oct 18, 2013

Really, just a few cosmetic changes, and I'll merge it. Well done !

sendFailureMessage(status.getStatusCode(), response.getAllHeaders(), new HttpResponseException(status.getStatusCode(), status.getReasonPhrase()), responseBody);
} else {
sendSuccessMessage(status.getStatusCode(), response.getAllHeaders(), responseBody);
byte[] getResponseData(HttpEntity entity) throws IOException {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see a lot of similar code in https://github.com/loopj/android-async-http/pull/339/files#diff-b7642d6783234c023a733a2f1dd10599R54
May this be merged, so it won't duplicate?

smarek added a commit that referenced this pull request Oct 19, 2013
@smarek smarek merged commit c5c4d6f into android-async-http:master Oct 19, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants