{"action":"created","comment":{"url":"https://api.github.com/repos/edx/edx-app-android/pulls/comments/77976226","id":77976226,"diff_hunk":"@@ -27,16 +31,18 @@ public OfflineRequestInterceptor(Context context, int maxStaleTime){\n     }\n \n     @Override\n-    public void intercept(RequestInterceptor.RequestFacade request) {\n+    public Response intercept(Chain chain) throws IOException {\n+        final Request.Builder requestBuilder = chain.request().newBuilder();\n         if (isNetworkConnected()) {\n             //TODO? should we specify caching here?\n //            int maxAge = 60; // read from cache for 1 minute\n-//            request.addHeader(\"Cache-Control\", \"public, max-age=\" + maxAge);\n-            request.addHeader(\"Cache-Control\", \"public\");\n+//            builder.header((\"Cache-Control\", \"public, max-age=\" + maxAge);","path":"VideoLocker/src/main/java/org/edx/mobile/http/OfflineRequestInterceptor.java","position":null,"original_position":32,"commit_id":"adf0fffc33e127d83fd9509cb2ce991bb3c6aead","original_commit_id":"e3c59815ec9a4410e82ac8f809499d27ec662883","user":{"login":"1zaman","id":4244109,"avatar_url":"https://avatars.githubusercontent.com/u/4244109?v=3","gravatar_id":"","url":"https://api.github.com/users/1zaman","html_url":"https://github.com/1zaman","followers_url":"https://api.github.com/users/1zaman/followers","following_url":"https://api.github.com/users/1zaman/following{/other_user}","gists_url":"https://api.github.com/users/1zaman/gists{/gist_id}","starred_url":"https://api.github.com/users/1zaman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/1zaman/subscriptions","organizations_url":"https://api.github.com/users/1zaman/orgs","repos_url":"https://api.github.com/users/1zaman/repos","events_url":"https://api.github.com/users/1zaman/events{/privacy}","received_events_url":"https://api.github.com/users/1zaman/received_events","type":"User","site_admin":false},"body":"Variable name has been updated in commit c4b9f2bb455b9d612ca88aeb3b2d65576a356b5d.","created_at":"2016-09-08T09:47:57Z","updated_at":"2016-09-08T09:47:57Z","html_url":"https://github.com/edx/edx-app-android/pull/799#discussion_r77976226","pull_request_url":"https://api.github.com/repos/edx/edx-app-android/pulls/799","_links":{"self":{"href":"https://api.github.com/repos/edx/edx-app-android/pulls/comments/77976226"},"html":{"href":"https://github.com/edx/edx-app-android/pull/799#discussion_r77976226"},"pull_request":{"href":"https://api.github.com/repos/edx/edx-app-android/pulls/799"}}},"pull_request":{"url":"https://api.github.com/repos/edx/edx-app-android/pulls/799","id":80922731,"html_url":"https://github.com/edx/edx-app-android/pull/799","diff_url":"https://github.com/edx/edx-app-android/pull/799.diff","patch_url":"https://github.com/edx/edx-app-android/pull/799.patch","issue_url":"https://api.github.com/repos/edx/edx-app-android/issues/799","number":799,"state":"open","locked":false,"title":"Update to Retrofit 2","user":{"login":"1zaman","id":4244109,"avatar_url":"https://avatars.githubusercontent.com/u/4244109?v=3","gravatar_id":"","url":"https://api.github.com/users/1zaman","html_url":"https://github.com/1zaman","followers_url":"https://api.github.com/users/1zaman/followers","following_url":"https://api.github.com/users/1zaman/following{/other_user}","gists_url":"https://api.github.com/users/1zaman/gists{/gist_id}","starred_url":"https://api.github.com/users/1zaman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/1zaman/subscriptions","organizations_url":"https://api.github.com/users/1zaman/orgs","repos_url":"https://api.github.com/users/1zaman/repos","events_url":"https://api.github.com/users/1zaman/events{/privacy}","received_events_url":"https://api.github.com/users/1zaman/received_events","type":"User","site_admin":false},"body":"### Description\r\n\r\n[MA-2185][]\r\n\r\nThis pull request updates the Retrofit library from 1.9.0 to 2.1.0, which is currently the latest release version. The API has been changed in a few fundamental ways in version 2. The Retrofit converters have been moved off into separate library projects, so we're now importing the Gson converter as well. This also necessitated an update to Gson itself from 2.4 to 2.7 (the latest release version), as the converter uses new APIs that were introduced in Gson version 2.6.\r\n\r\nThe main change in Retrofit 2 was the joining of the synchronous and asynchronous APIs via the `Call` interface, which is what's returned from the API methods along with the generic type of the class representing the response body. Since all the methods already present an asynchronous API, the various `Task` subclasses created specially for each API call have been deleted in it's favor, except where multiple asynchronous operations needed to be performed in sequence (this could be done with RxJava once it's imported, without having to move everything in one thread or creating a large nested chain of callbacks). The encapsulating *API classes have also been removed as redundant where possible without undue inconvenience, as they defeat the simple expressivity that's the purpose of Retrofit. In cases where they passed specific parameters to the actual API methods in the *Service classes, there parameters have been added as part of the URL (where they can be resolved statically as constants).\r\n\r\nThe error handling is also changed in Retrofit 2. RetrofitError has been removed, and error codes returned by the server are delivered just like standard responses to the same callback method, to be checked and handled there manually. However, we don't have specific error responses documented, and we were using a generic handler for these along with all the other error scenarios. Nor do the specific callback implementations need access to the whole response data other than the converted body (though generic handlers may use this information to perform some actions based on the headers etc.).\r\n\r\nTherefore, generic base implementations of the new callback interface have been created that define abstract methods according to the old style, with all errors delivered to the failure callback method, and the extra data (the `Call` and `Response` objects) stripped. The `Callback` class in the http package does only this (for use in the new MVP framework currently being used in the profiles module, which was using a basic custom asynchronous executor and observer framework for it's HTTP calls), while the `ErrorHandlingCallback` class is a replacement of the functionality provided by the old `Task` framework that we were using (providing callbacks for starting and ending, and error messages).\r\n\r\nThere was also an existing base implementation of the Retrofit callback interface from version 1 named `RetroApiCallback`, which seems to have copied the logic from an old version of the base `Task` implementation, but since it needed a total redesign anyway, it was deleted (as I didn't like it's name).\r\n\r\nThe `HttpResponseStatusException` has been retained to serve it's original purpose, but the `HttpConnectivityException` class has been removed in favor of `IOException` (which is now the error that Retrofit delivers in the case of connectivity errors), along with the base `HttpException`, as there doesn't seem to be any concrete and realized benefit for having one base exception class for Retrofit errors.\r\n\r\nIt doesn't use weak references though, since that would have necessitated the listeners to be strongly referenced in the view class, or actually implemented by the main view (`Activity` or `Fragment`) class itself. The latter is what's done in the `Task` implementations in practice. However, that still doesn't help in the cases where it's extended to update the view (thus holding a reference to it), usually in the form of an anonymous inner subclass. Any generic solution to this\r\nwould be quite complex, and would have to be implemented at the base view level as well to provide proper loose coupling, and this doesn't seem to be a critical issue either (since the view is only retained temporarily in memory, and we don't seem to be that tightly constrained on it), so it's being deferred until such a time as the MVP framework is implemented throughout the app (which already handles this situation properly).\r\n\r\nThe `Interceptor` API has also been removed in Retrofit 2, and delegated to OkHttp, which also added an interceptors API as of version 2.2.0. Therefore all the Retrofit interceptors have now been converted to OkHttp interceptors. The offline interceptor has also been registered in the client that's returned by `OkHttpUtil`, based on a flag parameter that is passed to the get method.\r\n\r\n### Notes\r\n- I didn't realize that this would affect any existing tests, and my compiler didn't warn me until the last moment, so I'll resolve the errors in the tests later.\r\n\r\n### Reviewers\r\nIf you've been tagged for review, please check your corresponding box once you've given the :+1:.\r\n- [ ] Code review: @bguertin\r\n- [ ] Code review: @BenjiLee\r\n- [ ] Code review: @miankhalid\r\n- [x] Code review: @mdinino\r\n\r\n[MA-2185]: https://openedx.atlassian.net/browse/MA-2185","created_at":"2016-08-11T08:53:36Z","updated_at":"2016-09-08T09:47:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5cb00ae0a81d5b3926d49931a4d0b9ea31d5b7e9","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/edx/edx-app-android/pulls/799/commits","review_comments_url":"https://api.github.com/repos/edx/edx-app-android/pulls/799/comments","review_comment_url":"https://api.github.com/repos/edx/edx-app-android/pulls/comments{/number}","comments_url":"https://api.github.com/repos/edx/edx-app-android/issues/799/comments","statuses_url":"https://api.github.com/repos/edx/edx-app-android/statuses/adf0fffc33e127d83fd9509cb2ce991bb3c6aead","head":{"label":"edx:MA-2185","ref":"MA-2185","sha":"adf0fffc33e127d83fd9509cb2ce991bb3c6aead","user":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"repo":{"id":29251742,"name":"edx-app-android","full_name":"edx/edx-app-android","owner":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/edx/edx-app-android","description":"","fork":false,"url":"https://api.github.com/repos/edx/edx-app-android","forks_url":"https://api.github.com/repos/edx/edx-app-android/forks","keys_url":"https://api.github.com/repos/edx/edx-app-android/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/edx-app-android/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/edx-app-android/teams","hooks_url":"https://api.github.com/repos/edx/edx-app-android/hooks","issue_events_url":"https://api.github.com/repos/edx/edx-app-android/issues/events{/number}","events_url":"https://api.github.com/repos/edx/edx-app-android/events","assignees_url":"https://api.github.com/repos/edx/edx-app-android/assignees{/user}","branches_url":"https://api.github.com/repos/edx/edx-app-android/branches{/branch}","tags_url":"https://api.github.com/repos/edx/edx-app-android/tags","blobs_url":"https://api.github.com/repos/edx/edx-app-android/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/edx-app-android/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/edx-app-android/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/edx-app-android/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/edx-app-android/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/edx-app-android/languages","stargazers_url":"https://api.github.com/repos/edx/edx-app-android/stargazers","contributors_url":"https://api.github.com/repos/edx/edx-app-android/contributors","subscribers_url":"https://api.github.com/repos/edx/edx-app-android/subscribers","subscription_url":"https://api.github.com/repos/edx/edx-app-android/subscription","commits_url":"https://api.github.com/repos/edx/edx-app-android/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/edx-app-android/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/edx-app-android/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/edx-app-android/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx/edx-app-android/contents/{+path}","compare_url":"https://api.github.com/repos/edx/edx-app-android/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/edx-app-android/merges","archive_url":"https://api.github.com/repos/edx/edx-app-android/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/edx-app-android/downloads","issues_url":"https://api.github.com/repos/edx/edx-app-android/issues{/number}","pulls_url":"https://api.github.com/repos/edx/edx-app-android/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/edx-app-android/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/edx-app-android/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/edx-app-android/labels{/name}","releases_url":"https://api.github.com/repos/edx/edx-app-android/releases{/id}","deployments_url":"https://api.github.com/repos/edx/edx-app-android/deployments","created_at":"2015-01-14T15:49:47Z","updated_at":"2016-09-03T09:57:36Z","pushed_at":"2016-09-08T09:43:35Z","git_url":"git://github.com/edx/edx-app-android.git","ssh_url":"git@github.com:edx/edx-app-android.git","clone_url":"https://github.com/edx/edx-app-android.git","svn_url":"https://github.com/edx/edx-app-android","homepage":null,"size":25777,"stargazers_count":91,"watchers_count":91,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":98,"mirror_url":null,"open_issues_count":17,"forks":98,"open_issues":17,"watchers":91,"default_branch":"master"}},"base":{"label":"edx:master","ref":"master","sha":"39ee0c223a274268e3585a4c068ac3fb9064fdda","user":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"repo":{"id":29251742,"name":"edx-app-android","full_name":"edx/edx-app-android","owner":{"login":"edx","id":3179841,"avatar_url":"https://avatars.githubusercontent.com/u/3179841?v=3","gravatar_id":"","url":"https://api.github.com/users/edx","html_url":"https://github.com/edx","followers_url":"https://api.github.com/users/edx/followers","following_url":"https://api.github.com/users/edx/following{/other_user}","gists_url":"https://api.github.com/users/edx/gists{/gist_id}","starred_url":"https://api.github.com/users/edx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edx/subscriptions","organizations_url":"https://api.github.com/users/edx/orgs","repos_url":"https://api.github.com/users/edx/repos","events_url":"https://api.github.com/users/edx/events{/privacy}","received_events_url":"https://api.github.com/users/edx/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/edx/edx-app-android","description":"","fork":false,"url":"https://api.github.com/repos/edx/edx-app-android","forks_url":"https://api.github.com/repos/edx/edx-app-android/forks","keys_url":"https://api.github.com/repos/edx/edx-app-android/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edx/edx-app-android/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edx/edx-app-android/teams","hooks_url":"https://api.github.com/repos/edx/edx-app-android/hooks","issue_events_url":"https://api.github.com/repos/edx/edx-app-android/issues/events{/number}","events_url":"https://api.github.com/repos/edx/edx-app-android/events","assignees_url":"https://api.github.com/repos/edx/edx-app-android/assignees{/user}","branches_url":"https://api.github.com/repos/edx/edx-app-android/branches{/branch}","tags_url":"https://api.github.com/repos/edx/edx-app-android/tags","blobs_url":"https://api.github.com/repos/edx/edx-app-android/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edx/edx-app-android/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edx/edx-app-android/git/refs{/sha}","trees_url":"https://api.github.com/repos/edx/edx-app-android/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edx/edx-app-android/statuses/{sha}","languages_url":"https://api.github.com/repos/edx/edx-app-android/languages","stargazers_url":"https://api.github.com/repos/edx/edx-app-android/stargazers","contributors_url":"https://api.github.com/repos/edx/edx-app-android/contributors","subscribers_url":"https://api.github.com/repos/edx/edx-app-android/subscribers","subscription_url":"https://api.github.com/repos/edx/edx-app-android/subscription","commits_url":"https://api.github.com/repos/edx/edx-app-android/commits{/sha}","git_commits_url":"https://api.github.com/repos/edx/edx-app-android/git/commits{/sha}","comments_url":"https://api.github.com/repos/edx/edx-app-android/comments{/number}","issue_comment_url":"https://api.github.com/repos/edx/edx-app-android/issues/comments{/number}","contents_url":"https://api.github.com/repos/edx/edx-app-android/contents/{+path}","compare_url":"https://api.github.com/repos/edx/edx-app-android/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edx/edx-app-android/merges","archive_url":"https://api.github.com/repos/edx/edx-app-android/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edx/edx-app-android/downloads","issues_url":"https://api.github.com/repos/edx/edx-app-android/issues{/number}","pulls_url":"https://api.github.com/repos/edx/edx-app-android/pulls{/number}","milestones_url":"https://api.github.com/repos/edx/edx-app-android/milestones{/number}","notifications_url":"https://api.github.com/repos/edx/edx-app-android/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edx/edx-app-android/labels{/name}","releases_url":"https://api.github.com/repos/edx/edx-app-android/releases{/id}","deployments_url":"https://api.github.com/repos/edx/edx-app-android/deployments","created_at":"2015-01-14T15:49:47Z","updated_at":"2016-09-03T09:57:36Z","pushed_at":"2016-09-08T09:43:35Z","git_url":"git://github.com/edx/edx-app-android.git","ssh_url":"git@github.com:edx/edx-app-android.git","clone_url":"https://github.com/edx/edx-app-android.git","svn_url":"https://github.com/edx/edx-app-android","homepage":null,"size":25777,"stargazers_count":91,"watchers_count":91,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":98,"mirror_url":null,"open_issues_count":17,"forks":98,"open_issues":17,"watchers":91,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/edx/edx-app-android/pulls/799"},"html":{"href":"https://github.com/edx/edx-app-android/pull/799"},"issue":{"href":"https://api.github.com/repos/edx/edx-app-android/issues/799"},"comments":{"href":"https://api.github.com/repos/edx/edx-app-android/issues/799/comments"},"review_comments":{"href":"https://api.github.com/repos/edx/edx-app-android/pulls/799/comments"},"review_comment":{"href":"https://api.github.com/repos/edx/edx-app-android/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/edx/edx-app-android/pulls/799/commits"},"statuses":{"href":"https://api.github.com/repos/edx/edx-app-android/statuses/adf0fffc33e127d83fd9509cb2ce991bb3c6aead"}}}}
{"actor":{"display_login":"1zaman"}}