[
  {
    "path": ".gitignore",
    "content": "*.iml\n.gradle\n/local.properties\n/.idea/workspace.xml\n/.idea/libraries\n.DS_Store\n/build\n/captures\n/.idea\n"
  },
  {
    "path": ".travis.yml",
    "content": "language: android\n\nenv:\n  global:\n    - ADB_INSTALL_TIMEOUT=30\n# Using the new Container-Based Infrastructure\n    - sudo: false\n# Turning off caching to avoid caching Issues\n    - cache: false\n# Initiating clean Gradle output\n    - TERM=dumb\n# Giving even more memory to Gradle JVM\n    - GRADLE_OPTS=\"-Xmx2048m -XX:MaxPermSize=1024m\"\n\nandroid:\n  components:\n    - tools\n    - platform-tools\n    - build-tools-27.0.3\n    - android-27\n    - android-24\n    - android-23\n    - android-22\n    - extra-google-google_play_services\n    - extra-google-m2repository\n    - extra-android-m2repository\n    - sys-img-armeabi-v7a-android-22    \n\n# Emulator Management: Create, Start and Wait\nbefore_script:\n  - echo no | android create avd --force -n test -t android-22 --abi armeabi-v7a -c 32M\n  - emulator -avd test -no-audio -no-window &\n  - android-wait-for-emulator\n  - sleep 180\n  - adb devices\n  - adb shell input keyevent 82 &\n  \nscript:\n  - ./gradlew connectedAndroidTest\n"
  },
  {
    "path": "CHANGELOG.md",
    "content": "Change Log\n==========\n\nVersion 1.0.2 *(2018-07-10)*\n----------------------------\n\n * New: Add support for multiple file upload with same key\n * New: Add support for multi contentType in multipart\n * Bump OkHttp Version to 3.10.0\n * Bump other dependencies\n\n\nVersion 1.0.1 *(2017-12-20)*\n----------------------------\n\n * New: Add support for `Single`, `Completable`, `Flowable`, `Maybe` Observable\n * New: Add support for OPTIONS request\n * Bump OkHttp Version to 3.9.1\n * Bump other dependencies\n * New: Add support for specifying request method dynamically\n * New: Add API to check isRequestRunning\n * Fix: Add more than one values for one key in header and query\n * Merge pull requests\n\n\nVersion 1.0.0 *(2017-03-19)*\n----------------------------\n\n * Fix: Progress bug for large files download\n * Merge pull requests\n * New: Add new API\n * Bump OkHttp Version to 3.6.0\n * New: Add config options for BitmapDecode\n * New: Add Consumer Proguard\n\n\nVersion 0.4.0 *(2017-02-01)*\n----------------------------\n\n * New: RxJava2 Support [link](https://amitshekhariitbhu.github.io/Fast-Android-Networking/rxjava2_support.html)\n * New: Add Java Object directly in any request [link](https://amitshekhariitbhu.github.io/Fast-Android-Networking/post_request.html)\n * New: Java Object is supported for query parameter, headers also\n * Update OkHttp to 3.5.0\n * Fix: Allow all Map implementations\n * New: Add better logging of request\n * New: Get parsed error body [link](https://amitshekhariitbhu.github.io/Fast-Android-Networking/error_code_handling.html)\n * Merged pull requests\n\n\nVersion 0.3.0 *(2016-11-07)*\n----------------------------\n\n * Fix: Few minor bug fixes\n * Remove unwanted tags from manifest file\n\n\nVersion 0.2.0 *(2016-09-16)*\n----------------------------\n\n* New: Jackson Parser Support \n* New: Making Synchronous Request - [Check Here](https://amitshekhariitbhu.github.io/Fast-Android-Networking/synchronous_request.html)\n* New: setContentType(\"application/json; charset=utf-8\") in POST and Multipart request.\n* New: Getting OkHttpResponse in Response to access headers - [Check Here](https://amitshekhariitbhu.github.io/Fast-Android-Networking/getting_okhttpresponse.html)\n* Bug fixes : As always we are squashing bugs.\n* New: Few other features which are request by the fans of Fast Android Networking.\n\n\nVersion 0.1.0 *(2016-07-31)*\n----------------------------\n\n * New: RxJava Support For Fast-Android-Networking\n * New: Now RxJava can be used with Fast-Android-Networking\n * New: Operators like `flatMap`, `filter`, `map`, `zip`, etc can be used easily with Fast-Android-Networking.\n * New: Chaining of Requests can be done.\n * New: Requests can be bind with Activity-Lifecycle.\n * New: Java Object Parsing Support\n\n\nVersion 0.0.1 *(2016-06-03)*\n----------------------------\n\nInitial release."
  },
  {
    "path": "CONTRIBUTING.md",
    "content": "# Contributing\n\n1. Fork it!\n2. Checkout the development branch: `git checkout development`\n3. Create your feature branch: `git checkout -b my-new-feature`\n4. Add your changes to the index: `git add .`\n5. Commit your changes: `git commit -m 'Add some feature'`\n6. Push to the branch: `git push origin my-new-feature`\n7. Submit a pull request against the `development` branch\n"
  },
  {
    "path": "LICENSE",
    "content": "\n                                 Apache License\n                           Version 2.0, January 2004\n                        http://www.apache.org/licenses/\n\n   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n   1. Definitions.\n\n      \"License\" shall mean the terms and conditions for use, reproduction,\n      and distribution as defined by Sections 1 through 9 of this document.\n\n      \"Licensor\" shall mean the copyright owner or entity authorized by\n      the copyright owner that is granting the License.\n\n      \"Legal Entity\" shall mean the union of the acting entity and all\n      other entities that control, are controlled by, or are under common\n      control with that entity. For the purposes of this definition,\n      \"control\" means (i) the power, direct or indirect, to cause the\n      direction or management of such entity, whether by contract or\n      otherwise, or (ii) ownership of fifty percent (50%) or more of the\n      outstanding shares, or (iii) beneficial ownership of such entity.\n\n      \"You\" (or \"Your\") shall mean an individual or Legal Entity\n      exercising permissions granted by this License.\n\n      \"Source\" form shall mean the preferred form for making modifications,\n      including but not limited to software source code, documentation\n      source, and configuration files.\n\n      \"Object\" form shall mean any form resulting from mechanical\n      transformation or translation of a Source form, including but\n      not limited to compiled object code, generated documentation,\n      and conversions to other media types.\n\n      \"Work\" shall mean the work of authorship, whether in Source or\n      Object form, made available under the License, as indicated by a\n      copyright notice that is included in or attached to the work\n      (an example is provided in the Appendix below).\n\n      \"Derivative Works\" shall mean any work, whether in Source or Object\n      form, that is based on (or derived from) the Work and for which the\n      editorial revisions, annotations, elaborations, or other modifications\n      represent, as a whole, an original work of authorship. For the purposes\n      of this License, Derivative Works shall not include works that remain\n      separable from, or merely link (or bind by name) to the interfaces of,\n      the Work and Derivative Works thereof.\n\n      \"Contribution\" shall mean any work of authorship, including\n      the original version of the Work and any modifications or additions\n      to that Work or Derivative Works thereof, that is intentionally\n      submitted to Licensor for inclusion in the Work by the copyright owner\n      or by an individual or Legal Entity authorized to submit on behalf of\n      the copyright owner. For the purposes of this definition, \"submitted\"\n      means any form of electronic, verbal, or written communication sent\n      to the Licensor or its representatives, including but not limited to\n      communication on electronic mailing lists, source code control systems,\n      and issue tracking systems that are managed by, or on behalf of, the\n      Licensor for the purpose of discussing and improving the Work, but\n      excluding communication that is conspicuously marked or otherwise\n      designated in writing by the copyright owner as \"Not a Contribution.\"\n\n      \"Contributor\" shall mean Licensor and any individual or Legal Entity\n      on behalf of whom a Contribution has been received by Licensor and\n      subsequently incorporated within the Work.\n\n   2. Grant of Copyright License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      copyright license to reproduce, prepare Derivative Works of,\n      publicly display, publicly perform, sublicense, and distribute the\n      Work and such Derivative Works in Source or Object form.\n\n   3. Grant of Patent License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      (except as stated in this section) patent license to make, have made,\n      use, offer to sell, sell, import, and otherwise transfer the Work,\n      where such license applies only to those patent claims licensable\n      by such Contributor that are necessarily infringed by their\n      Contribution(s) alone or by combination of their Contribution(s)\n      with the Work to which such Contribution(s) was submitted. If You\n      institute patent litigation against any entity (including a\n      cross-claim or counterclaim in a lawsuit) alleging that the Work\n      or a Contribution incorporated within the Work constitutes direct\n      or contributory patent infringement, then any patent licenses\n      granted to You under this License for that Work shall terminate\n      as of the date such litigation is filed.\n\n   4. Redistribution. You may reproduce and distribute copies of the\n      Work or Derivative Works thereof in any medium, with or without\n      modifications, and in Source or Object form, provided that You\n      meet the following conditions:\n\n      (a) You must give any other recipients of the Work or\n          Derivative Works a copy of this License; and\n\n      (b) You must cause any modified files to carry prominent notices\n          stating that You changed the files; and\n\n      (c) You must retain, in the Source form of any Derivative Works\n          that You distribute, all copyright, patent, trademark, and\n          attribution notices from the Source form of the Work,\n          excluding those notices that do not pertain to any part of\n          the Derivative Works; and\n\n      (d) If the Work includes a \"NOTICE\" text file as part of its\n          distribution, then any Derivative Works that You distribute must\n          include a readable copy of the attribution notices contained\n          within such NOTICE file, excluding those notices that do not\n          pertain to any part of the Derivative Works, in at least one\n          of the following places: within a NOTICE text file distributed\n          as part of the Derivative Works; within the Source form or\n          documentation, if provided along with the Derivative Works; or,\n          within a display generated by the Derivative Works, if and\n          wherever such third-party notices normally appear. The contents\n          of the NOTICE file are for informational purposes only and\n          do not modify the License. You may add Your own attribution\n          notices within Derivative Works that You distribute, alongside\n          or as an addendum to the NOTICE text from the Work, provided\n          that such additional attribution notices cannot be construed\n          as modifying the License.\n\n      You may add Your own copyright statement to Your modifications and\n      may provide additional or different license terms and conditions\n      for use, reproduction, or distribution of Your modifications, or\n      for any such Derivative Works as a whole, provided Your use,\n      reproduction, and distribution of the Work otherwise complies with\n      the conditions stated in this License.\n\n   5. Submission of Contributions. Unless You explicitly state otherwise,\n      any Contribution intentionally submitted for inclusion in the Work\n      by You to the Licensor shall be under the terms and conditions of\n      this License, without any additional terms or conditions.\n      Notwithstanding the above, nothing herein shall supersede or modify\n      the terms of any separate license agreement you may have executed\n      with Licensor regarding such Contributions.\n\n   6. Trademarks. This License does not grant permission to use the trade\n      names, trademarks, service marks, or product names of the Licensor,\n      except as required for reasonable and customary use in describing the\n      origin of the Work and reproducing the content of the NOTICE file.\n\n   7. Disclaimer of Warranty. Unless required by applicable law or\n      agreed to in writing, Licensor provides the Work (and each\n      Contributor provides its Contributions) on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n      implied, including, without limitation, any warranties or conditions\n      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n      PARTICULAR PURPOSE. You are solely responsible for determining the\n      appropriateness of using or redistributing the Work and assume any\n      risks associated with Your exercise of permissions under this License.\n\n   8. Limitation of Liability. In no event and under no legal theory,\n      whether in tort (including negligence), contract, or otherwise,\n      unless required by applicable law (such as deliberate and grossly\n      negligent acts) or agreed to in writing, shall any Contributor be\n      liable to You for damages, including any direct, indirect, special,\n      incidental, or consequential damages of any character arising as a\n      result of this License or out of the use or inability to use the\n      Work (including but not limited to damages for loss of goodwill,\n      work stoppage, computer failure or malfunction, or any and all\n      other commercial damages or losses), even if such Contributor\n      has been advised of the possibility of such damages.\n\n   9. Accepting Warranty or Additional Liability. While redistributing\n      the Work or Derivative Works thereof, You may choose to offer,\n      and charge a fee for, acceptance of support, warranty, indemnity,\n      or other liability obligations and/or rights consistent with this\n      License. However, in accepting such obligations, You may act only\n      on Your own behalf and on Your sole responsibility, not on behalf\n      of any other Contributor, and only if You agree to indemnify,\n      defend, and hold each Contributor harmless for any liability\n      incurred by, or claims asserted against, such Contributor by reason\n      of your accepting any such warranty or additional liability.\n\n   END OF TERMS AND CONDITIONS\n\n   APPENDIX: How to apply the Apache License to your work.\n\n      To apply the Apache License to your work, attach the following\n      boilerplate notice, with the fields enclosed by brackets \"[]\"\n      replaced with your own identifying information. (Don't include\n      the brackets!)  The text should be enclosed in the appropriate\n      comment syntax for the file format. We also recommend that a\n      file or class name and description of purpose be included on the\n      same \"printed page\" as the copyright notice for easier\n      identification within third-party archives.\n\n   Copyright [yyyy] [name of copyright owner]\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License."
  },
  {
    "path": "README.md",
    "content": "<img src=https://raw.githubusercontent.com/amitshekhariitbhu/Fast-Android-Networking/master/assets/androidnetworking.png >\n\n# Fast Android Networking Library\n\n### About Fast Android Networking Library\n\nFast Android Networking Library is a powerful library for doing any type of networking in Android applications which is made on top of [OkHttp Networking Layer](http://square.github.io/okhttp/).\n\nFast Android Networking Library takes care of each and everything. So you don't have to do anything, just make request and listen for the response.\n\n### Why use Fast Android Networking ?\n* Recent removal of HttpClient in Android Marshmallow(Android M) made other networking libraries obsolete.\n* No other single library does each and everything like making request, downloading any type of file, uploading file, loading\n  image from network in ImageView, etc. There are some libraries but they are outdated.\n* No other library provides simple interface for doing all types of things in networking like setting priority, cancelling, etc.\n* As it uses [Okio](https://github.com/square/okio) , No more GC overhead in android applications.\n  [Okio](https://github.com/square/okio) is made to handle GC overhead while allocating memory.\n  [Okio](https://github.com/square/okio) does some clever things to save CPU and memory.\n* It uses [OkHttp](http://square.github.io/okhttp/) , more importantly it supports HTTP/2.  \n\n## About me\n\nHi, I am Amit Shekhar, Founder @ [Outcome School](https://outcomeschool.com) • IIT 2010-14 • I have taught and mentored many developers, and their efforts landed them high-paying tech jobs, helped many tech companies in solving their unique problems, and created many open-source libraries being used by top companies. I am passionate about sharing knowledge through open-source, blogs, and videos.\n\n### Follow Amit Shekhar\n\n- [X/Twitter](https://twitter.com/amitiitbhu)\n- [LinkedIn](https://www.linkedin.com/in/amit-shekhar-iitbhu)\n- [GitHub](https://github.com/amitshekhariitbhu)\n\n### Follow Outcome School\n\n- [YouTube](https://youtube.com/@OutcomeSchool)\n- [X/Twitter](https://x.com/outcome_school)\n- [LinkedIn](https://www.linkedin.com/company/outcomeschool)\n- [GitHub](http://github.com/OutcomeSchool)\n\n## I teach at Outcome School\n\n- [AI and Machine Learning](https://outcomeschool.com/program/ai-and-machine-learning)\n- [Android](https://outcomeschool.com/program/android)\n\nJoin Outcome School and get a high-paying tech job: [Outcome School](https://outcomeschool.com)\n\n## [Outcome School Blog](https://outcomeschool.com/blog) - High-quality content to learn Android concepts.\n\n### RxJava2 Support, [check here](https://amitshekhariitbhu.github.io/Fast-Android-Networking/rxjava2_support.html).\n\n### Find this project useful ? :heart:\n* Support it by clicking the :star: button on the upper right of this page. :v:\n\nFor full details, visit the documentation on our web site :\n\n<a href=\"https://amitshekhariitbhu.github.io/Fast-Android-Networking\" target=\"_blank\"><img src=\"https://raw.githubusercontent.com/amitshekhariitbhu/Fast-Android-Networking/master/assets/get_started.png\" width=\"150\" height=\"42\"/></a>\n\n## Requirements\n\nFast Android Networking Library can be included in any Android application. \n\nFast Android Networking Library supports Android 2.3 (Gingerbread) and later. \n\n## Using Fast Android Networking Library in your application\n\nAdd this in your `settings.gradle`:\n```groovy\nmaven { url 'https://jitpack.io' }\n```\n\nIf you are using `settings.gradle.kts`, add the following:\n```kotlin\nmaven { setUrl(\"https://jitpack.io\") }\n```\n\nAdd this in your `build.gradle`\n```groovy\nimplementation 'com.github.amitshekhariitbhu.Fast-Android-Networking:android-networking:1.0.4'\n```\n\nIf you are using `build.gradle.kts`, add the following:\n```kotlin\nimplementation(\"com.github.amitshekhariitbhu.Fast-Android-Networking:android-networking:1.0.4\")\n```\n\nDo not forget to add internet permission in manifest if already not present\n```xml\n<uses-permission android:name=\"android.permission.INTERNET\" />\n```\nThen initialize it in onCreate() Method of application class :\n```java\nAndroidNetworking.initialize(getApplicationContext());\n```\nInitializing it with some customization , as it uses [OkHttp](http://square.github.io/okhttp/) as networking layer, you can pass custom okHttpClient while initializing it.\n```java\n// Adding an Network Interceptor for Debugging purpose :\nOkHttpClient okHttpClient = new OkHttpClient() .newBuilder()\n                        .addNetworkInterceptor(new StethoInterceptor())\n                        .build();\nAndroidNetworking.initialize(getApplicationContext(),okHttpClient);                        \n```\n\nUsing the Fast Android Networking with Jackson Parser\n\nAdd this in your `build.gradle`\n```groovy\nimplementation 'com.github.amitshekhariitbhu.Fast-Android-Networking:jackson-android-networking:1.0.4'\n```\n\nIf you are using `build.gradle.kts`, add the following:\n```kotlin\nimplementation(\"com.github.amitshekhariitbhu.Fast-Android-Networking:jackson-android-networking:1.0.4\")\n```\n\n```java\n// Then set the JacksonParserFactory like below\nAndroidNetworking.setParserFactory(new JacksonParserFactory());\n```\n\nUsing the Fast Android Networking with RxJava2\n\nAdd this in your `build.gradle`\n```groovy\nimplementation 'com.github.amitshekhariitbhu.Fast-Android-Networking:rx2-android-networking:1.0.4'\n```\n\nIf you are using `build.gradle.kts`, add the following:\n```kotlin\nimplementation(\"com.github.amitshekhariitbhu.Fast-Android-Networking:rx2-android-networking:1.0.4\")\n```\n\nUsing the Fast Android Networking with RxJava\n\nAdd this in your `build.gradle`\n```groovy\nimplementation 'com.github.amitshekhariitbhu.Fast-Android-Networking:rx-android-networking:1.0.4'\n```\n\nIf you are using `build.gradle.kts`, add the following:\n```kotlin\nimplementation(\"com.github.amitshekhariitbhu.Fast-Android-Networking:rx-android-networking:1.0.4\")\n```\n\n### Making a GET Request\n```java\nAndroidNetworking.get(\"https://fierce-cove-29863.herokuapp.com/getAllUsers/{pageNumber}\")\n                 .addPathParameter(\"pageNumber\", \"0\")\n                 .addQueryParameter(\"limit\", \"3\")\n                 .addHeaders(\"token\", \"1234\")\n                 .setTag(\"test\")\n                 .setPriority(Priority.LOW)\n                 .build()\n                 .getAsJSONArray(new JSONArrayRequestListener() {\n                    @Override\n                    public void onResponse(JSONArray response) {\n                      // do anything with response\n                    }\n                    @Override\n                    public void onError(ANError error) {\n                      // handle error\n                    }\n                });                \n```\n### Making a POST Request\n```java\nAndroidNetworking.post(\"https://fierce-cove-29863.herokuapp.com/createAnUser\")\n                 .addBodyParameter(\"firstname\", \"Amit\")\n                 .addBodyParameter(\"lastname\", \"Shekhar\")\n                 .setTag(\"test\")\n                 .setPriority(Priority.MEDIUM)\n                 .build()\n                 .getAsJSONObject(new JSONObjectRequestListener() {\n                    @Override\n                    public void onResponse(JSONObject response) {\n                      // do anything with response\n                    }\n                    @Override\n                    public void onError(ANError error) {\n                      // handle error\n                    }\n                });\n```\nYou can also post java object, json, file, etc in POST request like this.\n```java\nUser user = new User();\nuser.firstname = \"Amit\";\nuser.lastname = \"Shekhar\";\n\nAndroidNetworking.post(\"https://fierce-cove-29863.herokuapp.com/createUser\")\n                 .addBodyParameter(user) // posting java object\n                 .setTag(\"test\")\n                 .setPriority(Priority.MEDIUM)\n                 .build()\n                 .getAsJSONArray(new JSONArrayRequestListener() {\n                    @Override\n                    public void onResponse(JSONArray response) {\n                      // do anything with response\n                    }\n                    @Override\n                    public void onError(ANError error) {\n                      // handle error\n                    }\n                });\n\n\nJSONObject jsonObject = new JSONObject();\ntry {\n    jsonObject.put(\"firstname\", \"Amit\");\n    jsonObject.put(\"lastname\", \"Shekhar\");\n} catch (JSONException e) {\n  e.printStackTrace();\n}\n       \nAndroidNetworking.post(\"https://fierce-cove-29863.herokuapp.com/createUser\")\n                 .addJSONObjectBody(jsonObject) // posting json\n                 .setTag(\"test\")\n                 .setPriority(Priority.MEDIUM)\n                 .build()\n                 .getAsJSONArray(new JSONArrayRequestListener() {\n                    @Override\n                    public void onResponse(JSONArray response) {\n                      // do anything with response\n                    }\n                    @Override\n                    public void onError(ANError error) {\n                      // handle error\n                    }\n                });\n                \nAndroidNetworking.post(\"https://fierce-cove-29863.herokuapp.com/postFile\")\n                 .addFileBody(file) // posting any type of file\n                 .setTag(\"test\")\n                 .setPriority(Priority.MEDIUM)\n                 .build()\n                 .getAsJSONObject(new JSONObjectRequestListener() {\n                    @Override\n                    public void onResponse(JSONObject response) {\n                      // do anything with response\n                    }\n                    @Override\n                    public void onError(ANError error) {\n                      // handle error\n                    }\n                });               \n```\n\n### Using it with your own JAVA Object - JSON Parser\n```java\n/*--------------Example One -> Getting the userList----------------*/\nAndroidNetworking.get(\"https://fierce-cove-29863.herokuapp.com/getAllUsers/{pageNumber}\")\n                .addPathParameter(\"pageNumber\", \"0\")\n                .addQueryParameter(\"limit\", \"3\")\n                .setTag(this)\n                .setPriority(Priority.LOW)\n                .build()\n                .getAsObjectList(User.class, new ParsedRequestListener<List<User>>() {\n                    @Override\n                    public void onResponse(List<User> users) {\n                      // do anything with response\n                      Log.d(TAG, \"userList size : \" + users.size());\n                      for (User user : users) {\n                        Log.d(TAG, \"id : \" + user.id);\n                        Log.d(TAG, \"firstname : \" + user.firstname);\n                        Log.d(TAG, \"lastname : \" + user.lastname);\n                      }\n                    }\n                    @Override\n                    public void onError(ANError anError) {\n                     // handle error\n                    }\n                });\n/*--------------Example Two -> Getting an user----------------*/\nAndroidNetworking.get(\"https://fierce-cove-29863.herokuapp.com/getAnUserDetail/{userId}\")\n                .addPathParameter(\"userId\", \"1\")\n                .setTag(this)\n                .setPriority(Priority.LOW)\n                .build()\n                .getAsObject(User.class, new ParsedRequestListener<User>() {\n                     @Override\n                     public void onResponse(User user) {\n                        // do anything with response\n                        Log.d(TAG, \"id : \" + user.id);\n                        Log.d(TAG, \"firstname : \" + user.firstname);\n                        Log.d(TAG, \"lastname : \" + user.lastname);\n                     }\n                     @Override\n                     public void onError(ANError anError) {\n                        // handle error\n                     }\n                 }); \n/*-- Note : YourObject.class, getAsObject and getAsObjectList are important here --*/              \n```\n\n### Downloading a file from server\n```java\nAndroidNetworking.download(url,dirPath,fileName)\n                 .setTag(\"downloadTest\")\n                 .setPriority(Priority.MEDIUM)\n                 .build()\n                 .setDownloadProgressListener(new DownloadProgressListener() {\n                    @Override\n                    public void onProgress(long bytesDownloaded, long totalBytes) {\n                      // do anything with progress  \n                    }\n                 })\n                 .startDownload(new DownloadListener() {\n                    @Override\n                    public void onDownloadComplete() {\n                      // do anything after completion\n                    }\n                    @Override\n                    public void onError(ANError error) {\n                      // handle error    \n                    }\n                });                 \n```\n### Uploading a file to server\n```java\nAndroidNetworking.upload(url)\n                 .addMultipartFile(\"image\",file)    \n                 .addMultipartParameter(\"key\",\"value\")\n                 .setTag(\"uploadTest\")\n                 .setPriority(Priority.HIGH)\n                 .build()\n                 .setUploadProgressListener(new UploadProgressListener() {\n                    @Override\n                    public void onProgress(long bytesUploaded, long totalBytes) {\n                      // do anything with progress \n                    }\n                 })\n                 .getAsJSONObject(new JSONObjectRequestListener() {\n                    @Override\n                    public void onResponse(JSONObject response) {\n                      // do anything with response                \n                    }\n                    @Override\n                    public void onError(ANError error) {\n                      // handle error \n                    }\n                 }); \n```\n\n### Getting Response and completion in an another thread executor \n(Note : Error and Progress will always be returned in main thread of application)\n```java\nAndroidNetworking.upload(url)\n                 .addMultipartFile(\"image\",file)  \n                 .addMultipartParameter(\"key\",\"value\")  \n                 .setTag(\"uploadTest\")\n                 .setPriority(Priority.HIGH)\n                 .build()\n                 .setExecutor(Executors.newSingleThreadExecutor()) // setting an executor to get response or completion on that executor thread\n                 .setUploadProgressListener(new UploadProgressListener() {\n                    @Override\n                    public void onProgress(long bytesUploaded, long totalBytes) {\n                      // do anything with progress \n                    }\n                 })\n                 .getAsJSONObject(new JSONObjectRequestListener() {\n                    @Override\n                    public void onResponse(JSONObject response) {\n                      // below code will be executed in the executor provided\n                      // do anything with response                \n                    }\n                    @Override\n                    public void onError(ANError error) {\n                      // handle error \n                    }\n                 }); \n```\n### Setting a Percentage Threshold For Not Cancelling the request if it has completed the given threshold\n```java\nAndroidNetworking.download(url,dirPath,fileName)\n                 .setTag(\"downloadTest\")\n                 .setPriority(Priority.MEDIUM)\n                 .setPercentageThresholdForCancelling(50) // even if at the time of cancelling it will not cancel if 50% \n                 .build()                                 // downloading is done.But can be cancalled with forceCancel.\n                 .setDownloadProgressListener(new DownloadProgressListener() {\n                    @Override\n                    public void onProgress(long bytesDownloaded, long totalBytes) {\n                      // do anything with progress  \n                    }\n                 })\n                 .startDownload(new DownloadListener() {\n                    @Override\n                    public void onDownloadComplete() {\n                      // do anything after completion\n                    }\n                    @Override\n                    public void onError(ANError error) {\n                      // handle error    \n                    }\n                });   \n```\n### Cancelling a request.\nAny request with a given tag can be cancelled. Just do like this.\n```java\nAndroidNetworking.cancel(\"tag\"); // All the requests with the given tag will be cancelled.\nAndroidNetworking.forceCancel(\"tag\");  // All the requests with the given tag will be cancelled , even if any percent threshold is\n                                       // set , it will be cancelled forcefully. \nAndroidNetworking.cancelAll(); // All the requests will be cancelled.  \nAndroidNetworking.forceCancelAll(); // All the requests will be cancelled , even if any percent threshold is\n                               // set , it will be cancelled forcefully.                           \n```\n### Loading image from network into ImageView\n```xml\n      <com.androidnetworking.widget.ANImageView\n          android:id=\"@+id/imageView\"\n          android:layout_width=\"100dp\"\n          android:layout_height=\"100dp\"\n          android:layout_gravity=\"center\" />\n          \n      imageView.setDefaultImageResId(R.drawable.default);\n      imageView.setErrorImageResId(R.drawable.error);\n      imageView.setImageUrl(imageUrl);          \n```\n### Getting Bitmap from url with some specified parameters\n```java\nAndroidNetworking.get(imageUrl)\n                 .setTag(\"imageRequestTag\")\n                 .setPriority(Priority.MEDIUM)\n                 .setBitmapMaxHeight(100)\n                 .setBitmapMaxWidth(100)\n                 .setBitmapConfig(Bitmap.Config.ARGB_8888)\n                 .build()\n                 .getAsBitmap(new BitmapRequestListener() {\n                    @Override\n                    public void onResponse(Bitmap bitmap) {\n                    // do anything with bitmap\n                    }\n                    @Override\n                    public void onError(ANError error) {\n                      // handle error\n                    }\n                });\n```\n### Error Code Handling\n```java\npublic void onError(ANError error) {\n   if (error.getErrorCode() != 0) {\n        // received error from server\n        // error.getErrorCode() - the error code from server\n        // error.getErrorBody() - the error body from server\n        // error.getErrorDetail() - just an error detail\n        Log.d(TAG, \"onError errorCode : \" + error.getErrorCode());\n        Log.d(TAG, \"onError errorBody : \" + error.getErrorBody());\n        Log.d(TAG, \"onError errorDetail : \" + error.getErrorDetail());\n        // get parsed error object (If ApiError is your class)\n        ApiError apiError = error.getErrorAsObject(ApiError.class);\n   } else {\n        // error.getErrorDetail() : connectionError, parseError, requestCancelledError\n        Log.d(TAG, \"onError errorDetail : \" + error.getErrorDetail());\n   }\n}\n```\n### Remove Bitmap from cache or clear cache\n```java\nAndroidNetworking.evictBitmap(key); // remove a bitmap with key from LruCache\nAndroidNetworking.evictAllBitmap(); // clear LruCache\n```\n### Prefetch a request (so that it can return from cache when required at instant)\n```java\nAndroidNetworking.get(\"https://fierce-cove-29863.herokuapp.com/getAllUsers/{pageNumber}\")\n                .addPathParameter(\"pageNumber\", \"0\")\n                .addQueryParameter(\"limit\", \"30\")\n                .setTag(this)\n                .setPriority(Priority.LOW)\n                .build()\n                .prefetch();\n```\n### Customizing OkHttpClient for a particular request\n```java\nOkHttpClient okHttpClient = new OkHttpClient().newBuilder()\n                .addInterceptor(new GzipRequestInterceptor())\n                .build();\n                \nAndroidNetworking.get(\"https://fierce-cove-29863.herokuapp.com/getAllUsers/{pageNumber}\")\n                 .addPathParameter(\"pageNumber\", \"0\")\n                 .addQueryParameter(\"limit\", \"3\")\n                 .addHeaders(\"token\", \"1234\")\n                 .setTag(\"test\")\n                 .setPriority(Priority.LOW)\n                 .setOkHttpClient(okHttpClient) // passing a custom okHttpClient \n                 .build()\n                 .getAsJSONArray(new JSONArrayRequestListener() {\n                    @Override\n                    public void onResponse(JSONArray response) {\n                      // do anything with response\n                    }\n                    @Override\n                    public void onError(ANError error) {\n                    // handle error\n                    }\n                });\n```\n### Making a conditional request (Building a request)\n```java\nANRequest.GetRequestBuilder getRequestBuilder = new ANRequest.GetRequestBuilder(ApiEndPoint.BASE_URL + ApiEndPoint.CHECK_FOR_HEADER);\n               \nif(isHeaderRequired){\n getRequestBuilder.addHeaders(\"token\", \"1234\");\n}\n\nif(executorRequired){\n getRequestBuilder.setExecutor(Executors.newSingleThreadExecutor());\n}\n               \nANRequest anRequest = getRequestBuilder.build();       \n                 \nanRequest.getAsJSONObject(new JSONObjectRequestListener() {\n    @Override\n    public void onResponse(JSONObject response) {\n      // do anything with response\n    }\n    @Override\n    public void onError(ANError error) {\n      // handle error\n    }\n});\n```\n### ConnectionClass Listener to get current network quality and bandwidth\n```java\n// Adding Listener\nAndroidNetworking.setConnectionQualityChangeListener(new ConnectionQualityChangeListener() {\n            @Override\n            public void onChange(ConnectionQuality currentConnectionQuality, int currentBandwidth) {\n              // do something on change in connectionQuality\n            }\n        });\n        \n// Removing Listener   \nAndroidNetworking.removeConnectionQualityChangeListener();\n\n// Getting current ConnectionQuality\nConnectionQuality connectionQuality = AndroidNetworking.getCurrentConnectionQuality();\nif(connectionQuality == ConnectionQuality.EXCELLENT) {\n  // do something\n} else if (connectionQuality == ConnectionQuality.POOR) {\n  // do something\n} else if (connectionQuality == ConnectionQuality.UNKNOWN) {\n  // do something\n}\n// Getting current bandwidth\nint currentBandwidth = AndroidNetworking.getCurrentBandwidth(); // Note : if (currentBandwidth == 0) : means UNKNOWN\n```\n### Getting Analytics of a request by setting AnalyticsListener on that\n```java\nAndroidNetworking.download(url,dirPath,fileName)\n                 .setTag(\"downloadTest\")\n                 .setPriority(Priority.MEDIUM)\n                 .build()\n                 .setAnalyticsListener(new AnalyticsListener() {\n                      @Override\n                      public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                          Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                          Log.d(TAG, \" bytesSent : \" + bytesSent);\n                          Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                          Log.d(TAG, \" isFromCache : \" + isFromCache);\n                      }\n                  })\n                 .setDownloadProgressListener(new DownloadProgressListener() {\n                    @Override\n                    public void onProgress(long bytesDownloaded, long totalBytes) {\n                      // do anything with progress  \n                    }\n                 })\n                 .startDownload(new DownloadListener() {\n                    @Override\n                    public void onDownloadComplete() {\n                      // do anything after completion\n                    }\n                    @Override\n                    public void onError(ANError error) {\n                      // handle error    \n                    }\n                });  \nNote : If bytesSent or bytesReceived is -1 , it means it is unknown                \n```\n### Getting OkHttpResponse in Response\n```java\nAndroidNetworking.get(\"https://fierce-cove-29863.herokuapp.com/getAnUserDetail/{userId}\")\n                .addPathParameter(\"userId\", \"1\")\n                .setTag(this)\n                .setPriority(Priority.LOW)\n                .setUserAgent(\"getAnUser\")\n                .build()\n                .getAsOkHttpResponseAndParsed(new TypeToken<User>() {\n                }, new OkHttpResponseAndParsedRequestListener<User>() {\n                    @Override\n                    public void onResponse(Response okHttpResponse, User user) {\n                      // do anything with okHttpResponse and user\n                    }\n                    @Override\n                    public void onError(ANError anError) {\n                      // handle error\n                    }\n                });\n```\n### Making Synchronous Request\n```java                \nANRequest request = AndroidNetworking.get(\"https://fierce-cove-29863.herokuapp.com/getAllUsers/{pageNumber}\")\n                        .addPathParameter(\"pageNumber\", \"0\")\n                        .addQueryParameter(\"limit\", \"3\")\n                        .build();\nANResponse<List<User>> response = request.executeForObjectList(User.class);\nif (response.isSuccess()) {\n   List<User> users = responseTwo.getResult();\n} else {\n   //handle error\n}                                        \n```\n### How caching works ?\n* First of all the server must send cache-control in header so that is starts working.\n* Response will be cached on the basis of cache-control max-age,max-stale.\n* If internet is connected and the age is NOT expired it will return from cache.\n* If internet is connected and the age is expired and if server returns 304(NOT MODIFIED) it will return from cache.\n* If internet is NOT connected if you are using getResponseOnlyIfCached() - it will return from cache even it date is expired.\n* If internet is NOT connected , if you are NOT using getResponseOnlyIfCached() - it will NOT return anything.\n* If you are using getResponseOnlyFromNetwork() , it will only return response after validation from server.\n* If cache-control is set, it will work according to the max-age,max-stale returned from server.\n* If internet is NOT connected only way to get cache Response is by using getResponseOnlyIfCached().\n\n### Enabling Logging\n```java\nAndroidNetworking.enableLogging(); // simply enable logging\nAndroidNetworking.enableLogging(LEVEL.HEADERS); // enabling logging with level\n```\n### Enabling GZIP From Client to Server\n```java\n// Enabling GZIP for Request (Not needed if your server doesn't support GZIP Compression), anyway responses \n// from server are automatically unGzipped if required. So enable it only if you need your request to be \n// Gzipped before sending to server(Make sure your server support GZIP Compression).\nOkHttpClient okHttpClient = new OkHttpClient().newBuilder()\n                .addInterceptor(new GzipRequestInterceptor())\n                .build();\nAndroidNetworking.initialize(getApplicationContext(),okHttpClient);                \n```\n### IMPORTANT NOTE\n* Use IMMEDIATE Priority with caution - use is at appropriate place only when\n  1 or 2 (at max 2)IMMEDIATE request is required at instant.Otherwise use HIGH Priority.\n* Known Bug : As present if you are using GZIP Interceptor from client to server, Upload progress\n  is not working perfectly in Multipart.\n  \n  If you are using Proguard with Gradle build system (which is usually the case), you don't have to do anything. The appropriate Proguard rules will be automatically applied. If you still need the rules applied in `proguard-rules.pro`, it is as follows:\n  ```\n  -dontwarn okio.**\n  ```\n\n  \n### Fast Android Networking Library supports\n\n* Fast Android Networking Library supports all types of HTTP/HTTPS request like GET, POST, DELETE, HEAD, PUT, PATCH\n* Fast Android Networking Library supports downloading any type of file\n* Fast Android Networking Library supports uploading any type of file (supports multipart upload)\n* Fast Android Networking Library supports cancelling a request\n* Fast Android Networking Library supports setting priority to any request (LOW, MEDIUM, HIGH, IMMEDIATE)\n* Fast Android Networking Library supports [RxJava](https://amitshekhariitbhu.github.io/Fast-Android-Networking/rxjava2_support.html)\n\nAs it uses [OkHttp](http://square.github.io/okhttp/) as a networking layer, it supports:\n\n* Fast Android Networking Library supports HTTP/2 support allows all requests to the same host to share a socket\n* Fast Android Networking Library uses connection pooling which reduces request latency (if HTTP/2 isn’t available)\n* Transparent GZIP shrinks download sizes\n* Fast Android Networking Library supports response caching which avoids the network completely for repeat requests\n\n### Difference over other Networking Library\n* In Fast Android Networking Library, OkHttpClient can be customized for every request easily — like timeout customization, etc. for each request.\n* As Fast Android Networking Library uses [OkHttp](http://square.github.io/okhttp/) and [Okio](https://github.com/square/okio), it is faster.\n* Single library for all type of networking.\n* Supports RxJava, RxJava2 -> [Check here](https://amitshekhariitbhu.github.io/Fast-Android-Networking/rxjava2_support.html)\n* Current bandwidth and connection quality can be obtained to decide logic of code.\n* Executor can be passed to any request to get the response in another thread.\n* Complete analytics of any request can be obtained.\n* All types of customization are possible.\n* Immediate Request really is immediate now.\n* Prefetching of any request can be done so that it gives instant data when required from the cache.\n* Proper request canceling.\n* Prevents cancellation of a request if it’s completed more than a specific threshold percentage.\n* A simple interface to make any type of request.\n* Proper Response Caching — which leads to reduced bandwidth usage. \n\n### TODO\n* Integration with other library\n* And of course many many features and bug fixes\n\n### CREDITS\n* [Square](https://square.github.io/) - As both [OkHttp](http://square.github.io/okhttp/) and [Okio](https://github.com/square/okio)\n  used by Fast Android Networking is developed by [Square](https://square.github.io/).\n* [Volley](https://android.googlesource.com/platform/frameworks/volley/) - As Fast Android Networking uses ImageLoader that is developed by [Volley](https://android.googlesource.com/platform/frameworks/volley/).  \n* [Prashant Gupta](https://github.com/PrashantGupta17) - For RxJava, RxJava2 Support - [RxJava Support](https://github.com/amitshekhariitbhu/Fast-Android-Networking/wiki/Using-Fast-Android-Networking-Library-With-RxJava)\n\n### Contact - Let's become friend\n- [Twitter](https://twitter.com/amitiitbhu)\n- [Github](https://github.com/amitshekhariitbhu)\n- [Medium](https://medium.com/@amitshekhar)\n- [Facebook](https://www.facebook.com/amit.shekhar.iitbhu)\n\n### License\n```\n   Copyright (C) 2024 Amit Shekhar\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n```\n\n### Contributing to Fast Android Networking\nAll pull requests are welcome, make sure to follow the [contribution guidelines](CONTRIBUTING.md)\nwhen you submit pull request.\n\n"
  },
  {
    "path": "android-networking/.gitignore",
    "content": "/build\n"
  },
  {
    "path": "android-networking/build.gradle",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\napply plugin: 'com.android.library'\n\nandroid {\n    compileSdkVersion rootProject.ext.compileSdkVersion\n    buildToolsVersion rootProject.ext.buildToolsVersion\n\n    defaultConfig {\n        minSdkVersion rootProject.ext.minSdkVersion\n        targetSdkVersion rootProject.ext.targetSdkVersion\n        versionCode 1\n        versionName \"1.0\"\n        consumerProguardFiles 'proguard-rules.pro'\n    }\n    buildTypes {\n        release {\n            minifyEnabled false\n            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'\n        }\n    }\n    lintOptions {\n        abortOnError false\n    }\n}\n\ndependencies {\n    api fileTree(dir: 'libs', include: ['*.jar'])\n    testImplementation \"junit:junit:$rootProject.ext.jUnitVersion\"\n    androidTestImplementation \"com.squareup.okhttp3:mockwebserver:$rootProject.ext.mockWebServerVersion\"\n    api \"com.squareup.okhttp3:okhttp:$rootProject.ext.okHttp3Version\"\n    api \"com.google.code.gson:gson:$rootProject.ext.gsonVersion\"\n    implementation \"com.android.support:appcompat-v7:$rootProject.ext.supportAppCompatVersion\"\n}\n"
  },
  {
    "path": "android-networking/proguard-rules.pro",
    "content": "# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in /Users/amitshekhar/Library/Android/sdk/tools/proguard/proguard-android.txt\n# You can edit the include path and order by changing the proguardFiles\n# directive in build.gradle.\n#\n# For more details, see\n#   http://developer.android.com/guide/developing/tools/proguard.html\n\n# Add any project specific keep options here:\n\n# If your project uses WebView with JS, uncomment the following\n# and specify the fully qualified class name to the JavaScript interface\n# class:\n#-keepclassmembers class fqcn.of.javascript.interface.for.webview {\n#   public *;\n#}\n\n# For OkHttp\n-dontwarn okio.**\n"
  },
  {
    "path": "android-networking/src/androidTest/AndroidManifest.xml",
    "content": "<!--\n  ~    Copyright (C) 2016 Amit Shekhar\n  ~    Copyright (C) 2011 Android Open Source Project\n  ~\n  ~    Licensed under the Apache License, Version 2.0 (the \"License\");\n  ~    you may not use this file except in compliance with the License.\n  ~    You may obtain a copy of the License at\n  ~\n  ~        http://www.apache.org/licenses/LICENSE-2.0\n  ~\n  ~    Unless required by applicable law or agreed to in writing, software\n  ~    distributed under the License is distributed on an \"AS IS\" BASIS,\n  ~    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  ~    See the License for the specific language governing permissions and\n  ~    limitations under the License.\n  -->\n\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    package=\"com.androidnetworking\">\n\n    <uses-permission android:name=\"android.permission.INTERNET\" />\n    <uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\"></uses-permission>\n\n</manifest>\n"
  },
  {
    "path": "android-networking/src/androidTest/java/com/androidnetworking/GetJSONApiTest.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.androidnetworking;\n\nimport android.app.Application;\nimport android.test.ApplicationTestCase;\n\nimport com.androidnetworking.common.ANConstants;\nimport com.androidnetworking.common.ANRequest;\nimport com.androidnetworking.common.ANResponse;\nimport com.androidnetworking.error.ANError;\nimport com.androidnetworking.interfaces.JSONArrayRequestListener;\nimport com.androidnetworking.interfaces.JSONObjectRequestListener;\nimport com.androidnetworking.interfaces.OkHttpResponseAndJSONArrayRequestListener;\nimport com.androidnetworking.interfaces.OkHttpResponseAndJSONObjectRequestListener;\n\nimport org.json.JSONArray;\nimport org.json.JSONException;\nimport org.json.JSONObject;\nimport org.junit.Rule;\n\nimport java.util.concurrent.CountDownLatch;\nimport java.util.concurrent.Executors;\nimport java.util.concurrent.atomic.AtomicReference;\n\nimport okhttp3.Response;\nimport okhttp3.mockwebserver.MockResponse;\nimport okhttp3.mockwebserver.MockWebServer;\n\nimport static java.util.concurrent.TimeUnit.SECONDS;\n\n/**\n * Created by amitshekhar on 03/04/17.\n */\n\npublic class GetJSONApiTest extends ApplicationTestCase<Application> {\n\n    @Rule\n    public final MockWebServer server = new MockWebServer();\n\n    public GetJSONApiTest() {\n        super(Application.class);\n    }\n\n    @Override\n    public void setUp() throws Exception {\n        super.setUp();\n        createApplication();\n    }\n\n    public void testJSONObjectGetRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.get(server.url(\"/\").toString())\n                .build()\n                .getAsJSONObject(new JSONObjectRequestListener() {\n                    @Override\n                    public void onResponse(JSONObject response) {\n                        try {\n                            firstNameRef.set(response.getString(\"firstName\"));\n                            lastNameRef.set(response.getString(\"lastName\"));\n                            latch.countDown();\n                        } catch (JSONException e) {\n                            assertTrue(false);\n                        }\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testJSONObjectGetRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.get(server.url(\"/\").toString())\n                .build()\n                .getAsJSONObject(new JSONObjectRequestListener() {\n                    @Override\n                    public void onResponse(JSONObject response) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n\n    }\n\n    public void testJSONArrayGetRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"[{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}]\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.get(server.url(\"/\").toString())\n                .build()\n                .getAsJSONArray(new JSONArrayRequestListener() {\n                    @Override\n                    public void onResponse(JSONArray response) {\n                        try {\n                            JSONObject jsonObject = response.getJSONObject(0);\n                            firstNameRef.set(jsonObject.getString(\"firstName\"));\n                            lastNameRef.set(jsonObject.getString(\"lastName\"));\n                            latch.countDown();\n                        } catch (JSONException e) {\n                            assertTrue(false);\n                        }\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testJSONArrayGetRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.get(server.url(\"/\").toString())\n                .build()\n                .getAsJSONArray(new JSONArrayRequestListener() {\n                    @Override\n                    public void onResponse(JSONArray response) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public void testSynchronousJSONObjectGetRequest() throws InterruptedException, JSONException {\n\n        server.enqueue(new MockResponse().setBody(\"{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}\"));\n\n        ANRequest request = AndroidNetworking.get(server.url(\"/\").toString()).build();\n\n        ANResponse<JSONObject> response = request.executeForJSONObject();\n\n        assertEquals(\"Amit\", response.getResult().getString(\"firstName\"));\n\n        assertEquals(\"Shekhar\", response.getResult().getString(\"lastName\"));\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public void testSynchronousJSONObjectGetRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        ANRequest request = AndroidNetworking.get(server.url(\"/\").toString()).build();\n\n        ANResponse<JSONObject> response = request.executeForJSONObject();\n\n        ANError error = response.getError();\n\n        assertEquals(\"data\", error.getErrorBody());\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, error.getErrorDetail());\n\n        assertEquals(404, error.getErrorCode());\n\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public void testSynchronousJSONArrayGetRequest() throws InterruptedException, JSONException {\n\n        server.enqueue(new MockResponse().setBody(\"[{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}]\"));\n\n        ANRequest request = AndroidNetworking.get(server.url(\"/\").toString()).build();\n\n        ANResponse<JSONArray> response = request.executeForJSONArray();\n\n        JSONObject jsonObject = response.getResult().getJSONObject(0);\n\n        assertEquals(\"Amit\", jsonObject.getString(\"firstName\"));\n\n        assertEquals(\"Shekhar\", jsonObject.getString(\"lastName\"));\n\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public void testSynchronousJSONArrayGetRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        ANRequest request = AndroidNetworking.get(server.url(\"/\").toString()).build();\n\n        ANResponse<JSONObject> response = request.executeForJSONArray();\n\n        ANError error = response.getError();\n\n        assertEquals(\"data\", error.getErrorBody());\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, error.getErrorDetail());\n\n        assertEquals(404, error.getErrorCode());\n\n    }\n\n    public void testResponseBodyAndJSONObjectGet() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final AtomicReference<Boolean> responseBodySuccess = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.get(server.url(\"/\").toString())\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponseAndJSONObject(new OkHttpResponseAndJSONObjectRequestListener() {\n                    @Override\n                    public void onResponse(Response okHttpResponse, JSONObject response) {\n                        try {\n                            firstNameRef.set(response.getString(\"firstName\"));\n                            lastNameRef.set(response.getString(\"lastName\"));\n                            responseBodySuccess.set(okHttpResponse.isSuccessful());\n                            latch.countDown();\n                        } catch (JSONException e) {\n                            assertTrue(false);\n                        }\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(responseBodySuccess.get());\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testResponseBodyAndJSONObjectGet404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.get(server.url(\"/\").toString())\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponseAndJSONObject(new OkHttpResponseAndJSONObjectRequestListener() {\n                    @Override\n                    public void onResponse(Response okHttpResponse, JSONObject response) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n    }\n\n    public void testResponseBodyAndJSONArrayGet() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"[{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}]\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final AtomicReference<Boolean> responseBodySuccess = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.get(server.url(\"/\").toString())\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponseAndJSONArray(new OkHttpResponseAndJSONArrayRequestListener() {\n                    @Override\n                    public void onResponse(Response okHttpResponse, JSONArray response) {\n                        try {\n                            JSONObject jsonObject = response.getJSONObject(0);\n                            firstNameRef.set(jsonObject.getString(\"firstName\"));\n                            lastNameRef.set(jsonObject.getString(\"lastName\"));\n                            responseBodySuccess.set(okHttpResponse.isSuccessful());\n                            latch.countDown();\n                        } catch (JSONException e) {\n                            assertTrue(false);\n                        }\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(responseBodySuccess.get());\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testResponseBodyAndJSONArrayGet404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.get(server.url(\"/\").toString())\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponseAndJSONArray(new OkHttpResponseAndJSONArrayRequestListener() {\n                    @Override\n                    public void onResponse(Response okHttpResponse, JSONArray response) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n    }\n\n    public void testHeaderGetRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final AtomicReference<String> headerRef = new AtomicReference<>();\n        final AtomicReference<Boolean> responseBodySuccess = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.get(server.url(\"/\").toString())\n                .addHeaders(\"headerKey\", \"headerValue\")\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponseAndJSONObject(new OkHttpResponseAndJSONObjectRequestListener() {\n                    @Override\n                    public void onResponse(Response okHttpResponse, JSONObject response) {\n                        try {\n                            firstNameRef.set(response.getString(\"firstName\"));\n                            lastNameRef.set(response.getString(\"lastName\"));\n                            responseBodySuccess.set(okHttpResponse.isSuccessful());\n                            headerRef.set(okHttpResponse.request().header(\"headerKey\"));\n                            latch.countDown();\n                        } catch (JSONException e) {\n                            assertTrue(false);\n                        }\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(responseBodySuccess.get());\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n        assertEquals(\"headerValue\", headerRef.get());\n    }\n\n}"
  },
  {
    "path": "android-networking/src/androidTest/java/com/androidnetworking/GetObjectApiTest.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.androidnetworking;\n\nimport android.app.Application;\nimport android.test.ApplicationTestCase;\n\nimport com.androidnetworking.common.ANConstants;\nimport com.androidnetworking.common.ANRequest;\nimport com.androidnetworking.common.ANResponse;\nimport com.androidnetworking.error.ANError;\nimport com.androidnetworking.interfaces.OkHttpResponseAndParsedRequestListener;\nimport com.androidnetworking.interfaces.ParsedRequestListener;\nimport com.androidnetworking.model.User;\n\nimport org.json.JSONException;\nimport org.junit.Rule;\n\nimport java.util.List;\nimport java.util.concurrent.CountDownLatch;\nimport java.util.concurrent.Executors;\nimport java.util.concurrent.atomic.AtomicReference;\n\nimport okhttp3.Response;\nimport okhttp3.mockwebserver.MockResponse;\nimport okhttp3.mockwebserver.MockWebServer;\n\nimport static java.util.concurrent.TimeUnit.SECONDS;\n\n/**\n * Created by amitshekhar on 10/04/17.\n */\n\npublic class GetObjectApiTest extends ApplicationTestCase<Application> {\n\n    @Rule\n    public final MockWebServer server = new MockWebServer();\n\n    public GetObjectApiTest() {\n        super(Application.class);\n    }\n\n    @Override\n    public void setUp() throws Exception {\n        super.setUp();\n        createApplication();\n    }\n\n    public void testObjectGetRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.get(server.url(\"/\").toString())\n                .build()\n                .getAsObject(User.class, new ParsedRequestListener<User>() {\n                    @Override\n                    public void onResponse(User user) {\n                        firstNameRef.set(user.firstName);\n                        lastNameRef.set(user.lastName);\n                        latch.countDown();\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testObjectGetRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.get(server.url(\"/\").toString())\n                .build()\n                .getAsObject(User.class, new ParsedRequestListener<User>() {\n                    @Override\n                    public void onResponse(User user) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n\n    }\n\n    public void testObjectListGetRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"[{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}]\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.get(server.url(\"/\").toString())\n                .build()\n                .getAsObjectList(User.class, new ParsedRequestListener<List<User>>() {\n                    @Override\n                    public void onResponse(List<User> userList) {\n                        firstNameRef.set(userList.get(0).firstName);\n                        lastNameRef.set(userList.get(0).lastName);\n                        latch.countDown();\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testObjectListGetRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.get(server.url(\"/\").toString())\n                .build()\n                .getAsObjectList(User.class, new ParsedRequestListener<List<User>>() {\n                    @Override\n                    public void onResponse(List<User> userList) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public void testSynchronousObjectGetRequest() throws InterruptedException, JSONException {\n\n        server.enqueue(new MockResponse().setBody(\"{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}\"));\n\n        ANRequest request = AndroidNetworking.get(server.url(\"/\").toString()).build();\n\n        ANResponse<User> response = request.executeForObject(User.class);\n\n        assertEquals(\"Amit\", response.getResult().firstName);\n\n        assertEquals(\"Shekhar\", response.getResult().lastName);\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public void testSynchronousObjectGetRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        ANRequest request = AndroidNetworking.get(server.url(\"/\").toString()).build();\n\n        ANResponse<User> response = request.executeForObject(User.class);\n\n        ANError error = response.getError();\n\n        assertEquals(\"data\", error.getErrorBody());\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, error.getErrorDetail());\n\n        assertEquals(404, error.getErrorCode());\n\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public void testSynchronousObjectListGetRequest() throws InterruptedException, JSONException {\n\n        server.enqueue(new MockResponse().setBody(\"[{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}]\"));\n\n        ANRequest request = AndroidNetworking.get(server.url(\"/\").toString()).build();\n\n        ANResponse<List<User>> response = request.executeForObjectList(User.class);\n\n        User user = response.getResult().get(0);\n\n        assertEquals(\"Amit\", user.firstName);\n\n        assertEquals(\"Shekhar\", user.lastName);\n\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public void testSynchronousObjectListGetRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        ANRequest request = AndroidNetworking.get(server.url(\"/\").toString()).build();\n\n        ANResponse<List<User>> response = request.executeForObjectList(User.class);\n\n        ANError error = response.getError();\n\n        assertEquals(\"data\", error.getErrorBody());\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, error.getErrorDetail());\n\n        assertEquals(404, error.getErrorCode());\n\n    }\n\n    public void testResponseBodyAndObjectGet() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final AtomicReference<Boolean> responseBodySuccess = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.get(server.url(\"/\").toString())\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponseAndObject(User.class,\n                        new OkHttpResponseAndParsedRequestListener<User>() {\n                            @Override\n                            public void onResponse(Response okHttpResponse, User user) {\n                                firstNameRef.set(user.firstName);\n                                lastNameRef.set(user.lastName);\n                                responseBodySuccess.set(okHttpResponse.isSuccessful());\n                                latch.countDown();\n                            }\n\n                            @Override\n                            public void onError(ANError anError) {\n                                assertTrue(false);\n                            }\n                        });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(responseBodySuccess.get());\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testResponseBodyAndObjectGet404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.get(server.url(\"/\").toString())\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponseAndObject(User.class,\n                        new OkHttpResponseAndParsedRequestListener<User>() {\n                            @Override\n                            public void onResponse(Response okHttpResponse, User user) {\n                                assertTrue(false);\n                            }\n\n                            @Override\n                            public void onError(ANError anError) {\n                                errorBodyRef.set(anError.getErrorBody());\n                                errorDetailRef.set(anError.getErrorDetail());\n                                errorCodeRef.set(anError.getErrorCode());\n                                latch.countDown();\n                            }\n                        });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n    }\n\n    public void testResponseBodyAndObjectListGet() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"[{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}]\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final AtomicReference<Boolean> responseBodySuccess = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.get(server.url(\"/\").toString())\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponseAndObjectList(User.class,\n                        new OkHttpResponseAndParsedRequestListener<List<User>>() {\n                            @Override\n                            public void onResponse(Response okHttpResponse, List<User> userList) {\n                                firstNameRef.set(userList.get(0).firstName);\n                                lastNameRef.set(userList.get(0).lastName);\n                                responseBodySuccess.set(okHttpResponse.isSuccessful());\n                                latch.countDown();\n                            }\n\n                            @Override\n                            public void onError(ANError anError) {\n                                assertTrue(false);\n                            }\n                        });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(responseBodySuccess.get());\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testResponseBodyAndObjectListGet404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.get(server.url(\"/\").toString())\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponseAndObjectList(User.class,\n                        new OkHttpResponseAndParsedRequestListener<List<User>>() {\n                            @Override\n                            public void onResponse(Response okHttpResponse, List<User> userList) {\n                                assertTrue(false);\n                            }\n\n                            @Override\n                            public void onError(ANError anError) {\n                                errorBodyRef.set(anError.getErrorBody());\n                                errorDetailRef.set(anError.getErrorDetail());\n                                errorCodeRef.set(anError.getErrorCode());\n                                latch.countDown();\n                            }\n                        });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n    }\n\n    public void testHeaderGetRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final AtomicReference<String> headerRef = new AtomicReference<>();\n        final AtomicReference<Boolean> responseBodySuccess = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.get(server.url(\"/\").toString())\n                .addHeaders(\"headerKey\", \"headerValue\")\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponseAndObject(User.class,\n                        new OkHttpResponseAndParsedRequestListener<User>() {\n                            @Override\n                            public void onResponse(Response okHttpResponse, User user) {\n                                firstNameRef.set(user.firstName);\n                                lastNameRef.set(user.lastName);\n                                responseBodySuccess.set(okHttpResponse.isSuccessful());\n                                headerRef.set(okHttpResponse.request().header(\"headerKey\"));\n                                latch.countDown();\n                            }\n\n                            @Override\n                            public void onError(ANError anError) {\n                                assertTrue(false);\n                            }\n                        });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(responseBodySuccess.get());\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n        assertEquals(\"headerValue\", headerRef.get());\n    }\n\n}\n"
  },
  {
    "path": "android-networking/src/androidTest/java/com/androidnetworking/GetStringApiTest.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.androidnetworking;\n\nimport android.app.Application;\nimport android.test.ApplicationTestCase;\n\nimport com.androidnetworking.common.ANConstants;\nimport com.androidnetworking.common.ANRequest;\nimport com.androidnetworking.common.ANResponse;\nimport com.androidnetworking.error.ANError;\nimport com.androidnetworking.interfaces.OkHttpResponseAndStringRequestListener;\nimport com.androidnetworking.interfaces.OkHttpResponseListener;\nimport com.androidnetworking.interfaces.StringRequestListener;\n\nimport org.junit.Rule;\n\nimport java.io.IOException;\nimport java.util.concurrent.CountDownLatch;\nimport java.util.concurrent.Executors;\nimport java.util.concurrent.atomic.AtomicReference;\n\nimport okhttp3.Response;\nimport okhttp3.mockwebserver.MockResponse;\nimport okhttp3.mockwebserver.MockWebServer;\n\nimport static java.util.concurrent.TimeUnit.SECONDS;\n\npublic class GetStringApiTest extends ApplicationTestCase<Application> {\n\n    @Rule\n    public final MockWebServer server = new MockWebServer();\n\n    public GetStringApiTest() {\n        super(Application.class);\n    }\n\n    @Override\n    public void setUp() throws Exception {\n        super.setUp();\n        createApplication();\n    }\n\n    public void testStringGetRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"data\"));\n\n        final AtomicReference<String> responseRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.get(server.url(\"/\").toString())\n                .build()\n                .getAsString(new StringRequestListener() {\n                    @Override\n                    public void onResponse(String response) {\n                        responseRef.set(response);\n                        latch.countDown();\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(\"data\", responseRef.get());\n    }\n\n    public void testStringGetRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.get(server.url(\"/\").toString())\n                .build()\n                .getAsString(new StringRequestListener() {\n                    @Override\n                    public void onResponse(String response) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public void testSynchronousStringGetRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"data\"));\n\n        ANRequest request = AndroidNetworking.get(server.url(\"/\").toString()).build();\n\n        ANResponse<String> response = request.executeForString();\n\n        assertEquals(\"data\", response.getResult());\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public void testSynchronousStringGetRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        ANRequest request = AndroidNetworking.get(server.url(\"/\").toString()).build();\n\n        ANResponse<String> response = request.executeForString();\n\n        ANError error = response.getError();\n\n        assertEquals(\"data\", error.getErrorBody());\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, error.getErrorDetail());\n\n        assertEquals(404, error.getErrorCode());\n    }\n\n    public void testResponseBodyGet() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"data\"));\n\n        final AtomicReference<String> responseRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.get(server.url(\"/\").toString())\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponse(new OkHttpResponseListener() {\n                    @Override\n                    public void onResponse(Response response) {\n                        try {\n                            responseRef.set(response.body().string());\n                            latch.countDown();\n                        } catch (IOException e) {\n                            assertTrue(false);\n                        }\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(\"data\", responseRef.get());\n    }\n\n    public void testResponseBodyGet404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.get(server.url(\"/\").toString())\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponse(new OkHttpResponseListener() {\n                    @Override\n                    public void onResponse(Response response) {\n                        try {\n                            errorBodyRef.set(response.body().string());\n                            errorCodeRef.set(response.code());\n                            latch.countDown();\n                        } catch (IOException e) {\n                            assertTrue(false);\n                        }\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public void testSyncResponseBodyGet() throws InterruptedException, IOException {\n\n        server.enqueue(new MockResponse().setBody(\"data\"));\n\n        ANRequest request = AndroidNetworking.get(server.url(\"/\").toString()).build();\n\n        ANResponse<Response> response = request.executeForOkHttpResponse();\n\n        assertEquals(\"data\", response.getResult().body().string());\n\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public void testSyncResponseBodyGet404() throws InterruptedException, IOException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        ANRequest request = AndroidNetworking.get(server.url(\"/\").toString()).build();\n\n        ANResponse<Response> response = request.executeForOkHttpResponse();\n\n        assertEquals(\"data\", response.getResult().body().string());\n\n        assertEquals(404, response.getResult().code());\n    }\n\n    public void testResponseBodyAndStringGet() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"data\"));\n\n        final AtomicReference<Boolean> responseBodySuccess = new AtomicReference<>();\n        final AtomicReference<String> responseStringRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.get(server.url(\"/\").toString())\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponseAndString(new OkHttpResponseAndStringRequestListener() {\n                    @Override\n                    public void onResponse(Response okHttpResponse, String response) {\n                        responseBodySuccess.set(okHttpResponse.isSuccessful());\n                        responseStringRef.set(response);\n                        latch.countDown();\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(responseBodySuccess.get());\n        assertEquals(\"data\", responseStringRef.get());\n    }\n\n    public void testResponseBodyAndStringGet404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.get(server.url(\"/\").toString())\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponseAndString(new OkHttpResponseAndStringRequestListener() {\n                    @Override\n                    public void onResponse(Response okHttpResponse, String response) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n    }\n\n    public void testHeaderGetRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"data\"));\n\n        final AtomicReference<String> responseRef = new AtomicReference<>();\n        final AtomicReference<String> headerRef = new AtomicReference<>();\n        final AtomicReference<Boolean> responseBodySuccess = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.get(server.url(\"/\").toString())\n                .addHeaders(\"headerKey\", \"headerValue\")\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponseAndString(new OkHttpResponseAndStringRequestListener() {\n                    @Override\n                    public void onResponse(Response okHttpResponse, String response) {\n                        responseRef.set(response);\n                        responseBodySuccess.set(okHttpResponse.isSuccessful());\n                        headerRef.set(okHttpResponse.request().header(\"headerKey\"));\n                        latch.countDown();\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(responseBodySuccess.get());\n        assertEquals(\"data\", responseRef.get());\n        assertEquals(\"headerValue\", headerRef.get());\n    }\n}"
  },
  {
    "path": "android-networking/src/androidTest/java/com/androidnetworking/MultipartJSONApiTest.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.androidnetworking;\n\nimport android.app.Application;\nimport android.test.ApplicationTestCase;\n\nimport com.androidnetworking.common.ANConstants;\nimport com.androidnetworking.common.ANRequest;\nimport com.androidnetworking.common.ANResponse;\nimport com.androidnetworking.error.ANError;\nimport com.androidnetworking.interfaces.JSONArrayRequestListener;\nimport com.androidnetworking.interfaces.JSONObjectRequestListener;\nimport com.androidnetworking.interfaces.OkHttpResponseAndJSONArrayRequestListener;\nimport com.androidnetworking.interfaces.OkHttpResponseAndJSONObjectRequestListener;\n\nimport org.json.JSONArray;\nimport org.json.JSONException;\nimport org.json.JSONObject;\nimport org.junit.Rule;\n\nimport java.util.concurrent.CountDownLatch;\nimport java.util.concurrent.Executors;\nimport java.util.concurrent.atomic.AtomicReference;\n\nimport okhttp3.Response;\nimport okhttp3.mockwebserver.MockResponse;\nimport okhttp3.mockwebserver.MockWebServer;\n\nimport static java.util.concurrent.TimeUnit.SECONDS;\n\n/**\n * Created by amitshekhar on 09/04/17.\n */\n\npublic class MultipartJSONApiTest extends ApplicationTestCase<Application> {\n\n    @Rule\n    public final MockWebServer server = new MockWebServer();\n\n    public MultipartJSONApiTest() {\n        super(Application.class);\n    }\n\n    @Override\n    public void setUp() throws Exception {\n        super.setUp();\n        createApplication();\n    }\n\n    public void testJSONObjectMultipartRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .build()\n                .getAsJSONObject(new JSONObjectRequestListener() {\n                    @Override\n                    public void onResponse(JSONObject response) {\n                        try {\n                            firstNameRef.set(response.getString(\"firstName\"));\n                            lastNameRef.set(response.getString(\"lastName\"));\n                            latch.countDown();\n                        } catch (JSONException e) {\n                            assertTrue(false);\n                        }\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testJSONObjectMultipartRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .build()\n                .getAsJSONObject(new JSONObjectRequestListener() {\n                    @Override\n                    public void onResponse(JSONObject response) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n\n    }\n\n    public void testJSONArrayMultipartRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"[{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}]\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .build()\n                .getAsJSONArray(new JSONArrayRequestListener() {\n                    @Override\n                    public void onResponse(JSONArray response) {\n                        try {\n                            JSONObject jsonObject = response.getJSONObject(0);\n                            firstNameRef.set(jsonObject.getString(\"firstName\"));\n                            lastNameRef.set(jsonObject.getString(\"lastName\"));\n                            latch.countDown();\n                        } catch (JSONException e) {\n                            assertTrue(false);\n                        }\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testJSONArrayMultipartRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .build()\n                .getAsJSONArray(new JSONArrayRequestListener() {\n                    @Override\n                    public void onResponse(JSONArray response) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public void testSynchronousJSONObjectMultipartRequest() throws InterruptedException, JSONException {\n\n        server.enqueue(new MockResponse().setBody(\"{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}\"));\n\n        ANRequest request = AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .build();\n\n        ANResponse<JSONObject> response = request.executeForJSONObject();\n\n        assertEquals(\"Amit\", response.getResult().getString(\"firstName\"));\n\n        assertEquals(\"Shekhar\", response.getResult().getString(\"lastName\"));\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public void testSynchronousJSONObjectMultipartRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        ANRequest request = AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .build();\n\n        ANResponse<JSONObject> response = request.executeForJSONObject();\n\n        ANError error = response.getError();\n\n        assertEquals(\"data\", error.getErrorBody());\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, error.getErrorDetail());\n\n        assertEquals(404, error.getErrorCode());\n\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public void testSynchronousJSONArrayMultipartRequest() throws InterruptedException, JSONException {\n\n        server.enqueue(new MockResponse().setBody(\"[{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}]\"));\n\n        ANRequest request = AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .build();\n\n        ANResponse<JSONArray> response = request.executeForJSONArray();\n\n        JSONObject jsonObject = response.getResult().getJSONObject(0);\n\n        assertEquals(\"Amit\", jsonObject.getString(\"firstName\"));\n\n        assertEquals(\"Shekhar\", jsonObject.getString(\"lastName\"));\n\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public void testSynchronousJSONArrayMultipartRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        ANRequest request = AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .build();\n\n        ANResponse<JSONObject> response = request.executeForJSONArray();\n\n        ANError error = response.getError();\n\n        assertEquals(\"data\", error.getErrorBody());\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, error.getErrorDetail());\n\n        assertEquals(404, error.getErrorCode());\n\n    }\n\n    public void testResponseBodyAndJSONObjectMultipart() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final AtomicReference<Boolean> responseBodySuccess = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponseAndJSONObject(new OkHttpResponseAndJSONObjectRequestListener() {\n                    @Override\n                    public void onResponse(Response okHttpResponse, JSONObject response) {\n                        try {\n                            firstNameRef.set(response.getString(\"firstName\"));\n                            lastNameRef.set(response.getString(\"lastName\"));\n                            responseBodySuccess.set(okHttpResponse.isSuccessful());\n                            latch.countDown();\n                        } catch (JSONException e) {\n                            assertTrue(false);\n                        }\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(responseBodySuccess.get());\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testResponseBodyAndJSONObjectMultipart404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponseAndJSONObject(new OkHttpResponseAndJSONObjectRequestListener() {\n                    @Override\n                    public void onResponse(Response okHttpResponse, JSONObject response) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n    }\n\n    public void testResponseBodyAndJSONArrayMultipart() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"[{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}]\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final AtomicReference<Boolean> responseBodySuccess = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponseAndJSONArray(new OkHttpResponseAndJSONArrayRequestListener() {\n                    @Override\n                    public void onResponse(Response okHttpResponse, JSONArray response) {\n                        try {\n                            JSONObject jsonObject = response.getJSONObject(0);\n                            firstNameRef.set(jsonObject.getString(\"firstName\"));\n                            lastNameRef.set(jsonObject.getString(\"lastName\"));\n                            responseBodySuccess.set(okHttpResponse.isSuccessful());\n                            latch.countDown();\n                        } catch (JSONException e) {\n                            assertTrue(false);\n                        }\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(responseBodySuccess.get());\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testResponseBodyAndJSONArrayMultipart404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponseAndJSONArray(new OkHttpResponseAndJSONArrayRequestListener() {\n                    @Override\n                    public void onResponse(Response okHttpResponse, JSONArray response) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n    }\n\n    public void testHeaderMultipartRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final AtomicReference<String> headerRef = new AtomicReference<>();\n        final AtomicReference<Boolean> responseBodySuccess = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.upload(server.url(\"/\").toString())\n                .addHeaders(\"headerKey\", \"headerValue\")\n                .addMultipartParameter(\"key\", \"value\")\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponseAndJSONObject(new OkHttpResponseAndJSONObjectRequestListener() {\n                    @Override\n                    public void onResponse(Response okHttpResponse, JSONObject response) {\n                        try {\n                            firstNameRef.set(response.getString(\"firstName\"));\n                            lastNameRef.set(response.getString(\"lastName\"));\n                            responseBodySuccess.set(okHttpResponse.isSuccessful());\n                            headerRef.set(okHttpResponse.request().header(\"headerKey\"));\n                            latch.countDown();\n                        } catch (JSONException e) {\n                            assertTrue(false);\n                        }\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(responseBodySuccess.get());\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n        assertEquals(\"headerValue\", headerRef.get());\n    }\n\n\n}\n"
  },
  {
    "path": "android-networking/src/androidTest/java/com/androidnetworking/MultipartObjectApiTest.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.androidnetworking;\n\nimport android.app.Application;\nimport android.test.ApplicationTestCase;\n\nimport com.androidnetworking.common.ANConstants;\nimport com.androidnetworking.common.ANRequest;\nimport com.androidnetworking.common.ANResponse;\nimport com.androidnetworking.error.ANError;\nimport com.androidnetworking.interfaces.OkHttpResponseAndParsedRequestListener;\nimport com.androidnetworking.interfaces.ParsedRequestListener;\nimport com.androidnetworking.model.User;\n\nimport org.json.JSONException;\nimport org.junit.Rule;\n\nimport java.util.List;\nimport java.util.concurrent.CountDownLatch;\nimport java.util.concurrent.Executors;\nimport java.util.concurrent.atomic.AtomicReference;\n\nimport okhttp3.Response;\nimport okhttp3.mockwebserver.MockResponse;\nimport okhttp3.mockwebserver.MockWebServer;\n\nimport static java.util.concurrent.TimeUnit.SECONDS;\n\n/**\n * Created by amitshekhar on 12/04/17.\n */\n\npublic class MultipartObjectApiTest extends ApplicationTestCase<Application> {\n\n    @Rule\n    public final MockWebServer server = new MockWebServer();\n\n    public MultipartObjectApiTest() {\n        super(Application.class);\n    }\n\n    @Override\n    public void setUp() throws Exception {\n        super.setUp();\n        createApplication();\n    }\n\n    public void testObjectMultipartRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .build()\n                .getAsObject(User.class, new ParsedRequestListener<User>() {\n                    @Override\n                    public void onResponse(User user) {\n                        firstNameRef.set(user.firstName);\n                        lastNameRef.set(user.lastName);\n                        latch.countDown();\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testObjectMultipartRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .build()\n                .getAsObject(User.class, new ParsedRequestListener<User>() {\n                    @Override\n                    public void onResponse(User user) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n\n    }\n\n    public void testObjectListMultipartRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"[{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}]\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .build()\n                .getAsObjectList(User.class, new ParsedRequestListener<List<User>>() {\n                    @Override\n                    public void onResponse(List<User> userList) {\n                        firstNameRef.set(userList.get(0).firstName);\n                        lastNameRef.set(userList.get(0).lastName);\n                        latch.countDown();\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testObjectListMultipartRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .build()\n                .getAsObjectList(User.class, new ParsedRequestListener<List<User>>() {\n                    @Override\n                    public void onResponse(List<User> userList) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public void testSynchronousObjectMultipartRequest() throws InterruptedException, JSONException {\n\n        server.enqueue(new MockResponse().setBody(\"{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}\"));\n\n        ANRequest request = AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .build();\n\n        ANResponse<User> response = request.executeForObject(User.class);\n\n        assertEquals(\"Amit\", response.getResult().firstName);\n\n        assertEquals(\"Shekhar\", response.getResult().lastName);\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public void testSynchronousObjectMultipartRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        ANRequest request = AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .build();\n\n        ANResponse<User> response = request.executeForObject(User.class);\n\n        ANError error = response.getError();\n\n        assertEquals(\"data\", error.getErrorBody());\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, error.getErrorDetail());\n\n        assertEquals(404, error.getErrorCode());\n\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public void testSynchronousObjectListMultipartRequest() throws InterruptedException, JSONException {\n\n        server.enqueue(new MockResponse().setBody(\"[{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}]\"));\n\n        ANRequest request = AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .build();\n\n        ANResponse<List<User>> response = request.executeForObjectList(User.class);\n\n        User user = response.getResult().get(0);\n\n        assertEquals(\"Amit\", user.firstName);\n\n        assertEquals(\"Shekhar\", user.lastName);\n\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public void testSynchronousObjectListMultipartRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        ANRequest request = AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .build();\n\n        ANResponse<List<User>> response = request.executeForObjectList(User.class);\n\n        ANError error = response.getError();\n\n        assertEquals(\"data\", error.getErrorBody());\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, error.getErrorDetail());\n\n        assertEquals(404, error.getErrorCode());\n\n    }\n\n    public void testResponseBodyAndObjectMultipart() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final AtomicReference<Boolean> responseBodySuccess = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponseAndObject(User.class,\n                        new OkHttpResponseAndParsedRequestListener<User>() {\n                            @Override\n                            public void onResponse(Response okHttpResponse, User user) {\n                                firstNameRef.set(user.firstName);\n                                lastNameRef.set(user.lastName);\n                                responseBodySuccess.set(okHttpResponse.isSuccessful());\n                                latch.countDown();\n                            }\n\n                            @Override\n                            public void onError(ANError anError) {\n                                assertTrue(false);\n                            }\n                        });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(responseBodySuccess.get());\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testResponseBodyAndObjectMultipart404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponseAndObject(User.class,\n                        new OkHttpResponseAndParsedRequestListener<User>() {\n                            @Override\n                            public void onResponse(Response okHttpResponse, User user) {\n                                assertTrue(false);\n                            }\n\n                            @Override\n                            public void onError(ANError anError) {\n                                errorBodyRef.set(anError.getErrorBody());\n                                errorDetailRef.set(anError.getErrorDetail());\n                                errorCodeRef.set(anError.getErrorCode());\n                                latch.countDown();\n                            }\n                        });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n    }\n\n    public void testResponseBodyAndObjectListMultipart() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"[{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}]\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final AtomicReference<Boolean> responseBodySuccess = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponseAndObjectList(User.class,\n                        new OkHttpResponseAndParsedRequestListener<List<User>>() {\n                            @Override\n                            public void onResponse(Response okHttpResponse, List<User> userList) {\n                                firstNameRef.set(userList.get(0).firstName);\n                                lastNameRef.set(userList.get(0).lastName);\n                                responseBodySuccess.set(okHttpResponse.isSuccessful());\n                                latch.countDown();\n                            }\n\n                            @Override\n                            public void onError(ANError anError) {\n                                assertTrue(false);\n                            }\n                        });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(responseBodySuccess.get());\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testResponseBodyAndObjectListMultipart404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponseAndObjectList(User.class,\n                        new OkHttpResponseAndParsedRequestListener<List<User>>() {\n                            @Override\n                            public void onResponse(Response okHttpResponse, List<User> userList) {\n                                assertTrue(false);\n                            }\n\n                            @Override\n                            public void onError(ANError anError) {\n                                errorBodyRef.set(anError.getErrorBody());\n                                errorDetailRef.set(anError.getErrorDetail());\n                                errorCodeRef.set(anError.getErrorCode());\n                                latch.countDown();\n                            }\n                        });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n    }\n\n    public void testHeaderMultipartRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final AtomicReference<String> headerRef = new AtomicReference<>();\n        final AtomicReference<Boolean> responseBodySuccess = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.upload(server.url(\"/\").toString())\n                .addHeaders(\"headerKey\", \"headerValue\")\n                .addMultipartParameter(\"key\", \"value\")\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponseAndObject(User.class,\n                        new OkHttpResponseAndParsedRequestListener<User>() {\n                            @Override\n                            public void onResponse(Response okHttpResponse, User user) {\n                                firstNameRef.set(user.firstName);\n                                lastNameRef.set(user.lastName);\n                                responseBodySuccess.set(okHttpResponse.isSuccessful());\n                                headerRef.set(okHttpResponse.request().header(\"headerKey\"));\n                                latch.countDown();\n                            }\n\n                            @Override\n                            public void onError(ANError anError) {\n                                assertTrue(false);\n                            }\n                        });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(responseBodySuccess.get());\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n        assertEquals(\"headerValue\", headerRef.get());\n    }\n\n}\n"
  },
  {
    "path": "android-networking/src/androidTest/java/com/androidnetworking/MultipartStringApiTest.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.androidnetworking;\n\nimport android.app.Application;\nimport android.test.ApplicationTestCase;\n\nimport com.androidnetworking.common.ANConstants;\nimport com.androidnetworking.common.ANRequest;\nimport com.androidnetworking.common.ANResponse;\nimport com.androidnetworking.error.ANError;\nimport com.androidnetworking.interfaces.OkHttpResponseAndParsedRequestListener;\nimport com.androidnetworking.interfaces.OkHttpResponseAndStringRequestListener;\nimport com.androidnetworking.interfaces.OkHttpResponseListener;\nimport com.androidnetworking.interfaces.StringRequestListener;\nimport com.androidnetworking.model.User;\n\nimport org.junit.Rule;\n\nimport java.io.IOException;\nimport java.util.concurrent.CountDownLatch;\nimport java.util.concurrent.Executors;\nimport java.util.concurrent.atomic.AtomicReference;\n\nimport okhttp3.Response;\nimport okhttp3.mockwebserver.MockResponse;\nimport okhttp3.mockwebserver.MockWebServer;\n\nimport static java.util.concurrent.TimeUnit.SECONDS;\n\n/**\n * Created by amitshekhar on 27/03/17.\n */\n\npublic class MultipartStringApiTest extends ApplicationTestCase<Application> {\n\n    @Rule\n    public final MockWebServer server = new MockWebServer();\n\n    public MultipartStringApiTest() {\n        super(Application.class);\n    }\n\n    @Override\n    public void setUp() throws Exception {\n        super.setUp();\n        createApplication();\n    }\n\n    public void testStringMultipartRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"data\"));\n\n        final AtomicReference<String> responseRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .build()\n                .getAsString(new StringRequestListener() {\n                    @Override\n                    public void onResponse(String response) {\n                        responseRef.set(response);\n                        latch.countDown();\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(\"data\", responseRef.get());\n    }\n\n    public void testStringMultipartRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .build()\n                .getAsString(new StringRequestListener() {\n                    @Override\n                    public void onResponse(String response) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public void testSynchronousStringMultipartRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"data\"));\n\n        ANRequest request = AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .build();\n\n        ANResponse<String> response = request.executeForString();\n\n        assertEquals(\"data\", response.getResult());\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public void testSynchronousMultipartRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        ANRequest request = AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .build();\n\n        ANResponse<String> response = request.executeForString();\n\n        ANError error = response.getError();\n\n        assertEquals(\"data\", error.getErrorBody());\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, error.getErrorDetail());\n\n        assertEquals(404, error.getErrorCode());\n    }\n\n    public void testResponseBodyMultipart() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"data\"));\n\n        final AtomicReference<String> responseRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponse(new OkHttpResponseListener() {\n                    @Override\n                    public void onResponse(Response response) {\n                        try {\n                            responseRef.set(response.body().string());\n                            latch.countDown();\n                        } catch (IOException e) {\n                            assertTrue(false);\n                        }\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(\"data\", responseRef.get());\n    }\n\n    public void testResponseBodyMultipart404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponse(new OkHttpResponseListener() {\n                    @Override\n                    public void onResponse(Response response) {\n                        try {\n                            errorBodyRef.set(response.body().string());\n                            errorCodeRef.set(response.code());\n                            latch.countDown();\n                        } catch (IOException e) {\n                            assertTrue(false);\n                        }\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public void testSyncResponseBodyMultipart() throws InterruptedException, IOException {\n\n        server.enqueue(new MockResponse().setBody(\"data\"));\n\n        ANRequest request = AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .build();\n\n        ANResponse<Response> response = request.executeForOkHttpResponse();\n\n        assertEquals(\"data\", response.getResult().body().string());\n\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public void testSyncResponseBodyMultipart404() throws InterruptedException, IOException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        ANRequest request = AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .build();\n\n        ANResponse<Response> response = request.executeForOkHttpResponse();\n\n        assertEquals(\"data\", response.getResult().body().string());\n\n        assertEquals(404, response.getResult().code());\n    }\n\n    public void testResponseBodyAndStringMultipart() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"data\"));\n\n        final AtomicReference<Boolean> responseBodySuccess = new AtomicReference<>();\n        final AtomicReference<String> responseStringRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponseAndString(new OkHttpResponseAndStringRequestListener() {\n                    @Override\n                    public void onResponse(Response okHttpResponse, String response) {\n                        responseBodySuccess.set(okHttpResponse.isSuccessful());\n                        responseStringRef.set(response);\n                        latch.countDown();\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(responseBodySuccess.get());\n        assertEquals(\"data\", responseStringRef.get());\n    }\n\n    public void testResponseBodyAndStringMultipart404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponseAndString(new OkHttpResponseAndStringRequestListener() {\n                    @Override\n                    public void onResponse(Response okHttpResponse, String response) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n    }\n\n    public void testHeaderMultipartRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"data\"));\n\n        final AtomicReference<String> responseRef = new AtomicReference<>();\n        final AtomicReference<String> headerRef = new AtomicReference<>();\n        final AtomicReference<Boolean> responseBodySuccess = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.upload(server.url(\"/\").toString())\n                .addHeaders(\"headerKey\", \"headerValue\")\n                .addMultipartParameter(\"key\", \"value\")\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponseAndString(new OkHttpResponseAndStringRequestListener() {\n                    @Override\n                    public void onResponse(Response okHttpResponse, String response) {\n                        responseRef.set(response);\n                        responseBodySuccess.set(okHttpResponse.isSuccessful());\n                        headerRef.set(okHttpResponse.request().header(\"headerKey\"));\n                        latch.countDown();\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(responseBodySuccess.get());\n        assertEquals(\"data\", responseRef.get());\n        assertEquals(\"headerValue\", headerRef.get());\n    }\n\n}"
  },
  {
    "path": "android-networking/src/androidTest/java/com/androidnetworking/PostJSONApiTest.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.androidnetworking;\n\nimport android.app.Application;\nimport android.test.ApplicationTestCase;\n\nimport com.androidnetworking.common.ANConstants;\nimport com.androidnetworking.common.ANRequest;\nimport com.androidnetworking.common.ANResponse;\nimport com.androidnetworking.error.ANError;\nimport com.androidnetworking.interfaces.JSONArrayRequestListener;\nimport com.androidnetworking.interfaces.JSONObjectRequestListener;\nimport com.androidnetworking.interfaces.OkHttpResponseAndJSONArrayRequestListener;\nimport com.androidnetworking.interfaces.OkHttpResponseAndJSONObjectRequestListener;\n\nimport org.json.JSONArray;\nimport org.json.JSONException;\nimport org.json.JSONObject;\nimport org.junit.Rule;\n\nimport java.util.concurrent.CountDownLatch;\nimport java.util.concurrent.Executors;\nimport java.util.concurrent.atomic.AtomicReference;\n\nimport okhttp3.Response;\nimport okhttp3.mockwebserver.MockResponse;\nimport okhttp3.mockwebserver.MockWebServer;\n\nimport static java.util.concurrent.TimeUnit.SECONDS;\n\n/**\n * Created by amitshekhar on 06/04/17.\n */\n\npublic class PostJSONApiTest extends ApplicationTestCase<Application> {\n\n    @Rule\n    public final MockWebServer server = new MockWebServer();\n\n    public PostJSONApiTest() {\n        super(Application.class);\n    }\n\n    @Override\n    public void setUp() throws Exception {\n        super.setUp();\n        createApplication();\n    }\n\n    public void testJSONObjectPostRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .build()\n                .getAsJSONObject(new JSONObjectRequestListener() {\n                    @Override\n                    public void onResponse(JSONObject response) {\n                        try {\n                            firstNameRef.set(response.getString(\"firstName\"));\n                            lastNameRef.set(response.getString(\"lastName\"));\n                            latch.countDown();\n                        } catch (JSONException e) {\n                            assertTrue(false);\n                        }\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testJSONObjectPostRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .build()\n                .getAsJSONObject(new JSONObjectRequestListener() {\n                    @Override\n                    public void onResponse(JSONObject response) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n\n    }\n\n    public void testJSONArrayPostRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"[{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}]\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .build()\n                .getAsJSONArray(new JSONArrayRequestListener() {\n                    @Override\n                    public void onResponse(JSONArray response) {\n                        try {\n                            JSONObject jsonObject = response.getJSONObject(0);\n                            firstNameRef.set(jsonObject.getString(\"firstName\"));\n                            lastNameRef.set(jsonObject.getString(\"lastName\"));\n                            latch.countDown();\n                        } catch (JSONException e) {\n                            assertTrue(false);\n                        }\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testJSONArrayPostRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .build()\n                .getAsJSONArray(new JSONArrayRequestListener() {\n                    @Override\n                    public void onResponse(JSONArray response) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public void testSynchronousJSONObjectPostRequest() throws InterruptedException, JSONException {\n\n        server.enqueue(new MockResponse().setBody(\"{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}\"));\n\n        ANRequest request = AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .build();\n\n        ANResponse<JSONObject> response = request.executeForJSONObject();\n\n        assertEquals(\"Amit\", response.getResult().getString(\"firstName\"));\n\n        assertEquals(\"Shekhar\", response.getResult().getString(\"lastName\"));\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public void testSynchronousJSONObjectPostRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        ANRequest request = AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .build();\n\n        ANResponse<JSONObject> response = request.executeForJSONObject();\n\n        ANError error = response.getError();\n\n        assertEquals(\"data\", error.getErrorBody());\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, error.getErrorDetail());\n\n        assertEquals(404, error.getErrorCode());\n\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public void testSynchronousJSONArrayPostRequest() throws InterruptedException, JSONException {\n\n        server.enqueue(new MockResponse().setBody(\"[{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}]\"));\n\n        ANRequest request = AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .build();\n\n        ANResponse<JSONArray> response = request.executeForJSONArray();\n\n        JSONObject jsonObject = response.getResult().getJSONObject(0);\n\n        assertEquals(\"Amit\", jsonObject.getString(\"firstName\"));\n\n        assertEquals(\"Shekhar\", jsonObject.getString(\"lastName\"));\n\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public void testSynchronousJSONArrayPostRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        ANRequest request = AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .build();\n\n        ANResponse<JSONObject> response = request.executeForJSONArray();\n\n        ANError error = response.getError();\n\n        assertEquals(\"data\", error.getErrorBody());\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, error.getErrorDetail());\n\n        assertEquals(404, error.getErrorCode());\n\n    }\n\n    public void testResponseBodyAndJSONObjectPost() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final AtomicReference<Boolean> responseBodySuccess = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponseAndJSONObject(new OkHttpResponseAndJSONObjectRequestListener() {\n                    @Override\n                    public void onResponse(Response okHttpResponse, JSONObject response) {\n                        try {\n                            firstNameRef.set(response.getString(\"firstName\"));\n                            lastNameRef.set(response.getString(\"lastName\"));\n                            responseBodySuccess.set(okHttpResponse.isSuccessful());\n                            latch.countDown();\n                        } catch (JSONException e) {\n                            assertTrue(false);\n                        }\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(responseBodySuccess.get());\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testResponseBodyAndJSONObjectPost404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponseAndJSONObject(new OkHttpResponseAndJSONObjectRequestListener() {\n                    @Override\n                    public void onResponse(Response okHttpResponse, JSONObject response) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n    }\n\n    public void testResponseBodyAndJSONArrayPost() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"[{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}]\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final AtomicReference<Boolean> responseBodySuccess = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponseAndJSONArray(new OkHttpResponseAndJSONArrayRequestListener() {\n                    @Override\n                    public void onResponse(Response okHttpResponse, JSONArray response) {\n                        try {\n                            JSONObject jsonObject = response.getJSONObject(0);\n                            firstNameRef.set(jsonObject.getString(\"firstName\"));\n                            lastNameRef.set(jsonObject.getString(\"lastName\"));\n                            responseBodySuccess.set(okHttpResponse.isSuccessful());\n                            latch.countDown();\n                        } catch (JSONException e) {\n                            assertTrue(false);\n                        }\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(responseBodySuccess.get());\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testResponseBodyAndJSONArrayPost404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponseAndJSONArray(new OkHttpResponseAndJSONArrayRequestListener() {\n                    @Override\n                    public void onResponse(Response okHttpResponse, JSONArray response) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n    }\n\n    public void testHeaderPostRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final AtomicReference<String> headerRef = new AtomicReference<>();\n        final AtomicReference<Boolean> responseBodySuccess = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.post(server.url(\"/\").toString())\n                .addHeaders(\"headerKey\", \"headerValue\")\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponseAndJSONObject(new OkHttpResponseAndJSONObjectRequestListener() {\n                    @Override\n                    public void onResponse(Response okHttpResponse, JSONObject response) {\n                        try {\n                            firstNameRef.set(response.getString(\"firstName\"));\n                            lastNameRef.set(response.getString(\"lastName\"));\n                            responseBodySuccess.set(okHttpResponse.isSuccessful());\n                            headerRef.set(okHttpResponse.request().header(\"headerKey\"));\n                            latch.countDown();\n                        } catch (JSONException e) {\n                            assertTrue(false);\n                        }\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(responseBodySuccess.get());\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n        assertEquals(\"headerValue\", headerRef.get());\n    }\n\n}\n"
  },
  {
    "path": "android-networking/src/androidTest/java/com/androidnetworking/PostObjectApiTest.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.androidnetworking;\n\nimport android.app.Application;\nimport android.test.ApplicationTestCase;\n\nimport com.androidnetworking.common.ANConstants;\nimport com.androidnetworking.common.ANRequest;\nimport com.androidnetworking.common.ANResponse;\nimport com.androidnetworking.error.ANError;\nimport com.androidnetworking.interfaces.OkHttpResponseAndParsedRequestListener;\nimport com.androidnetworking.interfaces.ParsedRequestListener;\nimport com.androidnetworking.model.User;\n\nimport org.json.JSONException;\nimport org.junit.Rule;\n\nimport java.util.List;\nimport java.util.concurrent.CountDownLatch;\nimport java.util.concurrent.Executors;\nimport java.util.concurrent.atomic.AtomicReference;\n\nimport okhttp3.Response;\nimport okhttp3.mockwebserver.MockResponse;\nimport okhttp3.mockwebserver.MockWebServer;\n\nimport static java.util.concurrent.TimeUnit.SECONDS;\n\n/**\n * Created by amitshekhar on 11/04/17.\n */\n\npublic class PostObjectApiTest extends ApplicationTestCase<Application> {\n\n    @Rule\n    public final MockWebServer server = new MockWebServer();\n\n    public PostObjectApiTest() {\n        super(Application.class);\n    }\n\n    @Override\n    public void setUp() throws Exception {\n        super.setUp();\n        createApplication();\n    }\n\n    public void testObjectPostRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .build()\n                .getAsObject(User.class, new ParsedRequestListener<User>() {\n                    @Override\n                    public void onResponse(User user) {\n                        firstNameRef.set(user.firstName);\n                        lastNameRef.set(user.lastName);\n                        latch.countDown();\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testObjectPostRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .build()\n                .getAsObject(User.class, new ParsedRequestListener<User>() {\n                    @Override\n                    public void onResponse(User user) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n\n    }\n\n    public void testObjectListPostRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"[{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}]\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .build()\n                .getAsObjectList(User.class, new ParsedRequestListener<List<User>>() {\n                    @Override\n                    public void onResponse(List<User> userList) {\n                        firstNameRef.set(userList.get(0).firstName);\n                        lastNameRef.set(userList.get(0).lastName);\n                        latch.countDown();\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testObjectListPostRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .build()\n                .getAsObjectList(User.class, new ParsedRequestListener<List<User>>() {\n                    @Override\n                    public void onResponse(List<User> userList) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public void testSynchronousObjectPostRequest() throws InterruptedException, JSONException {\n\n        server.enqueue(new MockResponse().setBody(\"{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}\"));\n\n        ANRequest request = AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .build();\n\n        ANResponse<User> response = request.executeForObject(User.class);\n\n        assertEquals(\"Amit\", response.getResult().firstName);\n\n        assertEquals(\"Shekhar\", response.getResult().lastName);\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public void testSynchronousObjectPostRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        ANRequest request = AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .build();\n\n        ANResponse<User> response = request.executeForObject(User.class);\n\n        ANError error = response.getError();\n\n        assertEquals(\"data\", error.getErrorBody());\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, error.getErrorDetail());\n\n        assertEquals(404, error.getErrorCode());\n\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public void testSynchronousObjectListPostRequest() throws InterruptedException, JSONException {\n\n        server.enqueue(new MockResponse().setBody(\"[{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}]\"));\n\n        ANRequest request = AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .build();\n\n        ANResponse<List<User>> response = request.executeForObjectList(User.class);\n\n        User user = response.getResult().get(0);\n\n        assertEquals(\"Amit\", user.firstName);\n\n        assertEquals(\"Shekhar\", user.lastName);\n\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public void testSynchronousObjectListPostRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        ANRequest request = AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .build();\n\n        ANResponse<List<User>> response = request.executeForObjectList(User.class);\n\n        ANError error = response.getError();\n\n        assertEquals(\"data\", error.getErrorBody());\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, error.getErrorDetail());\n\n        assertEquals(404, error.getErrorCode());\n\n    }\n\n    public void testResponseBodyAndObjectPost() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final AtomicReference<Boolean> responseBodySuccess = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponseAndObject(User.class,\n                        new OkHttpResponseAndParsedRequestListener<User>() {\n                            @Override\n                            public void onResponse(Response okHttpResponse, User user) {\n                                firstNameRef.set(user.firstName);\n                                lastNameRef.set(user.lastName);\n                                responseBodySuccess.set(okHttpResponse.isSuccessful());\n                                latch.countDown();\n                            }\n\n                            @Override\n                            public void onError(ANError anError) {\n                                assertTrue(false);\n                            }\n                        });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(responseBodySuccess.get());\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testResponseBodyAndObjectPost404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponseAndObject(User.class,\n                        new OkHttpResponseAndParsedRequestListener<User>() {\n                            @Override\n                            public void onResponse(Response okHttpResponse, User user) {\n                                assertTrue(false);\n                            }\n\n                            @Override\n                            public void onError(ANError anError) {\n                                errorBodyRef.set(anError.getErrorBody());\n                                errorDetailRef.set(anError.getErrorDetail());\n                                errorCodeRef.set(anError.getErrorCode());\n                                latch.countDown();\n                            }\n                        });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n    }\n\n    public void testResponseBodyAndObjectListPost() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"[{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}]\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final AtomicReference<Boolean> responseBodySuccess = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponseAndObjectList(User.class,\n                        new OkHttpResponseAndParsedRequestListener<List<User>>() {\n                            @Override\n                            public void onResponse(Response okHttpResponse, List<User> userList) {\n                                firstNameRef.set(userList.get(0).firstName);\n                                lastNameRef.set(userList.get(0).lastName);\n                                responseBodySuccess.set(okHttpResponse.isSuccessful());\n                                latch.countDown();\n                            }\n\n                            @Override\n                            public void onError(ANError anError) {\n                                assertTrue(false);\n                            }\n                        });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(responseBodySuccess.get());\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testResponseBodyAndObjectListPost404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponseAndObjectList(User.class,\n                        new OkHttpResponseAndParsedRequestListener<List<User>>() {\n                            @Override\n                            public void onResponse(Response okHttpResponse, List<User> userList) {\n                                assertTrue(false);\n                            }\n\n                            @Override\n                            public void onError(ANError anError) {\n                                errorBodyRef.set(anError.getErrorBody());\n                                errorDetailRef.set(anError.getErrorDetail());\n                                errorCodeRef.set(anError.getErrorCode());\n                                latch.countDown();\n                            }\n                        });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n    }\n\n    public void testHeaderPostRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final AtomicReference<String> headerRef = new AtomicReference<>();\n        final AtomicReference<Boolean> responseBodySuccess = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.post(server.url(\"/\").toString())\n                .addHeaders(\"headerKey\", \"headerValue\")\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponseAndObject(User.class,\n                        new OkHttpResponseAndParsedRequestListener<User>() {\n                            @Override\n                            public void onResponse(Response okHttpResponse, User user) {\n                                firstNameRef.set(user.firstName);\n                                lastNameRef.set(user.lastName);\n                                responseBodySuccess.set(okHttpResponse.isSuccessful());\n                                headerRef.set(okHttpResponse.request().header(\"headerKey\"));\n                                latch.countDown();\n                            }\n\n                            @Override\n                            public void onError(ANError anError) {\n                                assertTrue(false);\n                            }\n                        });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(responseBodySuccess.get());\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n        assertEquals(\"headerValue\", headerRef.get());\n    }\n\n}\n"
  },
  {
    "path": "android-networking/src/androidTest/java/com/androidnetworking/PostStringApiTest.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.androidnetworking;\n\nimport android.app.Application;\nimport android.test.ApplicationTestCase;\n\nimport com.androidnetworking.common.ANConstants;\nimport com.androidnetworking.common.ANRequest;\nimport com.androidnetworking.common.ANResponse;\nimport com.androidnetworking.error.ANError;\nimport com.androidnetworking.interfaces.OkHttpResponseAndStringRequestListener;\nimport com.androidnetworking.interfaces.OkHttpResponseListener;\nimport com.androidnetworking.interfaces.StringRequestListener;\n\nimport org.junit.Rule;\n\nimport java.io.IOException;\nimport java.util.concurrent.CountDownLatch;\nimport java.util.concurrent.Executors;\nimport java.util.concurrent.atomic.AtomicReference;\n\nimport okhttp3.Response;\nimport okhttp3.mockwebserver.MockResponse;\nimport okhttp3.mockwebserver.MockWebServer;\n\nimport static java.util.concurrent.TimeUnit.SECONDS;\n\n/**\n * Created by amitshekhar on 25/03/17.\n */\n\npublic class PostStringApiTest extends ApplicationTestCase<Application> {\n\n    @Rule\n    public final MockWebServer server = new MockWebServer();\n\n    public PostStringApiTest() {\n        super(Application.class);\n    }\n\n    @Override\n    public void setUp() throws Exception {\n        super.setUp();\n        createApplication();\n    }\n\n    public void testStringPostRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"data\"));\n\n        final AtomicReference<String> responseRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .build()\n                .getAsString(new StringRequestListener() {\n                    @Override\n                    public void onResponse(String response) {\n                        responseRef.set(response);\n                        latch.countDown();\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(\"data\", responseRef.get());\n    }\n\n\n    public void testStringPostRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .build()\n                .getAsString(new StringRequestListener() {\n                    @Override\n                    public void onResponse(String response) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public void testSynchronousStringPostRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"data\"));\n\n        ANRequest request = AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .build();\n\n        ANResponse<String> response = request.executeForString();\n\n        assertEquals(\"data\", response.getResult());\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public void testSynchronousStringPostRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        ANRequest request = AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .build();\n\n        ANResponse<String> response = request.executeForString();\n\n        ANError error = response.getError();\n\n        assertEquals(\"data\", error.getErrorBody());\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, error.getErrorDetail());\n\n        assertEquals(404, error.getErrorCode());\n    }\n\n    public void testResponseBodyPost() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"data\"));\n\n        final AtomicReference<String> responseRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponse(new OkHttpResponseListener() {\n                    @Override\n                    public void onResponse(Response response) {\n                        try {\n                            responseRef.set(response.body().string());\n                            latch.countDown();\n                        } catch (IOException e) {\n                            assertTrue(false);\n                        }\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(\"data\", responseRef.get());\n    }\n\n    public void testResponseBodyPost404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponse(new OkHttpResponseListener() {\n                    @Override\n                    public void onResponse(Response response) {\n                        try {\n                            errorBodyRef.set(response.body().string());\n                            errorCodeRef.set(response.code());\n                            latch.countDown();\n                        } catch (IOException e) {\n                            assertTrue(false);\n                        }\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public void testSyncResponseBodyPost() throws InterruptedException, IOException {\n\n        server.enqueue(new MockResponse().setBody(\"data\"));\n\n        ANRequest request = AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .build();\n\n        ANResponse<Response> response = request.executeForOkHttpResponse();\n\n        assertEquals(\"data\", response.getResult().body().string());\n\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public void testSyncResponseBodyPost404() throws InterruptedException, IOException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        ANRequest request = AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .build();\n\n        ANResponse<Response> response = request.executeForOkHttpResponse();\n\n        assertEquals(\"data\", response.getResult().body().string());\n\n        assertEquals(404, response.getResult().code());\n    }\n\n    public void testResponseBodyAndStringPost() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"data\"));\n\n        final AtomicReference<Boolean> responseBodySuccess = new AtomicReference<>();\n        final AtomicReference<String> responseStringRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponseAndString(new OkHttpResponseAndStringRequestListener() {\n                    @Override\n                    public void onResponse(Response okHttpResponse, String response) {\n                        responseBodySuccess.set(okHttpResponse.isSuccessful());\n                        responseStringRef.set(response);\n                        latch.countDown();\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(responseBodySuccess.get());\n        assertEquals(\"data\", responseStringRef.get());\n    }\n\n    public void testResponseBodyAndStringPost404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponseAndString(new OkHttpResponseAndStringRequestListener() {\n                    @Override\n                    public void onResponse(Response okHttpResponse, String response) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n    }\n\n    public void testHeaderPostRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"data\"));\n\n        final AtomicReference<String> responseRef = new AtomicReference<>();\n        final AtomicReference<String> headerRef = new AtomicReference<>();\n        final AtomicReference<Boolean> responseBodySuccess = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.post(server.url(\"/\").toString())\n                .addHeaders(\"headerKey\", \"headerValue\")\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponseAndString(new OkHttpResponseAndStringRequestListener() {\n                    @Override\n                    public void onResponse(Response okHttpResponse, String response) {\n                        responseRef.set(response);\n                        responseBodySuccess.set(okHttpResponse.isSuccessful());\n                        headerRef.set(okHttpResponse.request().header(\"headerKey\"));\n                        latch.countDown();\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(responseBodySuccess.get());\n        assertEquals(\"data\", responseRef.get());\n        assertEquals(\"headerValue\", headerRef.get());\n    }\n\n}\n"
  },
  {
    "path": "android-networking/src/androidTest/java/com/androidnetworking/model/User.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.androidnetworking.model;\n\n/**\n * Created by amitshekhar on 10/04/17.\n */\n\npublic class User {\n\n    public String firstName;\n    public String lastName;\n\n}\n"
  },
  {
    "path": "android-networking/src/main/AndroidManifest.xml",
    "content": "<!--\n  ~    Copyright (C) 2016 Amit Shekhar\n  ~    Copyright (C) 2011 Android Open Source Project\n  ~\n  ~    Licensed under the Apache License, Version 2.0 (the \"License\");\n  ~    you may not use this file except in compliance with the License.\n  ~    You may obtain a copy of the License at\n  ~\n  ~        http://www.apache.org/licenses/LICENSE-2.0\n  ~\n  ~    Unless required by applicable law or agreed to in writing, software\n  ~    distributed under the License is distributed on an \"AS IS\" BASIS,\n  ~    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  ~    See the License for the specific language governing permissions and\n  ~    limitations under the License.\n  -->\n\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    package=\"com.androidnetworking\">\n</manifest>\n"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/AndroidNetworking.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.androidnetworking;\n\nimport android.content.Context;\nimport android.graphics.BitmapFactory;\n\nimport com.androidnetworking.common.ANConstants;\nimport com.androidnetworking.common.ANRequest;\nimport com.androidnetworking.common.ConnectionClassManager;\nimport com.androidnetworking.common.ConnectionQuality;\nimport com.androidnetworking.core.Core;\nimport com.androidnetworking.interceptors.HttpLoggingInterceptor.Level;\nimport com.androidnetworking.interfaces.ConnectionQualityChangeListener;\nimport com.androidnetworking.interfaces.Parser;\nimport com.androidnetworking.internal.ANImageLoader;\nimport com.androidnetworking.internal.ANRequestQueue;\nimport com.androidnetworking.internal.InternalNetworking;\nimport com.androidnetworking.utils.ParseUtil;\nimport com.androidnetworking.utils.Utils;\n\nimport okhttp3.OkHttpClient;\n\n/**\n * Created by amitshekhar on 24/03/16.\n */\n\n/**\n * AndroidNetworking entry point.\n * You must initialize this class before use. The simplest way is to just do\n * {#code AndroidNetworking.initialize(context)}.\n */\n@SuppressWarnings(\"unused\")\npublic class AndroidNetworking {\n\n    /**\n     * private constructor to prevent instantiation of this class\n     */\n    private AndroidNetworking() {\n    }\n\n    /**\n     * Initializes AndroidNetworking with the default config.\n     *\n     * @param context The context\n     */\n    public static void initialize(Context context) {\n        InternalNetworking.setClientWithCache(context.getApplicationContext());\n        ANRequestQueue.initialize();\n        ANImageLoader.initialize();\n    }\n\n    /**\n     * Initializes AndroidNetworking with the specified config.\n     *\n     * @param context      The context\n     * @param okHttpClient The okHttpClient\n     */\n    public static void initialize(Context context, OkHttpClient okHttpClient) {\n        if (okHttpClient != null && okHttpClient.cache() == null) {\n            okHttpClient = okHttpClient\n                    .newBuilder()\n                    .cache(Utils.getCache(context.getApplicationContext(),\n                            ANConstants.MAX_CACHE_SIZE, ANConstants.CACHE_DIR_NAME))\n                    .build();\n        }\n        InternalNetworking.setClient(okHttpClient);\n        ANRequestQueue.initialize();\n        ANImageLoader.initialize();\n    }\n\n    /**\n     * Method to set decodeOptions\n     *\n     * @param decodeOptions The decode config for Bitmaps\n     */\n    public static void setBitmapDecodeOptions(BitmapFactory.Options decodeOptions) {\n        if (decodeOptions != null) {\n            ANImageLoader.getInstance().setBitmapDecodeOptions(decodeOptions);\n        }\n    }\n\n    /**\n     * Method to set connectionQualityChangeListener\n     *\n     * @param connectionChangeListener The connectionQualityChangeListener\n     */\n    public static void setConnectionQualityChangeListener(ConnectionQualityChangeListener connectionChangeListener) {\n        ConnectionClassManager.getInstance().setListener(connectionChangeListener);\n    }\n\n    /**\n     * Method to set connectionQualityChangeListener\n     */\n    public static void removeConnectionQualityChangeListener() {\n        ConnectionClassManager.getInstance().removeListener();\n    }\n\n    /**\n     * Method to make GET request\n     *\n     * @param url The url on which request is to be made\n     * @return The GetRequestBuilder\n     */\n    public static ANRequest.GetRequestBuilder get(String url) {\n        return new ANRequest.GetRequestBuilder(url);\n    }\n\n    /**\n     * Method to make HEAD request\n     *\n     * @param url The url on which request is to be made\n     * @return The HeadRequestBuilder\n     */\n    public static ANRequest.HeadRequestBuilder head(String url) {\n        return new ANRequest.HeadRequestBuilder(url);\n    }\n\n    /**\n     * Method to make OPTIONS request\n     *\n     * @param url The url on which request is to be made\n     * @return The OptionsRequestBuilder\n     */\n    public static ANRequest.OptionsRequestBuilder options(String url) {\n        return new ANRequest.OptionsRequestBuilder(url);\n    }\n\n    /**\n     * Method to make POST request\n     *\n     * @param url The url on which request is to be made\n     * @return The PostRequestBuilder\n     */\n    public static ANRequest.PostRequestBuilder post(String url) {\n        return new ANRequest.PostRequestBuilder(url);\n    }\n\n    /**\n     * Method to make PUT request\n     *\n     * @param url The url on which request is to be made\n     * @return The PutRequestBuilder\n     */\n    public static ANRequest.PutRequestBuilder put(String url) {\n        return new ANRequest.PutRequestBuilder(url);\n    }\n\n    /**\n     * Method to make DELETE request\n     *\n     * @param url The url on which request is to be made\n     * @return The DeleteRequestBuilder\n     */\n    public static ANRequest.DeleteRequestBuilder delete(String url) {\n        return new ANRequest.DeleteRequestBuilder(url);\n    }\n\n    /**\n     * Method to make PATCH request\n     *\n     * @param url The url on which request is to be made\n     * @return The PatchRequestBuilder\n     */\n    public static ANRequest.PatchRequestBuilder patch(String url) {\n        return new ANRequest.PatchRequestBuilder(url);\n    }\n\n    /**\n     * Method to make download request\n     *\n     * @param url      The url on which request is to be made\n     * @param dirPath  The directory path on which file is to be saved\n     * @param fileName The file name with which file is to be saved\n     * @return The DownloadBuilder\n     */\n    public static ANRequest.DownloadBuilder download(String url, String dirPath, String fileName) {\n        return new ANRequest.DownloadBuilder(url, dirPath, fileName);\n    }\n\n    /**\n     * Method to make upload request\n     *\n     * @param url The url on which request is to be made\n     * @return The MultiPartBuilder\n     */\n    public static ANRequest.MultiPartBuilder upload(String url) {\n        return new ANRequest.MultiPartBuilder(url);\n    }\n\n    /**\n     * Method to make Dynamic request\n     *\n     * @param url    The url on which request is to be made\n     * @param method The HTTP METHOD for the request\n     * @return The DynamicRequestBuilder\n     */\n    public static ANRequest.DynamicRequestBuilder request(String url, int method) {\n        return new ANRequest.DynamicRequestBuilder(url, method);\n    }\n\n    /**\n     * Method to cancel requests with the given tag\n     *\n     * @param tag The tag with which requests are to be cancelled\n     */\n    public static void cancel(Object tag) {\n        ANRequestQueue.getInstance().cancelRequestWithGivenTag(tag, false);\n    }\n\n    /**\n     * Method to force cancel requests with the given tag\n     *\n     * @param tag The tag with which requests are to be cancelled\n     */\n    public static void forceCancel(Object tag) {\n        ANRequestQueue.getInstance().cancelRequestWithGivenTag(tag, true);\n    }\n\n    /**\n     * Method to cancel all given request\n     */\n    public static void cancelAll() {\n        ANRequestQueue.getInstance().cancelAll(false);\n    }\n\n    /**\n     * Method to force cancel all given request\n     */\n    public static void forceCancelAll() {\n        ANRequestQueue.getInstance().cancelAll(true);\n    }\n\n    /**\n     * Method to enable logging\n     */\n    public static void enableLogging() {\n        enableLogging(Level.BASIC);\n    }\n\n    /**\n     * Method to enable logging with tag\n     *\n     * @param level The level for logging\n     */\n    public static void enableLogging(Level level) {\n        InternalNetworking.enableLogging(level);\n    }\n\n    /**\n     * Method to evict a bitmap with given key from LruCache\n     *\n     * @param key The key of the bitmap\n     */\n    public static void evictBitmap(String key) {\n        final ANImageLoader.ImageCache imageCache = ANImageLoader.getInstance().getImageCache();\n        if (imageCache != null && key != null) {\n            imageCache.evictBitmap(key);\n        }\n    }\n\n    /**\n     * Method to clear LruCache\n     */\n    public static void evictAllBitmap() {\n        final ANImageLoader.ImageCache imageCache = ANImageLoader.getInstance().getImageCache();\n        if (imageCache != null) {\n            imageCache.evictAllBitmap();\n        }\n    }\n\n    /**\n     * Method to set userAgent globally\n     *\n     * @param userAgent The userAgent\n     */\n    public static void setUserAgent(String userAgent) {\n        InternalNetworking.setUserAgent(userAgent);\n    }\n\n    /**\n     * Method to get currentBandwidth\n     *\n     * @return currentBandwidth\n     */\n    public static int getCurrentBandwidth() {\n        return ConnectionClassManager.getInstance().getCurrentBandwidth();\n    }\n\n    /**\n     * Method to get currentConnectionQuality\n     *\n     * @return currentConnectionQuality\n     */\n    public static ConnectionQuality getCurrentConnectionQuality() {\n        return ConnectionClassManager.getInstance().getCurrentConnectionQuality();\n    }\n\n    /**\n     * Method to set ParserFactory\n     *\n     * @param parserFactory The ParserFactory\n     */\n    public static void setParserFactory(Parser.Factory parserFactory) {\n        ParseUtil.setParserFactory(parserFactory);\n    }\n\n    /**\n     * Method to find if the request is running or not\n     *\n     * @param tag The tag with which request running status is to be checked\n     * @return The request is running or not\n     */\n    public static boolean isRequestRunning(Object tag) {\n        return ANRequestQueue.getInstance().isRequestRunning(tag);\n    }\n\n    /**\n     * Shuts AndroidNetworking down\n     */\n    public static void shutDown() {\n        Core.shutDown();\n        evictAllBitmap();\n        ConnectionClassManager.getInstance().removeListener();\n        ConnectionClassManager.shutDown();\n        ParseUtil.shutDown();\n    }\n}\n"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/cache/LruBitmapCache.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.androidnetworking.cache;\n\nimport android.graphics.Bitmap;\n\nimport com.androidnetworking.internal.ANImageLoader;\n\n/**\n * Created by amitshekhar on 24/03/16.\n */\npublic class LruBitmapCache extends LruCache<String, Bitmap>\n        implements ANImageLoader.ImageCache {\n\n    public LruBitmapCache(int maxSize) {\n        super(maxSize);\n    }\n\n    @Override\n    protected int sizeOf(String key, Bitmap value) {\n        return value.getRowBytes() * value.getHeight();\n    }\n\n    @Override\n    public Bitmap getBitmap(String key) {\n        return get(key);\n    }\n\n    @Override\n    public void evictBitmap(String key) {\n        remove(key);\n    }\n\n    @Override\n    public void evictAllBitmap() {\n        evictAll();\n    }\n\n    @Override\n    public void putBitmap(String url, Bitmap bitmap) {\n        put(url, bitmap);\n    }\n\n}\n"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/cache/LruCache.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.androidnetworking.cache;\n\nimport android.annotation.SuppressLint;\n\nimport java.util.LinkedHashMap;\nimport java.util.Map;\n\n/**\n * Created by amitshekhar on 28/05/16.\n */\npublic class LruCache<K, V> {\n    private final LinkedHashMap<K, V> map;\n\n    private int size;\n    private int maxSize;\n\n    private int putCount;\n    private int createCount;\n    private int evictionCount;\n    private int hitCount;\n    private int missCount;\n\n    public LruCache(int maxSize) {\n        if (maxSize <= 0) {\n            throw new IllegalArgumentException(\"maxSize <= 0\");\n        }\n        this.maxSize = maxSize;\n        this.map = new LinkedHashMap<K, V>(0, 0.75f, true);\n    }\n\n    public void resize(int maxSize) {\n        if (maxSize <= 0) {\n            throw new IllegalArgumentException(\"maxSize <= 0\");\n        }\n\n        synchronized (this) {\n            this.maxSize = maxSize;\n        }\n        trimToSize(maxSize);\n    }\n\n    public final V get(K key) {\n        if (key == null) {\n            throw new NullPointerException(\"key == null\");\n        }\n\n        V mapValue;\n        synchronized (this) {\n            mapValue = map.get(key);\n            if (mapValue != null) {\n                hitCount++;\n                return mapValue;\n            }\n            missCount++;\n        }\n\n        V createdValue = create(key);\n        if (createdValue == null) {\n            return null;\n        }\n\n        synchronized (this) {\n            createCount++;\n            mapValue = map.put(key, createdValue);\n\n            if (mapValue != null) {\n                // There was a conflict so undo that last put\n                map.put(key, mapValue);\n            } else {\n                size += safeSizeOf(key, createdValue);\n            }\n        }\n\n        if (mapValue != null) {\n            entryRemoved(false, key, createdValue, mapValue);\n            return mapValue;\n        } else {\n            trimToSize(maxSize);\n            return createdValue;\n        }\n    }\n\n    public final V put(K key, V value) {\n        if (key == null || value == null) {\n            throw new NullPointerException(\"key == null || value == null\");\n        }\n\n        V previous;\n        synchronized (this) {\n            putCount++;\n            size += safeSizeOf(key, value);\n            previous = map.put(key, value);\n            if (previous != null) {\n                size -= safeSizeOf(key, previous);\n            }\n        }\n\n        if (previous != null) {\n            entryRemoved(false, key, previous, value);\n        }\n\n        trimToSize(maxSize);\n        return previous;\n    }\n\n    public void trimToSize(int maxSize) {\n        while (true) {\n            K key;\n            V value;\n            synchronized (this) {\n                if (size < 0 || (map.isEmpty() && size != 0)) {\n                    throw new IllegalStateException(getClass().getName()\n                            + \".sizeOf() is reporting inconsistent results!\");\n                }\n\n                if (size <= maxSize || map.isEmpty()) {\n                    break;\n                }\n\n                Map.Entry<K, V> toEvict = map.entrySet().iterator().next();\n                key = toEvict.getKey();\n                value = toEvict.getValue();\n                map.remove(key);\n                size -= safeSizeOf(key, value);\n                evictionCount++;\n            }\n\n            entryRemoved(true, key, value, null);\n        }\n    }\n\n    public final V remove(K key) {\n        if (key == null) {\n            throw new NullPointerException(\"key == null\");\n        }\n\n        V previous;\n        synchronized (this) {\n            previous = map.remove(key);\n            if (previous != null) {\n                size -= safeSizeOf(key, previous);\n            }\n        }\n\n        if (previous != null) {\n            entryRemoved(false, key, previous, null);\n        }\n\n        return previous;\n    }\n\n    protected void entryRemoved(boolean evicted, K key, V oldValue, V newValue) {\n    }\n\n    protected V create(K key) {\n        return null;\n    }\n\n    private int safeSizeOf(K key, V value) {\n        int result = sizeOf(key, value);\n        if (result < 0) {\n            throw new IllegalStateException(\"Negative size: \" + key + \"=\" + value);\n        }\n        return result;\n    }\n\n    protected int sizeOf(K key, V value) {\n        return 1;\n    }\n\n    public final void evictAll() {\n        trimToSize(-1);\n    }\n\n    public synchronized final int size() {\n        return size;\n    }\n\n    public synchronized final int maxSize() {\n        return maxSize;\n    }\n\n    public synchronized final int hitCount() {\n        return hitCount;\n    }\n\n    public synchronized final int missCount() {\n        return missCount;\n    }\n\n    public synchronized final int createCount() {\n        return createCount;\n    }\n\n    public synchronized final int putCount() {\n        return putCount;\n    }\n\n    public synchronized final int evictionCount() {\n        return evictionCount;\n    }\n\n    public synchronized final Map<K, V> snapshot() {\n        return new LinkedHashMap<K, V>(map);\n    }\n\n    @SuppressLint(\"DefaultLocale\")\n    @Override\n    public synchronized final String toString() {\n        int accesses = hitCount + missCount;\n        int hitPercent = accesses != 0 ? (100 * hitCount / accesses) : 0;\n        return String.format(\"LruCache[maxSize=%d,hits=%d,misses=%d,hitRate=%d%%]\",\n                maxSize, hitCount, missCount, hitPercent);\n    }\n}\n"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/common/ANConstants.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.androidnetworking.common;\n\n/**\n * Created by amitshekhar on 29/03/16.\n */\npublic final class ANConstants {\n    public static final int MAX_CACHE_SIZE = 10 * 1024 * 1024;\n    public static final int UPDATE = 0x01;\n    public static final String CACHE_DIR_NAME = \"cache_an\";\n    public static final String CONNECTION_ERROR = \"connectionError\";\n    public static final String RESPONSE_FROM_SERVER_ERROR = \"responseFromServerError\";\n    public static final String REQUEST_CANCELLED_ERROR = \"requestCancelledError\";\n    public static final String PARSE_ERROR = \"parseError\";\n    public static final String PREFETCH = \"prefetch\";\n    public static final String FAST_ANDROID_NETWORKING = \"FastAndroidNetworking\";\n    public static final String USER_AGENT = \"User-Agent\";\n    public static final String SUCCESS = \"success\";\n    public static final String OPTIONS = \"OPTIONS\";\n}\n"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/common/ANRequest.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.androidnetworking.common;\n\nimport android.graphics.Bitmap;\nimport android.graphics.BitmapFactory;\nimport android.widget.ImageView;\n\nimport com.androidnetworking.core.Core;\nimport com.androidnetworking.error.ANError;\nimport com.androidnetworking.interfaces.AnalyticsListener;\nimport com.androidnetworking.interfaces.BitmapRequestListener;\nimport com.androidnetworking.interfaces.DownloadListener;\nimport com.androidnetworking.interfaces.DownloadProgressListener;\nimport com.androidnetworking.interfaces.JSONArrayRequestListener;\nimport com.androidnetworking.interfaces.JSONObjectRequestListener;\nimport com.androidnetworking.interfaces.OkHttpResponseAndBitmapRequestListener;\nimport com.androidnetworking.interfaces.OkHttpResponseAndJSONArrayRequestListener;\nimport com.androidnetworking.interfaces.OkHttpResponseAndJSONObjectRequestListener;\nimport com.androidnetworking.interfaces.OkHttpResponseAndParsedRequestListener;\nimport com.androidnetworking.interfaces.OkHttpResponseAndStringRequestListener;\nimport com.androidnetworking.interfaces.OkHttpResponseListener;\nimport com.androidnetworking.interfaces.ParsedRequestListener;\nimport com.androidnetworking.interfaces.StringRequestListener;\nimport com.androidnetworking.interfaces.UploadProgressListener;\nimport com.androidnetworking.internal.ANRequestQueue;\nimport com.androidnetworking.internal.SynchronousCall;\nimport com.androidnetworking.model.MultipartFileBody;\nimport com.androidnetworking.model.MultipartStringBody;\nimport com.androidnetworking.utils.ParseUtil;\nimport com.androidnetworking.utils.Utils;\nimport com.google.gson.internal.$Gson$Types;\nimport com.google.gson.reflect.TypeToken;\n\nimport org.json.JSONArray;\nimport org.json.JSONObject;\n\nimport java.io.File;\nimport java.lang.reflect.Type;\nimport java.util.ArrayList;\nimport java.util.HashMap;\nimport java.util.List;\nimport java.util.Map;\nimport java.util.Set;\nimport java.util.concurrent.Executor;\nimport java.util.concurrent.Future;\nimport java.util.concurrent.TimeUnit;\n\nimport okhttp3.CacheControl;\nimport okhttp3.Call;\nimport okhttp3.FormBody;\nimport okhttp3.Headers;\nimport okhttp3.HttpUrl;\nimport okhttp3.MediaType;\nimport okhttp3.MultipartBody;\nimport okhttp3.OkHttpClient;\nimport okhttp3.RequestBody;\nimport okhttp3.Response;\nimport okio.Okio;\n\n/**\n * Created by amitshekhar on 26/03/16.\n */\n@SuppressWarnings({\"unchecked\", \"unused\"})\npublic class ANRequest<T extends ANRequest> {\n\n    private final static String TAG = ANRequest.class.getSimpleName();\n\n    private int mMethod;\n    private Priority mPriority;\n    private int mRequestType;\n    private String mUrl;\n    private int sequenceNumber;\n    private Object mTag;\n    private ResponseType mResponseType;\n    private HashMap<String, List<String>> mHeadersMap = new HashMap<>();\n    private HashMap<String, String> mBodyParameterMap = new HashMap<>();\n    private HashMap<String, String> mUrlEncodedFormBodyParameterMap = new HashMap<>();\n    private HashMap<String, MultipartStringBody> mMultiPartParameterMap = new HashMap<>();\n    private HashMap<String, List<String>> mQueryParameterMap = new HashMap<>();\n    private HashMap<String, String> mPathParameterMap = new HashMap<>();\n    private HashMap<String, List<MultipartFileBody>> mMultiPartFileMap = new HashMap<>();\n    private String mDirPath;\n    private String mFileName;\n    private String mApplicationJsonString = null;\n    private String mStringBody = null;\n    private byte[] mByte = null;\n    private File mFile = null;\n    private static final MediaType JSON_MEDIA_TYPE =\n            MediaType.parse(\"application/json; charset=utf-8\");\n    private static final MediaType MEDIA_TYPE_MARKDOWN =\n            MediaType.parse(\"text/x-markdown; charset=utf-8\");\n    private MediaType customMediaType = null;\n    private static final Object sDecodeLock = new Object();\n\n    private Future future;\n    private Call call;\n    private int mProgress;\n    private boolean isCancelled;\n    private boolean isDelivered;\n    private boolean isRunning;\n    private int mPercentageThresholdForCancelling = 0;\n    private JSONArrayRequestListener mJSONArrayRequestListener;\n    private JSONObjectRequestListener mJSONObjectRequestListener;\n    private StringRequestListener mStringRequestListener;\n    private OkHttpResponseListener mOkHttpResponseListener;\n    private BitmapRequestListener mBitmapRequestListener;\n    private ParsedRequestListener mParsedRequestListener;\n    private OkHttpResponseAndJSONObjectRequestListener mOkHttpResponseAndJSONObjectRequestListener;\n    private OkHttpResponseAndJSONArrayRequestListener mOkHttpResponseAndJSONArrayRequestListener;\n    private OkHttpResponseAndStringRequestListener mOkHttpResponseAndStringRequestListener;\n    private OkHttpResponseAndBitmapRequestListener mOkHttpResponseAndBitmapRequestListener;\n    private OkHttpResponseAndParsedRequestListener mOkHttpResponseAndParsedRequestListener;\n    private DownloadProgressListener mDownloadProgressListener;\n    private UploadProgressListener mUploadProgressListener;\n    private DownloadListener mDownloadListener;\n    private AnalyticsListener mAnalyticsListener;\n\n    private Bitmap.Config mDecodeConfig;\n    private int mMaxWidth;\n    private int mMaxHeight;\n    private ImageView.ScaleType mScaleType;\n    private CacheControl mCacheControl = null;\n    private Executor mExecutor = null;\n    private OkHttpClient mOkHttpClient = null;\n    private String mUserAgent = null;\n    private Type mType = null;\n\n    public ANRequest(GetRequestBuilder builder) {\n        this.mRequestType = RequestType.SIMPLE;\n        this.mMethod = builder.mMethod;\n        this.mPriority = builder.mPriority;\n        this.mUrl = builder.mUrl;\n        this.mTag = builder.mTag;\n        this.mHeadersMap = builder.mHeadersMap;\n        this.mDecodeConfig = builder.mDecodeConfig;\n        this.mMaxHeight = builder.mMaxHeight;\n        this.mMaxWidth = builder.mMaxWidth;\n        this.mScaleType = builder.mScaleType;\n        this.mQueryParameterMap = builder.mQueryParameterMap;\n        this.mPathParameterMap = builder.mPathParameterMap;\n        this.mCacheControl = builder.mCacheControl;\n        this.mExecutor = builder.mExecutor;\n        this.mOkHttpClient = builder.mOkHttpClient;\n        this.mUserAgent = builder.mUserAgent;\n    }\n\n    public ANRequest(PostRequestBuilder builder) {\n        this.mRequestType = RequestType.SIMPLE;\n        this.mMethod = builder.mMethod;\n        this.mPriority = builder.mPriority;\n        this.mUrl = builder.mUrl;\n        this.mTag = builder.mTag;\n        this.mHeadersMap = builder.mHeadersMap;\n        this.mBodyParameterMap = builder.mBodyParameterMap;\n        this.mUrlEncodedFormBodyParameterMap = builder.mUrlEncodedFormBodyParameterMap;\n        this.mQueryParameterMap = builder.mQueryParameterMap;\n        this.mPathParameterMap = builder.mPathParameterMap;\n        this.mApplicationJsonString = builder.mApplicationJsonString;\n        this.mStringBody = builder.mStringBody;\n        this.mFile = builder.mFile;\n        this.mByte = builder.mByte;\n        this.mCacheControl = builder.mCacheControl;\n        this.mExecutor = builder.mExecutor;\n        this.mOkHttpClient = builder.mOkHttpClient;\n        this.mUserAgent = builder.mUserAgent;\n        if (builder.mCustomContentType != null) {\n            this.customMediaType = MediaType.parse(builder.mCustomContentType);\n        }\n    }\n\n    public ANRequest(DownloadBuilder builder) {\n        this.mRequestType = RequestType.DOWNLOAD;\n        this.mMethod = Method.GET;\n        this.mPriority = builder.mPriority;\n        this.mUrl = builder.mUrl;\n        this.mTag = builder.mTag;\n        this.mDirPath = builder.mDirPath;\n        this.mFileName = builder.mFileName;\n        this.mHeadersMap = builder.mHeadersMap;\n        this.mQueryParameterMap = builder.mQueryParameterMap;\n        this.mPathParameterMap = builder.mPathParameterMap;\n        this.mCacheControl = builder.mCacheControl;\n        this.mPercentageThresholdForCancelling = builder.mPercentageThresholdForCancelling;\n        this.mExecutor = builder.mExecutor;\n        this.mOkHttpClient = builder.mOkHttpClient;\n        this.mUserAgent = builder.mUserAgent;\n    }\n\n    public ANRequest(MultiPartBuilder builder) {\n        this.mRequestType = RequestType.MULTIPART;\n        this.mMethod = Method.POST;\n        this.mPriority = builder.mPriority;\n        this.mUrl = builder.mUrl;\n        this.mTag = builder.mTag;\n        this.mHeadersMap = builder.mHeadersMap;\n        this.mQueryParameterMap = builder.mQueryParameterMap;\n        this.mPathParameterMap = builder.mPathParameterMap;\n        this.mMultiPartParameterMap = builder.mMultiPartParameterMap;\n        this.mMultiPartFileMap = builder.mMultiPartFileMap;\n        this.mCacheControl = builder.mCacheControl;\n        this.mPercentageThresholdForCancelling = builder.mPercentageThresholdForCancelling;\n        this.mExecutor = builder.mExecutor;\n        this.mOkHttpClient = builder.mOkHttpClient;\n        this.mUserAgent = builder.mUserAgent;\n        if (builder.mCustomContentType != null) {\n            this.customMediaType = MediaType.parse(builder.mCustomContentType);\n        }\n    }\n\n    public void getAsJSONObject(JSONObjectRequestListener requestListener) {\n        this.mResponseType = ResponseType.JSON_OBJECT;\n        this.mJSONObjectRequestListener = requestListener;\n        ANRequestQueue.getInstance().addRequest(this);\n    }\n\n    public void getAsJSONArray(JSONArrayRequestListener requestListener) {\n        this.mResponseType = ResponseType.JSON_ARRAY;\n        this.mJSONArrayRequestListener = requestListener;\n        ANRequestQueue.getInstance().addRequest(this);\n    }\n\n    public void getAsString(StringRequestListener requestListener) {\n        this.mResponseType = ResponseType.STRING;\n        this.mStringRequestListener = requestListener;\n        ANRequestQueue.getInstance().addRequest(this);\n    }\n\n    public void getAsOkHttpResponse(OkHttpResponseListener requestListener) {\n        this.mResponseType = ResponseType.OK_HTTP_RESPONSE;\n        this.mOkHttpResponseListener = requestListener;\n        ANRequestQueue.getInstance().addRequest(this);\n    }\n\n    public void getAsBitmap(BitmapRequestListener requestListener) {\n        this.mResponseType = ResponseType.BITMAP;\n        this.mBitmapRequestListener = requestListener;\n        ANRequestQueue.getInstance().addRequest(this);\n    }\n\n    public void getAsParsed(TypeToken typeToken, ParsedRequestListener parsedRequestListener) {\n        this.mType = typeToken.getType();\n        this.mResponseType = ResponseType.PARSED;\n        this.mParsedRequestListener = parsedRequestListener;\n        ANRequestQueue.getInstance().addRequest(this);\n    }\n\n    public void getAsObject(Class objectClass, ParsedRequestListener parsedRequestListener) {\n        this.mType = objectClass;\n        this.mResponseType = ResponseType.PARSED;\n        this.mParsedRequestListener = parsedRequestListener;\n        ANRequestQueue.getInstance().addRequest(this);\n    }\n\n    public void getAsObjectList(Class objectClass, ParsedRequestListener parsedRequestListener) {\n        this.mType = $Gson$Types.newParameterizedTypeWithOwner(null, List.class, objectClass);\n        this.mResponseType = ResponseType.PARSED;\n        this.mParsedRequestListener = parsedRequestListener;\n        ANRequestQueue.getInstance().addRequest(this);\n    }\n\n    public void getAsOkHttpResponseAndJSONObject(OkHttpResponseAndJSONObjectRequestListener requestListener) {\n        this.mResponseType = ResponseType.JSON_OBJECT;\n        this.mOkHttpResponseAndJSONObjectRequestListener = requestListener;\n        ANRequestQueue.getInstance().addRequest(this);\n    }\n\n    public void getAsOkHttpResponseAndJSONArray(OkHttpResponseAndJSONArrayRequestListener requestListener) {\n        this.mResponseType = ResponseType.JSON_ARRAY;\n        this.mOkHttpResponseAndJSONArrayRequestListener = requestListener;\n        ANRequestQueue.getInstance().addRequest(this);\n    }\n\n    public void getAsOkHttpResponseAndString(OkHttpResponseAndStringRequestListener requestListener) {\n        this.mResponseType = ResponseType.STRING;\n        this.mOkHttpResponseAndStringRequestListener = requestListener;\n        ANRequestQueue.getInstance().addRequest(this);\n    }\n\n\n    public void getAsOkHttpResponseAndBitmap(OkHttpResponseAndBitmapRequestListener requestListener) {\n        this.mResponseType = ResponseType.BITMAP;\n        this.mOkHttpResponseAndBitmapRequestListener = requestListener;\n        ANRequestQueue.getInstance().addRequest(this);\n    }\n\n    public void getAsOkHttpResponseAndParsed(TypeToken typeToken, OkHttpResponseAndParsedRequestListener parsedRequestListener) {\n        this.mType = typeToken.getType();\n        this.mResponseType = ResponseType.PARSED;\n        this.mOkHttpResponseAndParsedRequestListener = parsedRequestListener;\n        ANRequestQueue.getInstance().addRequest(this);\n    }\n\n    public void getAsOkHttpResponseAndObject(Class objectClass, OkHttpResponseAndParsedRequestListener parsedRequestListener) {\n        this.mType = objectClass;\n        this.mResponseType = ResponseType.PARSED;\n        this.mOkHttpResponseAndParsedRequestListener = parsedRequestListener;\n        ANRequestQueue.getInstance().addRequest(this);\n    }\n\n    public void getAsOkHttpResponseAndObjectList(Class objectClass, OkHttpResponseAndParsedRequestListener parsedRequestListener) {\n        this.mType = $Gson$Types.newParameterizedTypeWithOwner(null, List.class, objectClass);\n        this.mResponseType = ResponseType.PARSED;\n        this.mOkHttpResponseAndParsedRequestListener = parsedRequestListener;\n        ANRequestQueue.getInstance().addRequest(this);\n    }\n\n    public void startDownload(DownloadListener downloadListener) {\n        this.mDownloadListener = downloadListener;\n        ANRequestQueue.getInstance().addRequest(this);\n    }\n\n    public void prefetch() {\n        this.mResponseType = ResponseType.PREFETCH;\n        ANRequestQueue.getInstance().addRequest(this);\n    }\n\n    public ANResponse executeForJSONObject() {\n        this.mResponseType = ResponseType.JSON_OBJECT;\n        return SynchronousCall.execute(this);\n    }\n\n    public ANResponse executeForJSONArray() {\n        this.mResponseType = ResponseType.JSON_ARRAY;\n        return SynchronousCall.execute(this);\n    }\n\n    public ANResponse executeForString() {\n        this.mResponseType = ResponseType.STRING;\n        return SynchronousCall.execute(this);\n    }\n\n    public ANResponse executeForOkHttpResponse() {\n        this.mResponseType = ResponseType.OK_HTTP_RESPONSE;\n        return SynchronousCall.execute(this);\n    }\n\n    public ANResponse executeForBitmap() {\n        this.mResponseType = ResponseType.BITMAP;\n        return SynchronousCall.execute(this);\n    }\n\n    public ANResponse executeForParsed(TypeToken typeToken) {\n        this.mType = typeToken.getType();\n        this.mResponseType = ResponseType.PARSED;\n        return SynchronousCall.execute(this);\n    }\n\n    public ANResponse executeForObject(Class objectClass) {\n        this.mType = objectClass;\n        this.mResponseType = ResponseType.PARSED;\n        return SynchronousCall.execute(this);\n    }\n\n    public ANResponse executeForObjectList(Class objectClass) {\n        this.mType = $Gson$Types.newParameterizedTypeWithOwner(null, List.class, objectClass);\n        this.mResponseType = ResponseType.PARSED;\n        return SynchronousCall.execute(this);\n    }\n\n    public ANResponse executeForDownload() {\n        return SynchronousCall.execute(this);\n    }\n\n    public T setDownloadProgressListener(DownloadProgressListener downloadProgressListener) {\n        this.mDownloadProgressListener = downloadProgressListener;\n        return (T) this;\n    }\n\n    public T setUploadProgressListener(UploadProgressListener uploadProgressListener) {\n        this.mUploadProgressListener = uploadProgressListener;\n        return (T) this;\n    }\n\n    public T setAnalyticsListener(AnalyticsListener analyticsListener) {\n        this.mAnalyticsListener = analyticsListener;\n        return (T) this;\n    }\n\n    public AnalyticsListener getAnalyticsListener() {\n        return mAnalyticsListener;\n    }\n\n    public int getMethod() {\n        return mMethod;\n    }\n\n    public Priority getPriority() {\n        return mPriority;\n    }\n\n    public String getUrl() {\n        String tempUrl = mUrl;\n        for (HashMap.Entry<String, String> entry : mPathParameterMap.entrySet()) {\n            tempUrl = tempUrl.replace(\"{\" + entry.getKey() + \"}\", String.valueOf(entry.getValue()));\n        }\n        HttpUrl.Builder urlBuilder = HttpUrl.parse(tempUrl).newBuilder();\n        if (mQueryParameterMap != null) {\n            Set<Map.Entry<String, List<String>>> entries = mQueryParameterMap.entrySet();\n            for (Map.Entry<String, List<String>> entry : entries) {\n                String name = entry.getKey();\n                List<String> list = entry.getValue();\n                if (list != null) {\n                    for (String value : list) {\n                        urlBuilder.addQueryParameter(name, value);\n                    }\n                }\n            }\n        }\n        return urlBuilder.build().toString();\n    }\n\n    public int getSequenceNumber() {\n        return sequenceNumber;\n    }\n\n    public void setSequenceNumber(int sequenceNumber) {\n        this.sequenceNumber = sequenceNumber;\n    }\n\n    public void setProgress(int progress) {\n        this.mProgress = progress;\n    }\n\n    public void setResponseAs(ResponseType responseType) {\n        this.mResponseType = responseType;\n    }\n\n    public ResponseType getResponseAs() {\n        return mResponseType;\n    }\n\n    public Object getTag() {\n        return mTag;\n    }\n\n    public int getRequestType() {\n        return mRequestType;\n    }\n\n    public OkHttpClient getOkHttpClient() {\n        return mOkHttpClient;\n    }\n\n    public void setUserAgent(String userAgent) {\n        this.mUserAgent = userAgent;\n    }\n\n    public String getUserAgent() {\n        return mUserAgent;\n    }\n\n    public Type getType() {\n        return mType;\n    }\n\n    public void setType(Type type) {\n        this.mType = type;\n    }\n\n    public DownloadProgressListener getDownloadProgressListener() {\n        return new DownloadProgressListener() {\n            @Override\n            public void onProgress(final long bytesDownloaded, final long totalBytes) {\n                if (mDownloadProgressListener != null && !isCancelled) {\n                    mDownloadProgressListener.onProgress(bytesDownloaded, totalBytes);\n                }\n            }\n        };\n    }\n\n    public void updateDownloadCompletion() {\n        isDelivered = true;\n        if (mDownloadListener != null) {\n            if (!isCancelled) {\n                if (mExecutor != null) {\n                    mExecutor.execute(new Runnable() {\n                        @Override\n                        public void run() {\n                            if (mDownloadListener != null) {\n                                mDownloadListener.onDownloadComplete();\n                            }\n                            finish();\n                        }\n                    });\n                } else {\n                    Core.getInstance().getExecutorSupplier().forMainThreadTasks().execute(new Runnable() {\n                        @Override\n                        public void run() {\n                            if (mDownloadListener != null) {\n                                mDownloadListener.onDownloadComplete();\n                            }\n                            finish();\n                        }\n                    });\n                }\n            } else {\n                deliverError(new ANError());\n                finish();\n            }\n        } else {\n            finish();\n        }\n    }\n\n    public UploadProgressListener getUploadProgressListener() {\n        return new UploadProgressListener() {\n            @Override\n            public void onProgress(final long bytesUploaded, final long totalBytes) {\n                mProgress = (int) ((bytesUploaded * 100) / totalBytes);\n                if (mUploadProgressListener != null && !isCancelled) {\n                    mUploadProgressListener.onProgress(bytesUploaded, totalBytes);\n                }\n            }\n        };\n    }\n\n    public String getDirPath() {\n        return mDirPath;\n    }\n\n    public String getFileName() {\n        return mFileName;\n    }\n\n    public CacheControl getCacheControl() {\n        return mCacheControl;\n    }\n\n    public ImageView.ScaleType getScaleType() {\n        return mScaleType;\n    }\n\n    public void cancel(boolean forceCancel) {\n        try {\n            if (forceCancel || mPercentageThresholdForCancelling == 0\n                    || mProgress < mPercentageThresholdForCancelling) {\n                isCancelled = true;\n                isRunning = false;\n                if (call != null) {\n                    call.cancel();\n                }\n                if (future != null) {\n                    future.cancel(true);\n                }\n                if (!isDelivered) {\n                    deliverError(new ANError());\n                }\n            }\n        } catch (Exception e) {\n            e.printStackTrace();\n        }\n    }\n\n    public boolean isCanceled() {\n        return isCancelled;\n    }\n\n    public boolean isRunning() {\n        return isRunning;\n    }\n\n    public void setRunning(boolean running) {\n        isRunning = running;\n    }\n\n    public Call getCall() {\n        return call;\n    }\n\n    public void setCall(Call call) {\n        this.call = call;\n    }\n\n    public Future getFuture() {\n        return future;\n    }\n\n    public void setFuture(Future future) {\n        this.future = future;\n    }\n\n    public void destroy() {\n        mJSONArrayRequestListener = null;\n        mJSONObjectRequestListener = null;\n        mStringRequestListener = null;\n        mBitmapRequestListener = null;\n        mParsedRequestListener = null;\n        mDownloadProgressListener = null;\n        mUploadProgressListener = null;\n        mDownloadListener = null;\n        mAnalyticsListener = null;\n    }\n\n    public void finish() {\n        destroy();\n        ANRequestQueue.getInstance().finish(this);\n    }\n\n    public ANResponse parseResponse(Response response) {\n        switch (mResponseType) {\n            case JSON_ARRAY:\n                try {\n                    JSONArray json = new JSONArray(Okio.buffer(response.body().source()).readUtf8());\n                    return ANResponse.success(json);\n                } catch (Exception e) {\n                    return ANResponse.failed(Utils.getErrorForParse(new ANError(e)));\n                }\n            case JSON_OBJECT:\n                try {\n                    JSONObject json = new JSONObject(Okio.buffer(response.body()\n                            .source()).readUtf8());\n                    return ANResponse.success(json);\n                } catch (Exception e) {\n                    return ANResponse.failed(Utils.getErrorForParse(new ANError(e)));\n                }\n            case STRING:\n                try {\n                    return ANResponse.success(Okio.buffer(response\n                            .body().source()).readUtf8());\n                } catch (Exception e) {\n                    return ANResponse.failed(Utils.getErrorForParse(new ANError(e)));\n                }\n            case BITMAP:\n                synchronized (sDecodeLock) {\n                    try {\n                        return Utils.decodeBitmap(response, mMaxWidth, mMaxHeight,\n                                mDecodeConfig, mScaleType);\n                    } catch (Exception e) {\n                        return ANResponse.failed(Utils.getErrorForParse(new ANError(e)));\n                    }\n                }\n            case PARSED:\n                try {\n                    return ANResponse.success(ParseUtil.getParserFactory()\n                            .responseBodyParser(mType).convert(response.body()));\n                } catch (Exception e) {\n                    return ANResponse.failed(Utils.getErrorForParse(new ANError(e)));\n                }\n            case PREFETCH:\n                try {\n                    Okio.buffer(response.body().source()).skip(Long.MAX_VALUE);\n                    return ANResponse.success(ANConstants.PREFETCH);\n                } catch (Exception e) {\n                    return ANResponse.failed(Utils.getErrorForParse(new ANError(e)));\n                }\n        }\n        return null;\n    }\n\n    public ANError parseNetworkError(ANError anError) {\n        try {\n            if (anError.getResponse() != null && anError.getResponse().body() != null\n                    && anError.getResponse().body().source() != null) {\n                anError.setErrorBody(Okio.buffer(anError\n                        .getResponse().body().source()).readUtf8());\n            }\n        } catch (Exception e) {\n            e.printStackTrace();\n        }\n        return anError;\n    }\n\n    public synchronized void deliverError(ANError anError) {\n        try {\n            if (!isDelivered) {\n                if (isCancelled) {\n                    anError.setCancellationMessageInError();\n                    anError.setErrorCode(0);\n                }\n                deliverErrorResponse(anError);\n            }\n            isDelivered = true;\n        } catch (Exception e) {\n            e.printStackTrace();\n        }\n    }\n\n\n    public void deliverResponse(final ANResponse response) {\n        try {\n            isDelivered = true;\n            if (!isCancelled) {\n                if (mExecutor != null) {\n                    mExecutor.execute(new Runnable() {\n                        @Override\n                        public void run() {\n                            deliverSuccessResponse(response);\n                        }\n                    });\n                } else {\n                    Core.getInstance().getExecutorSupplier().forMainThreadTasks().execute(new Runnable() {\n                        public void run() {\n                            deliverSuccessResponse(response);\n                        }\n                    });\n                }\n            } else {\n                ANError anError = new ANError();\n                anError.setCancellationMessageInError();\n                anError.setErrorCode(0);\n                deliverErrorResponse(anError);\n                finish();\n            }\n        } catch (Exception e) {\n            e.printStackTrace();\n        }\n    }\n\n    private void deliverSuccessResponse(ANResponse response) {\n        if (mJSONObjectRequestListener != null) {\n            mJSONObjectRequestListener.onResponse((JSONObject) response.getResult());\n        } else if (mJSONArrayRequestListener != null) {\n            mJSONArrayRequestListener.onResponse((JSONArray) response.getResult());\n        } else if (mStringRequestListener != null) {\n            mStringRequestListener.onResponse((String) response.getResult());\n        } else if (mBitmapRequestListener != null) {\n            mBitmapRequestListener.onResponse((Bitmap) response.getResult());\n        } else if (mParsedRequestListener != null) {\n            mParsedRequestListener.onResponse(response.getResult());\n        } else if (mOkHttpResponseAndJSONObjectRequestListener != null) {\n            mOkHttpResponseAndJSONObjectRequestListener.onResponse(response.getOkHttpResponse(), (JSONObject) response.getResult());\n        } else if (mOkHttpResponseAndJSONArrayRequestListener != null) {\n            mOkHttpResponseAndJSONArrayRequestListener.onResponse(response.getOkHttpResponse(), (JSONArray) response.getResult());\n        } else if (mOkHttpResponseAndStringRequestListener != null) {\n            mOkHttpResponseAndStringRequestListener.onResponse(response.getOkHttpResponse(), (String) response.getResult());\n        } else if (mOkHttpResponseAndBitmapRequestListener != null) {\n            mOkHttpResponseAndBitmapRequestListener.onResponse(response.getOkHttpResponse(), (Bitmap) response.getResult());\n        } else if (mOkHttpResponseAndParsedRequestListener != null) {\n            mOkHttpResponseAndParsedRequestListener.onResponse(response.getOkHttpResponse(), response.getResult());\n        }\n        finish();\n    }\n\n    private void deliverErrorResponse(ANError anError) {\n        if (mJSONObjectRequestListener != null) {\n            mJSONObjectRequestListener.onError(anError);\n        } else if (mJSONArrayRequestListener != null) {\n            mJSONArrayRequestListener.onError(anError);\n        } else if (mStringRequestListener != null) {\n            mStringRequestListener.onError(anError);\n        } else if (mBitmapRequestListener != null) {\n            mBitmapRequestListener.onError(anError);\n        } else if (mParsedRequestListener != null) {\n            mParsedRequestListener.onError(anError);\n        } else if (mOkHttpResponseListener != null) {\n            mOkHttpResponseListener.onError(anError);\n        } else if (mOkHttpResponseAndJSONObjectRequestListener != null) {\n            mOkHttpResponseAndJSONObjectRequestListener.onError(anError);\n        } else if (mOkHttpResponseAndJSONArrayRequestListener != null) {\n            mOkHttpResponseAndJSONArrayRequestListener.onError(anError);\n        } else if (mOkHttpResponseAndStringRequestListener != null) {\n            mOkHttpResponseAndStringRequestListener.onError(anError);\n        } else if (mOkHttpResponseAndBitmapRequestListener != null) {\n            mOkHttpResponseAndBitmapRequestListener.onError(anError);\n        } else if (mOkHttpResponseAndParsedRequestListener != null) {\n            mOkHttpResponseAndParsedRequestListener.onError(anError);\n        } else if (mDownloadListener != null) {\n            mDownloadListener.onError(anError);\n        }\n    }\n\n    public void deliverOkHttpResponse(final Response response) {\n        try {\n            isDelivered = true;\n            if (!isCancelled) {\n                if (mExecutor != null) {\n                    mExecutor.execute(new Runnable() {\n                        @Override\n                        public void run() {\n                            if (mOkHttpResponseListener != null) {\n                                mOkHttpResponseListener.onResponse(response);\n                            }\n                            finish();\n                        }\n                    });\n                } else {\n                    Core.getInstance().getExecutorSupplier().forMainThreadTasks().execute(new Runnable() {\n                        public void run() {\n                            if (mOkHttpResponseListener != null) {\n                                mOkHttpResponseListener.onResponse(response);\n                            }\n                            finish();\n                        }\n                    });\n                }\n            } else {\n                ANError anError = new ANError();\n                anError.setCancellationMessageInError();\n                anError.setErrorCode(0);\n                if (mOkHttpResponseListener != null) {\n                    mOkHttpResponseListener.onError(anError);\n                }\n                finish();\n            }\n        } catch (Exception e) {\n            e.printStackTrace();\n        }\n    }\n\n    public RequestBody getRequestBody() {\n        if (mApplicationJsonString != null) {\n            if (customMediaType != null) {\n                return RequestBody.create(customMediaType, mApplicationJsonString);\n            }\n            return RequestBody.create(JSON_MEDIA_TYPE, mApplicationJsonString);\n        } else if (mStringBody != null) {\n            if (customMediaType != null) {\n                return RequestBody.create(customMediaType, mStringBody);\n            }\n            return RequestBody.create(MEDIA_TYPE_MARKDOWN, mStringBody);\n        } else if (mFile != null) {\n            if (customMediaType != null) {\n                return RequestBody.create(customMediaType, mFile);\n            }\n            return RequestBody.create(MEDIA_TYPE_MARKDOWN, mFile);\n        } else if (mByte != null) {\n            if (customMediaType != null) {\n                return RequestBody.create(customMediaType, mByte);\n            }\n            return RequestBody.create(MEDIA_TYPE_MARKDOWN, mByte);\n        } else {\n            FormBody.Builder builder = new FormBody.Builder();\n            try {\n                for (HashMap.Entry<String, String> entry : mBodyParameterMap.entrySet()) {\n                    builder.add(entry.getKey(), entry.getValue());\n                }\n                for (HashMap.Entry<String, String> entry : mUrlEncodedFormBodyParameterMap.entrySet()) {\n                    builder.addEncoded(entry.getKey(), entry.getValue());\n                }\n            } catch (Exception e) {\n                e.printStackTrace();\n            }\n            return builder.build();\n        }\n    }\n\n    public RequestBody getMultiPartRequestBody() {\n        MultipartBody.Builder builder = new MultipartBody.Builder()\n                .setType((customMediaType == null) ? MultipartBody.FORM : customMediaType);\n        try {\n            for (HashMap.Entry<String, MultipartStringBody> entry : mMultiPartParameterMap.entrySet()) {\n                MultipartStringBody stringBody = entry.getValue();\n                MediaType mediaType = null;\n                if (stringBody.contentType != null) {\n                    mediaType = MediaType.parse(stringBody.contentType);\n                }\n                builder.addPart(Headers.of(\"Content-Disposition\",\n                        \"form-data; name=\\\"\" + entry.getKey() + \"\\\"\"),\n                        RequestBody.create(mediaType, stringBody.value));\n            }\n            for (HashMap.Entry<String, List<MultipartFileBody>> entry : mMultiPartFileMap.entrySet()) {\n                List<MultipartFileBody> fileBodies = entry.getValue();\n                for (MultipartFileBody fileBody : fileBodies) {\n                    String fileName = fileBody.file.getName();\n                    MediaType mediaType;\n                    if (fileBody.contentType != null) {\n                        mediaType = MediaType.parse(fileBody.contentType);\n                    } else {\n                        mediaType = MediaType.parse(Utils.getMimeType(fileName));\n                    }\n                    RequestBody requestBody = RequestBody.create(mediaType, fileBody.file);\n                    builder.addPart(Headers.of(\"Content-Disposition\",\n                            \"form-data; name=\\\"\" + entry.getKey() + \"\\\"; filename=\\\"\" + fileName + \"\\\"\"),\n                            requestBody);\n                }\n            }\n        } catch (Exception e) {\n            e.printStackTrace();\n        }\n        return builder.build();\n    }\n\n    public Headers getHeaders() {\n        Headers.Builder builder = new Headers.Builder();\n        try {\n            if (mHeadersMap != null) {\n                Set<Map.Entry<String, List<String>>> entries = mHeadersMap.entrySet();\n                for (Map.Entry<String, List<String>> entry : entries) {\n                    String name = entry.getKey();\n                    List<String> list = entry.getValue();\n                    if (list != null) {\n                        for (String value : list) {\n                            builder.add(name, value);\n                        }\n                    }\n                }\n            }\n        } catch (Exception e) {\n            e.printStackTrace();\n        }\n        return builder.build();\n    }\n\n    public static class HeadRequestBuilder extends GetRequestBuilder {\n\n        public HeadRequestBuilder(String url) {\n            super(url, Method.HEAD);\n        }\n    }\n\n    public static class OptionsRequestBuilder extends GetRequestBuilder {\n\n        public OptionsRequestBuilder(String url) {\n            super(url, Method.OPTIONS);\n        }\n    }\n\n    public static class GetRequestBuilder<T extends GetRequestBuilder> implements RequestBuilder {\n        private Priority mPriority = Priority.MEDIUM;\n        private int mMethod = Method.GET;\n        private String mUrl;\n        private Object mTag;\n        private Bitmap.Config mDecodeConfig;\n        private BitmapFactory.Options mBitmapOptions;\n        private int mMaxWidth;\n        private int mMaxHeight;\n        private ImageView.ScaleType mScaleType;\n        private HashMap<String, List<String>> mHeadersMap = new HashMap<>();\n        private HashMap<String, List<String>> mQueryParameterMap = new HashMap<>();\n        private HashMap<String, String> mPathParameterMap = new HashMap<>();\n        private CacheControl mCacheControl;\n        private Executor mExecutor;\n        private OkHttpClient mOkHttpClient;\n        private String mUserAgent;\n\n        public GetRequestBuilder(String url) {\n            this.mUrl = url;\n            this.mMethod = Method.GET;\n        }\n\n        public GetRequestBuilder(String url, int method) {\n            this.mUrl = url;\n            this.mMethod = method;\n        }\n\n        @Override\n        public T setPriority(Priority priority) {\n            mPriority = priority;\n            return (T) this;\n        }\n\n        @Override\n        public T setTag(Object tag) {\n            mTag = tag;\n            return (T) this;\n        }\n\n        @Override\n        public T addQueryParameter(String key, String value) {\n            List<String> list = mQueryParameterMap.get(key);\n            if (list == null) {\n                list = new ArrayList<>();\n                mQueryParameterMap.put(key, list);\n            }\n            if (!list.contains(value)) {\n                list.add(value);\n            }\n            return (T) this;\n        }\n\n        @Override\n        public T addQueryParameter(Map<String, String> queryParameterMap) {\n            if (queryParameterMap != null) {\n                for (HashMap.Entry<String, String> entry : queryParameterMap.entrySet()) {\n                    addQueryParameter(entry.getKey(), entry.getValue());\n                }\n            }\n            return (T) this;\n        }\n\n        @Override\n        public T addQueryParameter(Object object) {\n            if (object != null) {\n                return addQueryParameter(ParseUtil\n                        .getParserFactory()\n                        .getStringMap(object));\n            }\n            return (T) this;\n        }\n\n        @Override\n        public T addPathParameter(String key, String value) {\n            mPathParameterMap.put(key, value);\n            return (T) this;\n        }\n\n        @Override\n        public T addPathParameter(Map<String, String> pathParameterMap) {\n            if (pathParameterMap != null) {\n                mPathParameterMap.putAll(pathParameterMap);\n            }\n            return (T) this;\n        }\n\n        @Override\n        public T addPathParameter(Object object) {\n            if (object != null) {\n                mPathParameterMap.putAll(ParseUtil\n                        .getParserFactory()\n                        .getStringMap(object));\n            }\n            return (T) this;\n        }\n\n        @Override\n        public T addHeaders(String key, String value) {\n            List<String> list = mHeadersMap.get(key);\n            if (list == null) {\n                list = new ArrayList<>();\n                mHeadersMap.put(key, list);\n            }\n            if (!list.contains(value)) {\n                list.add(value);\n            }\n            return (T) this;\n        }\n\n        @Override\n        public T addHeaders(Map<String, String> headerMap) {\n            if (headerMap != null) {\n                for (HashMap.Entry<String, String> entry : headerMap.entrySet()) {\n                    addHeaders(entry.getKey(), entry.getValue());\n                }\n            }\n            return (T) this;\n        }\n\n        @Override\n        public T addHeaders(Object object) {\n            if (object != null) {\n                return addHeaders(ParseUtil\n                        .getParserFactory()\n                        .getStringMap(object));\n            }\n            return (T) this;\n        }\n\n        @Override\n        public T doNotCacheResponse() {\n            mCacheControl = new CacheControl.Builder().noStore().build();\n            return (T) this;\n        }\n\n        @Override\n        public T getResponseOnlyIfCached() {\n            mCacheControl = CacheControl.FORCE_CACHE;\n            return (T) this;\n        }\n\n        @Override\n        public T getResponseOnlyFromNetwork() {\n            mCacheControl = CacheControl.FORCE_NETWORK;\n            return (T) this;\n        }\n\n        @Override\n        public T setMaxAgeCacheControl(int maxAge, TimeUnit timeUnit) {\n            mCacheControl = new CacheControl.Builder().maxAge(maxAge, timeUnit).build();\n            return (T) this;\n        }\n\n        @Override\n        public T setMaxStaleCacheControl(int maxStale, TimeUnit timeUnit) {\n            mCacheControl = new CacheControl.Builder().maxStale(maxStale, timeUnit).build();\n            return (T) this;\n        }\n\n        @Override\n        public T setExecutor(Executor executor) {\n            mExecutor = executor;\n            return (T) this;\n        }\n\n        @Override\n        public T setOkHttpClient(OkHttpClient okHttpClient) {\n            mOkHttpClient = okHttpClient;\n            return (T) this;\n        }\n\n        @Override\n        public T setUserAgent(String userAgent) {\n            mUserAgent = userAgent;\n            return (T) this;\n        }\n\n        public T setBitmapConfig(Bitmap.Config bitmapConfig) {\n            mDecodeConfig = bitmapConfig;\n            return (T) this;\n        }\n\n        public T setBitmapOptions(BitmapFactory.Options bitmapOptions) {\n            mBitmapOptions = bitmapOptions;\n            return (T) this;\n        }\n\n        public T setBitmapMaxHeight(int maxHeight) {\n            mMaxHeight = maxHeight;\n            return (T) this;\n        }\n\n        public T setBitmapMaxWidth(int maxWidth) {\n            mMaxWidth = maxWidth;\n            return (T) this;\n        }\n\n        public T setImageScaleType(ImageView.ScaleType imageScaleType) {\n            mScaleType = imageScaleType;\n            return (T) this;\n        }\n\n        public ANRequest build() {\n            return new ANRequest(this);\n        }\n    }\n\n    public static class PutRequestBuilder extends PostRequestBuilder {\n\n        public PutRequestBuilder(String url) {\n            super(url, Method.PUT);\n        }\n    }\n\n    public static class DeleteRequestBuilder extends PostRequestBuilder {\n\n        public DeleteRequestBuilder(String url) {\n            super(url, Method.DELETE);\n        }\n    }\n\n    public static class PatchRequestBuilder extends PostRequestBuilder {\n\n        public PatchRequestBuilder(String url) {\n            super(url, Method.PATCH);\n        }\n    }\n\n    public static class DynamicRequestBuilder extends PostRequestBuilder {\n\n        public DynamicRequestBuilder(String url, int method) {\n            super(url, method);\n        }\n    }\n\n    public static class PostRequestBuilder<T extends PostRequestBuilder> implements RequestBuilder {\n\n        private Priority mPriority = Priority.MEDIUM;\n        private int mMethod = Method.POST;\n        private String mUrl;\n        private Object mTag;\n        private String mApplicationJsonString = null;\n        private String mStringBody = null;\n        private byte[] mByte = null;\n        private File mFile = null;\n        private HashMap<String, List<String>> mHeadersMap = new HashMap<>();\n        private HashMap<String, String> mBodyParameterMap = new HashMap<>();\n        private HashMap<String, String> mUrlEncodedFormBodyParameterMap = new HashMap<>();\n        private HashMap<String, List<String>> mQueryParameterMap = new HashMap<>();\n        private HashMap<String, String> mPathParameterMap = new HashMap<>();\n        private CacheControl mCacheControl;\n        private Executor mExecutor;\n        private OkHttpClient mOkHttpClient;\n        private String mUserAgent;\n        private String mCustomContentType;\n\n        public PostRequestBuilder(String url) {\n            this.mUrl = url;\n            this.mMethod = Method.POST;\n        }\n\n        public PostRequestBuilder(String url, int method) {\n            this.mUrl = url;\n            this.mMethod = method;\n        }\n\n        @Override\n        public T setPriority(Priority priority) {\n            mPriority = priority;\n            return (T) this;\n        }\n\n        @Override\n        public T setTag(Object tag) {\n            mTag = tag;\n            return (T) this;\n        }\n\n        @Override\n        public T addQueryParameter(String key, String value) {\n            List<String> list = mQueryParameterMap.get(key);\n            if (list == null) {\n                list = new ArrayList<>();\n                mQueryParameterMap.put(key, list);\n            }\n            if (!list.contains(value)) {\n                list.add(value);\n            }\n            return (T) this;\n        }\n\n        @Override\n        public T addQueryParameter(Map<String, String> queryParameterMap) {\n            if (queryParameterMap != null) {\n                for (HashMap.Entry<String, String> entry : queryParameterMap.entrySet()) {\n                    addQueryParameter(entry.getKey(), entry.getValue());\n                }\n            }\n            return (T) this;\n        }\n\n        @Override\n        public T addQueryParameter(Object object) {\n            if (object != null) {\n                return addQueryParameter(ParseUtil\n                        .getParserFactory()\n                        .getStringMap(object));\n            }\n            return (T) this;\n        }\n\n        @Override\n        public T addPathParameter(String key, String value) {\n            mPathParameterMap.put(key, value);\n            return (T) this;\n        }\n\n        @Override\n        public T addPathParameter(Map<String, String> pathParameterMap) {\n            if (pathParameterMap != null) {\n                mPathParameterMap.putAll(pathParameterMap);\n            }\n            return (T) this;\n        }\n\n        @Override\n        public T addPathParameter(Object object) {\n            if (object != null) {\n                mPathParameterMap.putAll(ParseUtil\n                        .getParserFactory()\n                        .getStringMap(object));\n            }\n            return (T) this;\n        }\n\n        @Override\n        public T addHeaders(String key, String value) {\n            List<String> list = mHeadersMap.get(key);\n            if (list == null) {\n                list = new ArrayList<>();\n                mHeadersMap.put(key, list);\n            }\n            if (!list.contains(value)) {\n                list.add(value);\n            }\n            return (T) this;\n        }\n\n        @Override\n        public T addHeaders(Map<String, String> headerMap) {\n            if (headerMap != null) {\n                for (HashMap.Entry<String, String> entry : headerMap.entrySet()) {\n                    addHeaders(entry.getKey(), entry.getValue());\n                }\n            }\n            return (T) this;\n        }\n\n        @Override\n        public T addHeaders(Object object) {\n            if (object != null) {\n                return addHeaders(ParseUtil\n                        .getParserFactory()\n                        .getStringMap(object));\n            }\n            return (T) this;\n        }\n\n        @Override\n        public T doNotCacheResponse() {\n            mCacheControl = new CacheControl.Builder().noStore().build();\n            return (T) this;\n        }\n\n        @Override\n        public T getResponseOnlyIfCached() {\n            mCacheControl = CacheControl.FORCE_CACHE;\n            return (T) this;\n        }\n\n        @Override\n        public T getResponseOnlyFromNetwork() {\n            mCacheControl = CacheControl.FORCE_NETWORK;\n            return (T) this;\n        }\n\n        @Override\n        public T setMaxAgeCacheControl(int maxAge, TimeUnit timeUnit) {\n            mCacheControl = new CacheControl.Builder().maxAge(maxAge, timeUnit).build();\n            return (T) this;\n        }\n\n        @Override\n        public T setMaxStaleCacheControl(int maxStale, TimeUnit timeUnit) {\n            mCacheControl = new CacheControl.Builder().maxStale(maxStale, timeUnit).build();\n            return (T) this;\n        }\n\n        @Override\n        public T setExecutor(Executor executor) {\n            mExecutor = executor;\n            return (T) this;\n        }\n\n        @Override\n        public T setOkHttpClient(OkHttpClient okHttpClient) {\n            mOkHttpClient = okHttpClient;\n            return (T) this;\n        }\n\n        @Override\n        public T setUserAgent(String userAgent) {\n            mUserAgent = userAgent;\n            return (T) this;\n        }\n\n        public T addBodyParameter(String key, String value) {\n            mBodyParameterMap.put(key, value);\n            return (T) this;\n        }\n\n        public T addBodyParameter(Map<String, String> bodyParameterMap) {\n            if (bodyParameterMap != null) {\n                mBodyParameterMap.putAll(bodyParameterMap);\n            }\n            return (T) this;\n        }\n\n        public T addBodyParameter(Object object) {\n            if (object != null) {\n                mBodyParameterMap.putAll(ParseUtil\n                        .getParserFactory()\n                        .getStringMap(object));\n            }\n            return (T) this;\n        }\n\n        public T addUrlEncodeFormBodyParameter(String key, String value) {\n            mUrlEncodedFormBodyParameterMap.put(key, value);\n            return (T) this;\n        }\n\n        public T addUrlEncodeFormBodyParameter(Map<String, String> bodyParameterMap) {\n            if (bodyParameterMap != null) {\n                mUrlEncodedFormBodyParameterMap.putAll(bodyParameterMap);\n            }\n            return (T) this;\n        }\n\n        public T addUrlEncodeFormBodyParameter(Object object) {\n            if (object != null) {\n                mUrlEncodedFormBodyParameterMap.putAll(ParseUtil\n                        .getParserFactory()\n                        .getStringMap(object));\n            }\n            return (T) this;\n        }\n\n        public T addApplicationJsonBody(Object object) {\n            if (object != null) {\n                mApplicationJsonString = ParseUtil\n                        .getParserFactory()\n                        .getString(object);\n            }\n            return (T) this;\n        }\n\n        public T addJSONObjectBody(JSONObject jsonObject) {\n            if (jsonObject != null) {\n                mApplicationJsonString = jsonObject.toString();\n            }\n            return (T) this;\n        }\n\n        public T addJSONArrayBody(JSONArray jsonArray) {\n            if (jsonArray != null) {\n                mApplicationJsonString = jsonArray.toString();\n            }\n            return (T) this;\n        }\n\n        public T addStringBody(String stringBody) {\n            mStringBody = stringBody;\n            return (T) this;\n        }\n\n        public T addFileBody(File file) {\n            mFile = file;\n            return (T) this;\n        }\n\n        public T addByteBody(byte[] bytes) {\n            mByte = bytes;\n            return (T) this;\n        }\n\n        public T setContentType(String contentType) {\n            mCustomContentType = contentType;\n            return (T) this;\n        }\n\n        public ANRequest build() {\n            return new ANRequest(this);\n        }\n    }\n\n    public static class DownloadBuilder<T extends DownloadBuilder> implements RequestBuilder {\n\n        private Priority mPriority = Priority.MEDIUM;\n        private String mUrl;\n        private Object mTag;\n        private HashMap<String, List<String>> mHeadersMap = new HashMap<>();\n        private HashMap<String, List<String>> mQueryParameterMap = new HashMap<>();\n        private HashMap<String, String> mPathParameterMap = new HashMap<>();\n        private String mDirPath;\n        private String mFileName;\n        private CacheControl mCacheControl;\n        private int mPercentageThresholdForCancelling = 0;\n        private Executor mExecutor;\n        private OkHttpClient mOkHttpClient;\n        private String mUserAgent;\n\n        public DownloadBuilder(String url, String dirPath, String fileName) {\n            this.mUrl = url;\n            this.mDirPath = dirPath;\n            this.mFileName = fileName;\n        }\n\n        @Override\n        public T setPriority(Priority priority) {\n            mPriority = priority;\n            return (T) this;\n        }\n\n        @Override\n        public T setTag(Object tag) {\n            mTag = tag;\n            return (T) this;\n        }\n\n        @Override\n        public T addHeaders(String key, String value) {\n            List<String> list = mHeadersMap.get(key);\n            if (list == null) {\n                list = new ArrayList<>();\n                mHeadersMap.put(key, list);\n            }\n            if (!list.contains(value)) {\n                list.add(value);\n            }\n            return (T) this;\n        }\n\n        @Override\n        public T addHeaders(Map<String, String> headerMap) {\n            if (headerMap != null) {\n                for (HashMap.Entry<String, String> entry : headerMap.entrySet()) {\n                    addHeaders(entry.getKey(), entry.getValue());\n                }\n            }\n            return (T) this;\n        }\n\n        @Override\n        public T addHeaders(Object object) {\n            if (object != null) {\n                return addHeaders(ParseUtil\n                        .getParserFactory()\n                        .getStringMap(object));\n            }\n            return (T) this;\n        }\n\n        @Override\n        public T addQueryParameter(String key, String value) {\n            List<String> list = mQueryParameterMap.get(key);\n            if (list == null) {\n                list = new ArrayList<>();\n                mQueryParameterMap.put(key, list);\n            }\n            if (!list.contains(value)) {\n                list.add(value);\n            }\n            return (T) this;\n        }\n\n        @Override\n        public T addQueryParameter(Map<String, String> queryParameterMap) {\n            if (queryParameterMap != null) {\n                for (HashMap.Entry<String, String> entry : queryParameterMap.entrySet()) {\n                    addQueryParameter(entry.getKey(), entry.getValue());\n                }\n            }\n            return (T) this;\n        }\n\n        @Override\n        public T addQueryParameter(Object object) {\n            if (object != null) {\n                return addQueryParameter(ParseUtil\n                        .getParserFactory()\n                        .getStringMap(object));\n            }\n            return (T) this;\n        }\n\n        @Override\n        public T addPathParameter(String key, String value) {\n            mPathParameterMap.put(key, value);\n            return (T) this;\n        }\n\n        @Override\n        public T addPathParameter(Map<String, String> pathParameterMap) {\n            if (pathParameterMap != null) {\n                mPathParameterMap.putAll(pathParameterMap);\n            }\n            return (T) this;\n        }\n\n        @Override\n        public T addPathParameter(Object object) {\n            if (object != null) {\n                mPathParameterMap.putAll(ParseUtil\n                        .getParserFactory()\n                        .getStringMap(object));\n            }\n            return (T) this;\n        }\n\n        @Override\n        public T doNotCacheResponse() {\n            mCacheControl = new CacheControl.Builder().noStore().build();\n            return (T) this;\n        }\n\n        @Override\n        public T getResponseOnlyIfCached() {\n            mCacheControl = CacheControl.FORCE_CACHE;\n            return (T) this;\n        }\n\n        @Override\n        public T getResponseOnlyFromNetwork() {\n            mCacheControl = CacheControl.FORCE_NETWORK;\n            return (T) this;\n        }\n\n        @Override\n        public T setMaxAgeCacheControl(int maxAge, TimeUnit timeUnit) {\n            mCacheControl = new CacheControl.Builder().maxAge(maxAge, timeUnit).build();\n            return (T) this;\n        }\n\n        @Override\n        public T setMaxStaleCacheControl(int maxStale, TimeUnit timeUnit) {\n            mCacheControl = new CacheControl.Builder().maxStale(maxStale, timeUnit).build();\n            return (T) this;\n        }\n\n        @Override\n        public T setExecutor(Executor executor) {\n            mExecutor = executor;\n            return (T) this;\n        }\n\n        @Override\n        public T setOkHttpClient(OkHttpClient okHttpClient) {\n            mOkHttpClient = okHttpClient;\n            return (T) this;\n        }\n\n        @Override\n        public T setUserAgent(String userAgent) {\n            mUserAgent = userAgent;\n            return (T) this;\n        }\n\n        public T setPercentageThresholdForCancelling(int percentageThresholdForCancelling) {\n            mPercentageThresholdForCancelling = percentageThresholdForCancelling;\n            return (T) this;\n        }\n\n        public ANRequest build() {\n            return new ANRequest(this);\n        }\n    }\n\n    public static class MultiPartBuilder<T extends MultiPartBuilder> implements RequestBuilder {\n\n        private Priority mPriority = Priority.MEDIUM;\n        private String mUrl;\n        private Object mTag;\n        private HashMap<String, List<String>> mHeadersMap = new HashMap<>();\n        private HashMap<String, List<String>> mQueryParameterMap = new HashMap<>();\n        private HashMap<String, String> mPathParameterMap = new HashMap<>();\n        private HashMap<String, MultipartStringBody> mMultiPartParameterMap = new HashMap<>();\n        private HashMap<String, List<MultipartFileBody>> mMultiPartFileMap = new HashMap<>();\n        private CacheControl mCacheControl;\n        private int mPercentageThresholdForCancelling = 0;\n        private Executor mExecutor;\n        private OkHttpClient mOkHttpClient;\n        private String mUserAgent;\n        private String mCustomContentType;\n\n        public MultiPartBuilder(String url) {\n            this.mUrl = url;\n        }\n\n        @Override\n        public T setPriority(Priority priority) {\n            mPriority = priority;\n            return (T) this;\n        }\n\n        @Override\n        public T setTag(Object tag) {\n            mTag = tag;\n            return (T) this;\n        }\n\n        @Override\n        public T addQueryParameter(String key, String value) {\n            List<String> list = mQueryParameterMap.get(key);\n            if (list == null) {\n                list = new ArrayList<>();\n                mQueryParameterMap.put(key, list);\n            }\n            if (!list.contains(value)) {\n                list.add(value);\n            }\n            return (T) this;\n        }\n\n        @Override\n        public T addQueryParameter(Map<String, String> queryParameterMap) {\n            if (queryParameterMap != null) {\n                for (HashMap.Entry<String, String> entry : queryParameterMap.entrySet()) {\n                    addQueryParameter(entry.getKey(), entry.getValue());\n                }\n            }\n            return (T) this;\n        }\n\n        @Override\n        public T addQueryParameter(Object object) {\n            if (object != null) {\n                return addQueryParameter(ParseUtil\n                        .getParserFactory()\n                        .getStringMap(object));\n            }\n            return (T) this;\n        }\n\n        @Override\n        public T addPathParameter(String key, String value) {\n            mPathParameterMap.put(key, value);\n            return (T) this;\n        }\n\n        @Override\n        public T addPathParameter(Map<String, String> pathParameterMap) {\n            if (pathParameterMap != null) {\n                mPathParameterMap.putAll(pathParameterMap);\n            }\n            return (T) this;\n        }\n\n        @Override\n        public T addPathParameter(Object object) {\n            if (object != null) {\n                mPathParameterMap.putAll(ParseUtil\n                        .getParserFactory()\n                        .getStringMap(object));\n            }\n            return (T) this;\n        }\n\n        @Override\n        public T addHeaders(String key, String value) {\n            List<String> list = mHeadersMap.get(key);\n            if (list == null) {\n                list = new ArrayList<>();\n                mHeadersMap.put(key, list);\n            }\n            if (!list.contains(value)) {\n                list.add(value);\n            }\n            return (T) this;\n        }\n\n        @Override\n        public T addHeaders(Map<String, String> headerMap) {\n            if (headerMap != null) {\n                for (HashMap.Entry<String, String> entry : headerMap.entrySet()) {\n                    addHeaders(entry.getKey(), entry.getValue());\n                }\n            }\n            return (T) this;\n        }\n\n        @Override\n        public T addHeaders(Object object) {\n            if (object != null) {\n                return addHeaders(ParseUtil\n                        .getParserFactory()\n                        .getStringMap(object));\n            }\n            return (T) this;\n        }\n\n        @Override\n        public T doNotCacheResponse() {\n            mCacheControl = new CacheControl.Builder().noStore().build();\n            return (T) this;\n        }\n\n        @Override\n        public T getResponseOnlyIfCached() {\n            mCacheControl = CacheControl.FORCE_CACHE;\n            return (T) this;\n        }\n\n        @Override\n        public T getResponseOnlyFromNetwork() {\n            mCacheControl = CacheControl.FORCE_NETWORK;\n            return (T) this;\n        }\n\n        @Override\n        public T setMaxAgeCacheControl(int maxAge, TimeUnit timeUnit) {\n            mCacheControl = new CacheControl.Builder().maxAge(maxAge, timeUnit).build();\n            return (T) this;\n        }\n\n        @Override\n        public T setMaxStaleCacheControl(int maxStale, TimeUnit timeUnit) {\n            mCacheControl = new CacheControl.Builder().maxStale(maxStale, timeUnit).build();\n            return (T) this;\n        }\n\n        @Override\n        public T setExecutor(Executor executor) {\n            mExecutor = executor;\n            return (T) this;\n        }\n\n        @Override\n        public T setOkHttpClient(OkHttpClient okHttpClient) {\n            mOkHttpClient = okHttpClient;\n            return (T) this;\n        }\n\n        @Override\n        public T setUserAgent(String userAgent) {\n            mUserAgent = userAgent;\n            return (T) this;\n        }\n\n        public T addMultipartParameter(String key, String value) {\n            return addMultipartParameter(key, value, null);\n        }\n\n        public T addMultipartParameter(String key, String value, String contentType) {\n            MultipartStringBody stringBody = new MultipartStringBody(value, contentType);\n            mMultiPartParameterMap.put(key, stringBody);\n            return (T) this;\n        }\n\n        public T addMultipartParameter(Map<String, String> multiPartParameterMap) {\n            return addMultipartParameter(multiPartParameterMap, null);\n        }\n\n        public T addMultipartParameter(Map<String, String> multiPartParameterMap, String contentType) {\n            if (multiPartParameterMap != null) {\n                Map<String, MultipartStringBody> parameterMap = new HashMap<>();\n                for (HashMap.Entry<String, String> entry : multiPartParameterMap.entrySet()) {\n                    MultipartStringBody stringBody = new MultipartStringBody(entry.getValue(), contentType);\n                    parameterMap.put(entry.getKey(), stringBody);\n                }\n                mMultiPartParameterMap.putAll(parameterMap);\n            }\n            return (T) this;\n        }\n\n        public T addMultipartParameter(Object object) {\n            return addMultipartParameter(object, null);\n        }\n\n        public T addMultipartParameter(Object object, String contentType) {\n            if (object != null) {\n                Map<String, String> parameterMap = ParseUtil\n                        .getParserFactory()\n                        .getStringMap(object);\n                addMultipartParameter(parameterMap, contentType);\n            }\n            return (T) this;\n        }\n\n        public T addMultipartFile(String key, File file) {\n            return addMultipartFile(key, file, null);\n        }\n\n        public T addMultipartFile(String key, File file, String contentType) {\n            MultipartFileBody fileBody = new MultipartFileBody(file, contentType);\n            addMultipartFileWithKey(key, fileBody);\n            return (T) this;\n        }\n\n        public T addMultipartFile(Map<String, File> multiPartFileMap) {\n            return addMultipartFile(multiPartFileMap, null);\n        }\n\n        public T addMultipartFile(Map<String, File> multiPartFileMap, String contentType) {\n            if (multiPartFileMap != null) {\n                for (HashMap.Entry<String, File> entry : multiPartFileMap.entrySet()) {\n                    MultipartFileBody fileBody = new MultipartFileBody(entry.getValue(), contentType);\n                    addMultipartFileWithKey(entry.getKey(), fileBody);\n                }\n            }\n            return (T) this;\n        }\n\n        public T addMultipartFileList(String key, List<File> files) {\n            return addMultipartFileList(key, files, null);\n        }\n\n        public T addMultipartFileList(String key, List<File> files, String contentType) {\n            if (files != null) {\n                for (File file : files) {\n                    MultipartFileBody fileBody = new MultipartFileBody(file, contentType);\n                    addMultipartFileWithKey(key, fileBody);\n                }\n            }\n            return (T) this;\n        }\n\n        public T addMultipartFileList(Map<String, List<File>> multiPartFileMap) {\n            return addMultipartFileList(multiPartFileMap, null);\n        }\n\n        public T addMultipartFileList(Map<String, List<File>> multiPartFileMap, String contentType) {\n            if (multiPartFileMap != null) {\n                Map<String, List<MultipartFileBody>> parameterMap = new HashMap<>();\n                for (HashMap.Entry<String, List<File>> entry : multiPartFileMap.entrySet()) {\n                    List<File> files = entry.getValue();\n                    List<MultipartFileBody> fileBodies = new ArrayList<>();\n                    for (File file : files) {\n                        MultipartFileBody fileBody = new MultipartFileBody(file, contentType);\n                        fileBodies.add(fileBody);\n                    }\n                    parameterMap.put(entry.getKey(), fileBodies);\n                }\n                mMultiPartFileMap.putAll(parameterMap);\n            }\n            return (T) this;\n        }\n\n        public T setPercentageThresholdForCancelling(int percentageThresholdForCancelling) {\n            this.mPercentageThresholdForCancelling = percentageThresholdForCancelling;\n            return (T) this;\n        }\n\n        public T setContentType(String contentType) {\n            mCustomContentType = contentType;\n            return (T) this;\n        }\n\n        private void addMultipartFileWithKey(String key, MultipartFileBody fileBody) {\n            List<MultipartFileBody> fileBodies = mMultiPartFileMap.get(key);\n            if (fileBodies == null) {\n                fileBodies = new ArrayList<>();\n            }\n            fileBodies.add(fileBody);\n            mMultiPartFileMap.put(key, fileBodies);\n        }\n\n        public ANRequest build() {\n            return new ANRequest(this);\n        }\n    }\n\n    @Override\n    public String toString() {\n        return \"ANRequest{\" +\n                \"sequenceNumber='\" + sequenceNumber +\n                \", mMethod=\" + mMethod +\n                \", mPriority=\" + mPriority +\n                \", mRequestType=\" + mRequestType +\n                \", mUrl=\" + mUrl +\n                '}';\n    }\n}\n"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/common/ANResponse.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.androidnetworking.common;\n\nimport com.androidnetworking.error.ANError;\n\nimport okhttp3.Response;\n\n/**\n * Created by amitshekhar on 22/03/16.\n */\npublic class ANResponse<T> {\n\n    private final T mResult;\n\n    private final ANError mANError;\n\n    private Response response;\n\n    public static <T> ANResponse<T> success(T result) {\n        return new ANResponse<>(result);\n    }\n\n    public static <T> ANResponse<T> failed(ANError anError) {\n        return new ANResponse<>(anError);\n    }\n\n    public ANResponse(T result) {\n        this.mResult = result;\n        this.mANError = null;\n    }\n\n    public ANResponse(ANError anError) {\n        this.mResult = null;\n        this.mANError = anError;\n    }\n\n    public T getResult() {\n        return mResult;\n    }\n\n    public boolean isSuccess() {\n        return mANError == null;\n    }\n\n    public ANError getError() {\n        return mANError;\n    }\n\n    public void setOkHttpResponse(Response response) {\n        this.response = response;\n    }\n\n    public Response getOkHttpResponse() {\n        return response;\n    }\n\n}\n"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/common/ConnectionClassManager.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.androidnetworking.common;\n\nimport com.androidnetworking.core.Core;\nimport com.androidnetworking.interfaces.ConnectionQualityChangeListener;\n\n/**\n * Created by amitshekhar on 29/05/16.\n */\npublic class ConnectionClassManager {\n\n    private static final int BYTES_TO_BITS = 8;\n    private static final int DEFAULT_SAMPLES_TO_QUALITY_CHANGE = 5;\n    private static final int MINIMUM_SAMPLES_TO_DECIDE_QUALITY = 2;\n    private static final int DEFAULT_POOR_BANDWIDTH = 150;\n    private static final int DEFAULT_MODERATE_BANDWIDTH = 550;\n    private static final int DEFAULT_GOOD_BANDWIDTH = 2000;\n    private static final long BANDWIDTH_LOWER_BOUND = 10;\n\n    private static ConnectionClassManager sInstance;\n    private ConnectionQuality mCurrentConnectionQuality = ConnectionQuality.UNKNOWN;\n    private int mCurrentBandwidthForSampling = 0;\n    private int mCurrentNumberOfSample = 0;\n    private int mCurrentBandwidth = 0;\n    private ConnectionQualityChangeListener mConnectionQualityChangeListener;\n\n    public static ConnectionClassManager getInstance() {\n        if (sInstance == null) {\n            synchronized (ConnectionClassManager.class) {\n                if (sInstance == null) {\n                    sInstance = new ConnectionClassManager();\n                }\n            }\n        }\n        return sInstance;\n    }\n\n    public synchronized void updateBandwidth(long bytes, long timeInMs) {\n        if (timeInMs == 0 || bytes < 20000 || (bytes) * 1.0 / (timeInMs) *\n                BYTES_TO_BITS < BANDWIDTH_LOWER_BOUND) {\n            return;\n        }\n        double bandwidth = (bytes) * 1.0 / (timeInMs) * BYTES_TO_BITS;\n        mCurrentBandwidthForSampling = (int) ((mCurrentBandwidthForSampling *\n                mCurrentNumberOfSample + bandwidth) / (mCurrentNumberOfSample + 1));\n        mCurrentNumberOfSample++;\n        if (mCurrentNumberOfSample == DEFAULT_SAMPLES_TO_QUALITY_CHANGE ||\n                (mCurrentConnectionQuality == ConnectionQuality.UNKNOWN &&\n                        mCurrentNumberOfSample == MINIMUM_SAMPLES_TO_DECIDE_QUALITY)) {\n            final ConnectionQuality lastConnectionQuality = mCurrentConnectionQuality;\n            mCurrentBandwidth = mCurrentBandwidthForSampling;\n            if (mCurrentBandwidthForSampling <= 0) {\n                mCurrentConnectionQuality = ConnectionQuality.UNKNOWN;\n            } else if (mCurrentBandwidthForSampling < DEFAULT_POOR_BANDWIDTH) {\n                mCurrentConnectionQuality = ConnectionQuality.POOR;\n            } else if (mCurrentBandwidthForSampling < DEFAULT_MODERATE_BANDWIDTH) {\n                mCurrentConnectionQuality = ConnectionQuality.MODERATE;\n            } else if (mCurrentBandwidthForSampling < DEFAULT_GOOD_BANDWIDTH) {\n                mCurrentConnectionQuality = ConnectionQuality.GOOD;\n            } else if (mCurrentBandwidthForSampling > DEFAULT_GOOD_BANDWIDTH) {\n                mCurrentConnectionQuality = ConnectionQuality.EXCELLENT;\n            }\n            if (mCurrentNumberOfSample == DEFAULT_SAMPLES_TO_QUALITY_CHANGE) {\n                mCurrentBandwidthForSampling = 0;\n                mCurrentNumberOfSample = 0;\n            }\n            if (mCurrentConnectionQuality != lastConnectionQuality &&\n                    mConnectionQualityChangeListener != null) {\n                Core.getInstance().getExecutorSupplier().forMainThreadTasks()\n                        .execute(new Runnable() {\n                            @Override\n                            public void run() {\n                                mConnectionQualityChangeListener\n                                        .onChange(mCurrentConnectionQuality, mCurrentBandwidth);\n                            }\n                        });\n            }\n        }\n\n    }\n\n    public int getCurrentBandwidth() {\n        return mCurrentBandwidth;\n    }\n\n    public ConnectionQuality getCurrentConnectionQuality() {\n        return mCurrentConnectionQuality;\n    }\n\n    public void setListener(ConnectionQualityChangeListener connectionQualityChangeListener) {\n        mConnectionQualityChangeListener = connectionQualityChangeListener;\n    }\n\n    public void removeListener() {\n        mConnectionQualityChangeListener = null;\n    }\n\n    public static void shutDown() {\n        if (sInstance != null) {\n            sInstance = null;\n        }\n    }\n\n}\n"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/common/ConnectionQuality.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.androidnetworking.common;\n\n/**\n * Created by amitshekhar on 29/05/16.\n */\npublic enum ConnectionQuality {\n    /**\n     * Bandwidth under 150 kbps.\n     */\n    POOR,\n    /**\n     * Bandwidth between 150 and 550 kbps.\n     */\n    MODERATE,\n    /**\n     * Bandwidth between 550 and 2000 kbps.\n     */\n    GOOD,\n    /**\n     * EXCELLENT - Bandwidth over 2000 kbps.\n     */\n    EXCELLENT,\n    /**\n     * Placeholder for unknown bandwidth. This is the initial value and will stay at this value\n     * if a bandwidth cannot be accurately found.\n     */\n    UNKNOWN\n}\n"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/common/Method.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.androidnetworking.common;\n\n/**\n * Created by amitshekhar on 26/03/16.\n */\npublic interface Method {\n    int GET = 0;\n    int POST = 1;\n    int PUT = 2;\n    int DELETE = 3;\n    int HEAD = 4;\n    int PATCH = 5;\n    int OPTIONS = 6;\n}\n"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/common/Priority.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.androidnetworking.common;\n\n/**\n * Created by amitshekhar on 22/03/16.\n */\n\n\n/**\n * Priority levels recognized by the request server.\n */\npublic enum Priority {\n    /**\n     * NOTE: DO NOT CHANGE ORDERING OF THOSE CONSTANTS UNDER ANY CIRCUMSTANCES.\n     * Doing so will make ordering incorrect.\n     */\n\n    /**\n     * Lowest priority level. Used for prefetches of data.\n     */\n    LOW,\n\n    /**\n     * Medium priority level. Used for warming of data that might soon get visible.\n     */\n    MEDIUM,\n\n    /**\n     * Highest priority level. Used for data that are currently visible on screen.\n     */\n    HIGH,\n\n    /**\n     * Highest priority level. Used for data that are required instantly(mainly for emergency).\n     */\n    IMMEDIATE\n\n}\n"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/common/RequestBuilder.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.androidnetworking.common;\n\nimport java.util.Map;\nimport java.util.concurrent.Executor;\nimport java.util.concurrent.TimeUnit;\n\nimport okhttp3.OkHttpClient;\n\n/**\n * Created by amitshekhar on 26/03/16.\n */\npublic interface RequestBuilder {\n\n    RequestBuilder setPriority(Priority priority);\n\n    RequestBuilder setTag(Object tag);\n\n    RequestBuilder addHeaders(String key, String value);\n\n    RequestBuilder addHeaders(Map<String, String> headerMap);\n\n    RequestBuilder addHeaders(Object object);\n\n    RequestBuilder addQueryParameter(String key, String value);\n\n    RequestBuilder addQueryParameter(Map<String, String> queryParameterMap);\n\n    RequestBuilder addQueryParameter(Object object);\n\n    RequestBuilder addPathParameter(String key, String value);\n\n    RequestBuilder addPathParameter(Map<String, String> pathParameterMap);\n\n    RequestBuilder addPathParameter(Object object);\n\n    RequestBuilder doNotCacheResponse();\n\n    RequestBuilder getResponseOnlyIfCached();\n\n    RequestBuilder getResponseOnlyFromNetwork();\n\n    RequestBuilder setMaxAgeCacheControl(int maxAge, TimeUnit timeUnit);\n\n    RequestBuilder setMaxStaleCacheControl(int maxStale, TimeUnit timeUnit);\n\n    RequestBuilder setExecutor(Executor executor);\n\n    RequestBuilder setOkHttpClient(OkHttpClient okHttpClient);\n\n    RequestBuilder setUserAgent(String userAgent);\n\n}\n"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/common/RequestType.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.androidnetworking.common;\n\n/**\n * Created by amitshekhar on 04/04/16.\n */\npublic interface RequestType {\n    int SIMPLE = 0;\n    int DOWNLOAD = 1;\n    int MULTIPART = 2;\n}\n"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/common/ResponseType.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.androidnetworking.common;\n\n/**\n * Created by amitshekhar on 26/03/16.\n */\npublic enum ResponseType {\n    STRING,\n    JSON_OBJECT,\n    JSON_ARRAY,\n    OK_HTTP_RESPONSE,\n    BITMAP,\n    PREFETCH,\n    PARSED\n}\n"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/core/ANExecutor.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.androidnetworking.core;\n\nimport android.net.ConnectivityManager;\nimport android.net.NetworkInfo;\nimport android.telephony.TelephonyManager;\n\nimport com.androidnetworking.common.Priority;\nimport com.androidnetworking.internal.InternalRunnable;\n\nimport java.util.concurrent.Future;\nimport java.util.concurrent.FutureTask;\nimport java.util.concurrent.PriorityBlockingQueue;\nimport java.util.concurrent.ThreadFactory;\nimport java.util.concurrent.ThreadPoolExecutor;\nimport java.util.concurrent.TimeUnit;\n\n/**\n * Created by amitshekhar on 22/03/16.\n */\npublic class ANExecutor extends ThreadPoolExecutor {\n\n    private static final int DEFAULT_THREAD_COUNT = 3;\n\n    ANExecutor(int maxNumThreads, ThreadFactory threadFactory) {\n        super(maxNumThreads, maxNumThreads, 0, TimeUnit.MILLISECONDS,\n                new PriorityBlockingQueue<Runnable>(), threadFactory);\n    }\n\n\n    void adjustThreadCount(NetworkInfo info) {\n        if (info == null || !info.isConnectedOrConnecting()) {\n            setThreadCount(DEFAULT_THREAD_COUNT);\n            return;\n        }\n        switch (info.getType()) {\n            case ConnectivityManager.TYPE_WIFI:\n            case ConnectivityManager.TYPE_WIMAX:\n            case ConnectivityManager.TYPE_ETHERNET:\n                setThreadCount(4);\n                break;\n            case ConnectivityManager.TYPE_MOBILE:\n                switch (info.getSubtype()) {\n                    case TelephonyManager.NETWORK_TYPE_LTE:  // 4G\n                    case TelephonyManager.NETWORK_TYPE_HSPAP:\n                    case TelephonyManager.NETWORK_TYPE_EHRPD:\n                        setThreadCount(3);\n                        break;\n                    case TelephonyManager.NETWORK_TYPE_UMTS: // 3G\n                    case TelephonyManager.NETWORK_TYPE_CDMA:\n                    case TelephonyManager.NETWORK_TYPE_EVDO_0:\n                    case TelephonyManager.NETWORK_TYPE_EVDO_A:\n                    case TelephonyManager.NETWORK_TYPE_EVDO_B:\n                        setThreadCount(2);\n                        break;\n                    case TelephonyManager.NETWORK_TYPE_GPRS: // 2G\n                    case TelephonyManager.NETWORK_TYPE_EDGE:\n                        setThreadCount(1);\n                        break;\n                    default:\n                        setThreadCount(DEFAULT_THREAD_COUNT);\n                }\n                break;\n            default:\n                setThreadCount(DEFAULT_THREAD_COUNT);\n        }\n    }\n\n    private void setThreadCount(int threadCount) {\n        setCorePoolSize(threadCount);\n        setMaximumPoolSize(threadCount);\n    }\n\n    @Override\n    public Future<?> submit(Runnable task) {\n        AndroidNetworkingFutureTask futureTask = new AndroidNetworkingFutureTask((InternalRunnable) task);\n        execute(futureTask);\n        return futureTask;\n    }\n\n    private static final class AndroidNetworkingFutureTask extends FutureTask<InternalRunnable>\n            implements Comparable<AndroidNetworkingFutureTask> {\n        private final InternalRunnable hunter;\n\n        public AndroidNetworkingFutureTask(InternalRunnable hunter) {\n            super(hunter, null);\n            this.hunter = hunter;\n        }\n\n        @Override\n        public int compareTo(AndroidNetworkingFutureTask other) {\n            Priority p1 = hunter.getPriority();\n            Priority p2 = other.hunter.getPriority();\n            return (p1 == p2 ? hunter.sequence - other.hunter.sequence : p2.ordinal() - p1.ordinal());\n        }\n    }\n}\n"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/core/Core.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.androidnetworking.core;\n\n/**\n * Created by amitshekhar on 22/03/16.\n */\npublic class Core {\n\n    private static Core sInstance = null;\n    private final ExecutorSupplier mExecutorSupplier;\n\n    private Core() {\n        this.mExecutorSupplier = new DefaultExecutorSupplier();\n    }\n\n    public static Core getInstance() {\n        if (sInstance == null) {\n            synchronized (Core.class) {\n                if (sInstance == null) {\n                    sInstance = new Core();\n                }\n            }\n        }\n        return sInstance;\n    }\n\n    public ExecutorSupplier getExecutorSupplier() {\n        return mExecutorSupplier;\n    }\n\n    public static void shutDown() {\n        if (sInstance != null) {\n            sInstance = null;\n        }\n    }\n}\n"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/core/DefaultExecutorSupplier.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.androidnetworking.core;\n\nimport android.os.Process;\n\nimport java.util.concurrent.Executor;\nimport java.util.concurrent.ThreadFactory;\n\n/**\n * Created by amitshekhar on 22/03/16.\n */\npublic class DefaultExecutorSupplier implements ExecutorSupplier {\n\n    public static final int DEFAULT_MAX_NUM_THREADS = 2 * Runtime.getRuntime().availableProcessors() + 1;\n    private final ANExecutor mNetworkExecutor;\n    private final ANExecutor mImmediateNetworkExecutor;\n    private final Executor mMainThreadExecutor;\n\n    public DefaultExecutorSupplier() {\n        ThreadFactory backgroundPriorityThreadFactory = new PriorityThreadFactory(Process.THREAD_PRIORITY_BACKGROUND);\n        mNetworkExecutor = new ANExecutor(DEFAULT_MAX_NUM_THREADS, backgroundPriorityThreadFactory);\n        mImmediateNetworkExecutor = new ANExecutor(2, backgroundPriorityThreadFactory);\n        mMainThreadExecutor = new MainThreadExecutor();\n    }\n\n    @Override\n    public ANExecutor forNetworkTasks() {\n        return mNetworkExecutor;\n    }\n\n    @Override\n    public ANExecutor forImmediateNetworkTasks() {\n        return mImmediateNetworkExecutor;\n    }\n\n    @Override\n    public Executor forMainThreadTasks() {\n        return mMainThreadExecutor;\n    }\n}\n"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/core/ExecutorSupplier.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.androidnetworking.core;\n\nimport java.util.concurrent.Executor;\n\n/**\n * Created by amitshekhar on 22/03/16.\n */\npublic interface ExecutorSupplier {\n\n    ANExecutor forNetworkTasks();\n\n    ANExecutor forImmediateNetworkTasks();\n\n    Executor forMainThreadTasks();\n}\n"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/core/MainThreadExecutor.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.androidnetworking.core;\n\nimport android.os.Handler;\nimport android.os.Looper;\n\nimport java.util.concurrent.Executor;\n\n/**\n * Created by amitshekhar on 22/03/16.\n */\npublic class MainThreadExecutor implements Executor {\n\n    private final Handler handler = new Handler(Looper.getMainLooper());\n\n    @Override\n    public void execute(Runnable runnable) {\n        handler.post(runnable);\n    }\n}\n"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/core/PriorityThreadFactory.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.androidnetworking.core;\n\n/**\n * Created by amitshekhar on 22/03/16.\n */\n\n\nimport android.os.Process;\n\nimport java.util.concurrent.ThreadFactory;\n\npublic class PriorityThreadFactory implements ThreadFactory {\n\n    private final int mThreadPriority;\n\n    public PriorityThreadFactory(int threadPriority) {\n        mThreadPriority = threadPriority;\n    }\n\n    @Override\n    public Thread newThread(final Runnable runnable) {\n        Runnable wrapperRunnable = new Runnable() {\n            @Override\n            public void run() {\n                try {\n                    Process.setThreadPriority(mThreadPriority);\n                } catch (Throwable t) {\n\n                }\n                runnable.run();\n            }\n        };\n        return new Thread(wrapperRunnable);\n    }\n\n}\n"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/error/ANError.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.androidnetworking.error;\n\nimport com.androidnetworking.common.ANConstants;\nimport com.androidnetworking.utils.ParseUtil;\n\nimport okhttp3.Response;\n\n/**\n * Created by amitshekhar on 22/03/16.\n */\n@SuppressWarnings({\"unchecked\", \"unused\"})\npublic class ANError extends Exception {\n\n    private String errorBody;\n\n    private int errorCode = 0;\n\n    private String errorDetail;\n\n    private Response response;\n\n    public ANError() {\n    }\n\n    public ANError(Response response) {\n        this.response = response;\n    }\n\n    public ANError(String message) {\n        super(message);\n    }\n\n    public ANError(String message, Response response) {\n        super(message);\n        this.response = response;\n    }\n\n    public ANError(String message, Throwable throwable) {\n        super(message, throwable);\n    }\n\n    public ANError(String message, Response response, Throwable throwable) {\n        super(message, throwable);\n        this.response = response;\n    }\n\n    public ANError(Response response, Throwable throwable) {\n        super(throwable);\n        this.response = response;\n    }\n\n    public ANError(Throwable throwable) {\n        super(throwable);\n    }\n\n    public Response getResponse() {\n        return response;\n    }\n\n    public void setErrorDetail(String errorDetail) {\n        this.errorDetail = errorDetail;\n    }\n\n    public String getErrorDetail() {\n        return this.errorDetail;\n    }\n\n    public void setErrorCode(int errorCode) {\n        this.errorCode = errorCode;\n    }\n\n    public int getErrorCode() {\n        return this.errorCode;\n    }\n\n    public void setCancellationMessageInError() {\n        this.errorDetail = ANConstants.REQUEST_CANCELLED_ERROR;\n    }\n\n    public String getErrorBody() {\n        return errorBody;\n    }\n\n    public void setErrorBody(String errorBody) {\n        this.errorBody = errorBody;\n    }\n\n    public <T> T getErrorAsObject(Class<T> objectClass) {\n        try {\n            return (T) (ParseUtil\n                    .getParserFactory()\n                    .getObject(errorBody, objectClass));\n        } catch (Exception e) {\n            e.printStackTrace();\n        }\n        return null;\n    }\n}\n"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/gsonparserfactory/GsonParserFactory.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.androidnetworking.gsonparserfactory;\n\nimport com.androidnetworking.interfaces.Parser;\nimport com.google.gson.Gson;\nimport com.google.gson.TypeAdapter;\nimport com.google.gson.reflect.TypeToken;\n\nimport java.lang.reflect.Type;\nimport java.util.HashMap;\n\nimport okhttp3.RequestBody;\nimport okhttp3.ResponseBody;\n\n/**\n * Created by amitshekhar on 31/07/16.\n */\npublic final class GsonParserFactory extends Parser.Factory {\n\n    private final Gson gson;\n\n    public GsonParserFactory() {\n        this.gson = new Gson();\n    }\n\n    public GsonParserFactory(Gson gson) {\n        this.gson = gson;\n    }\n\n    @Override\n    public Parser<ResponseBody, ?> responseBodyParser(Type type) {\n        TypeAdapter<?> adapter = gson.getAdapter(TypeToken.get(type));\n        return new GsonResponseBodyParser<>(gson, adapter);\n    }\n\n    @Override\n    public Parser<?, RequestBody> requestBodyParser(Type type) {\n        TypeAdapter<?> adapter = gson.getAdapter(TypeToken.get(type));\n        return new GsonRequestBodyParser<>(gson, adapter);\n    }\n\n    @Override\n    public Object getObject(String string, Type type) {\n        try {\n            return gson.fromJson(string, type);\n        } catch (Exception e) {\n            e.printStackTrace();\n        }\n        return null;\n    }\n\n    @Override\n    public String getString(Object object) {\n        try {\n            return gson.toJson(object);\n        } catch (Exception e) {\n            e.printStackTrace();\n        }\n        return \"\";\n    }\n\n    @Override\n    public HashMap<String, String> getStringMap(Object object) {\n        try {\n            Type type = new TypeToken<HashMap<String, String>>() {\n            }.getType();\n            return gson.fromJson(gson.toJson(object), type);\n        } catch (Exception e) {\n            e.printStackTrace();\n        }\n        return new HashMap<>();\n    }\n}\n"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/gsonparserfactory/GsonRequestBodyParser.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.androidnetworking.gsonparserfactory;\n\nimport com.androidnetworking.interfaces.Parser;\nimport com.google.gson.Gson;\nimport com.google.gson.TypeAdapter;\nimport com.google.gson.stream.JsonWriter;\n\nimport java.io.IOException;\nimport java.io.OutputStreamWriter;\nimport java.io.Writer;\nimport java.nio.charset.Charset;\n\nimport okhttp3.MediaType;\nimport okhttp3.RequestBody;\nimport okio.Buffer;\n\n/**\n * Created by amitshekhar on 31/07/16.\n */\nfinal class GsonRequestBodyParser<T> implements Parser<T, RequestBody> {\n    private static final MediaType MEDIA_TYPE = MediaType.parse(\"application/json; charset=UTF-8\");\n    private static final Charset UTF_8 = Charset.forName(\"UTF-8\");\n\n    private final Gson gson;\n    private final TypeAdapter<T> adapter;\n\n    GsonRequestBodyParser(Gson gson, TypeAdapter<T> adapter) {\n        this.gson = gson;\n        this.adapter = adapter;\n    }\n\n    @Override\n    public RequestBody convert(T value) throws IOException {\n        Buffer buffer = new Buffer();\n        Writer writer = new OutputStreamWriter(buffer.outputStream(), UTF_8);\n        JsonWriter jsonWriter = gson.newJsonWriter(writer);\n        adapter.write(jsonWriter, value);\n        jsonWriter.close();\n        return RequestBody.create(MEDIA_TYPE, buffer.readByteString());\n    }\n}\n"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/gsonparserfactory/GsonResponseBodyParser.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.androidnetworking.gsonparserfactory;\n\nimport com.androidnetworking.interfaces.Parser;\nimport com.google.gson.Gson;\nimport com.google.gson.TypeAdapter;\nimport com.google.gson.stream.JsonReader;\n\nimport java.io.IOException;\n\nimport okhttp3.ResponseBody;\n\n/**\n * Created by amitshekhar on 31/07/16.\n */\nfinal class GsonResponseBodyParser<T> implements Parser<ResponseBody, T> {\n    private final Gson gson;\n    private final TypeAdapter<T> adapter;\n\n    GsonResponseBodyParser(Gson gson, TypeAdapter<T> adapter) {\n        this.gson = gson;\n        this.adapter = adapter;\n    }\n\n    @Override\n    public T convert(ResponseBody value) throws IOException {\n        JsonReader jsonReader = gson.newJsonReader(value.charStream());\n        try {\n            return adapter.read(jsonReader);\n        } finally {\n            value.close();\n        }\n    }\n}\n"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/interceptors/GzipRequestInterceptor.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.androidnetworking.interceptors;\n\nimport java.io.IOException;\n\nimport okhttp3.Interceptor;\nimport okhttp3.MediaType;\nimport okhttp3.Request;\nimport okhttp3.RequestBody;\nimport okhttp3.Response;\nimport okio.Buffer;\nimport okio.BufferedSink;\nimport okio.GzipSink;\nimport okio.Okio;\n\n/**\n * Created by amitshekhar on 02/05/16.\n */\npublic class GzipRequestInterceptor implements Interceptor {\n    @Override\n    public Response intercept(Chain chain) throws IOException {\n        Request originalRequest = chain.request();\n        if (originalRequest.body() == null || originalRequest.header(\"Content-Encoding\") != null) {\n            return chain.proceed(originalRequest);\n        }\n\n        Request compressedRequest = originalRequest.newBuilder()\n                .header(\"Content-Encoding\", \"gzip\")\n                .method(originalRequest.method(), forceContentLength(gzip(originalRequest.body())))\n                .build();\n        return chain.proceed(compressedRequest);\n    }\n\n    private RequestBody forceContentLength(final RequestBody requestBody) throws IOException {\n        final Buffer buffer = new Buffer();\n        requestBody.writeTo(buffer);\n        return new RequestBody() {\n            @Override\n            public MediaType contentType() {\n                return requestBody.contentType();\n            }\n\n            @Override\n            public long contentLength() {\n                return buffer.size();\n            }\n\n            @Override\n            public void writeTo(BufferedSink sink) throws IOException {\n                sink.write(buffer.snapshot());\n            }\n        };\n    }\n\n\n    private RequestBody gzip(final RequestBody body) {\n        return new RequestBody() {\n            @Override\n            public MediaType contentType() {\n                return body.contentType();\n            }\n\n            @Override\n            public long contentLength() {\n                return -1; // We don't know the compressed length in advance!\n            }\n\n            @Override\n            public void writeTo(BufferedSink sink) throws IOException {\n                BufferedSink gzipSink = Okio.buffer(new GzipSink(sink));\n                body.writeTo(gzipSink);\n                gzipSink.close();\n            }\n        };\n    }\n}"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/interceptors/HttpLoggingInterceptor.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.androidnetworking.interceptors;\n\nimport java.io.EOFException;\nimport java.io.IOException;\nimport java.nio.charset.Charset;\nimport java.util.concurrent.TimeUnit;\n\nimport okhttp3.Connection;\nimport okhttp3.Headers;\nimport okhttp3.Interceptor;\nimport okhttp3.MediaType;\nimport okhttp3.Protocol;\nimport okhttp3.Request;\nimport okhttp3.RequestBody;\nimport okhttp3.Response;\nimport okhttp3.ResponseBody;\nimport okhttp3.internal.http.HttpHeaders;\nimport okhttp3.internal.platform.Platform;\nimport okio.Buffer;\nimport okio.BufferedSource;\n\nimport static okhttp3.internal.platform.Platform.INFO;\n\n/**\n * Created by amitshekhar on 31/01/17.\n */\n\npublic class HttpLoggingInterceptor implements Interceptor {\n\n    private static final Charset UTF8 = Charset.forName(\"UTF-8\");\n\n    public enum Level {\n        /**\n         * No logs.\n         */\n        NONE,\n        /**\n         * Logs request and response lines.\n         * <p>\n         * <p>Example:\n         * <pre>{@code\n         * --> POST /greeting http/1.1 (3-byte body)\n         *\n         * <-- 200 OK (22ms, 6-byte body)\n         * }</pre>\n         */\n        BASIC,\n        /**\n         * Logs request and response lines and their respective headers.\n         * <p>\n         * <p>Example:\n         * <pre>{@code\n         * --> POST /greeting http/1.1\n         * Host: example.com\n         * Content-Type: plain/text\n         * Content-Length: 3\n         * --> END POST\n         *\n         * <-- 200 OK (22ms)\n         * Content-Type: plain/text\n         * Content-Length: 6\n         * <-- END HTTP\n         * }</pre>\n         */\n        HEADERS,\n        /**\n         * Logs request and response lines and their respective headers and bodies (if present).\n         * <p>\n         * <p>Example:\n         * <pre>{@code\n         * --> POST /greeting http/1.1\n         * Host: example.com\n         * Content-Type: plain/text\n         * Content-Length: 3\n         *\n         * Hi?\n         * --> END POST\n         *\n         * <-- 200 OK (22ms)\n         * Content-Type: plain/text\n         * Content-Length: 6\n         *\n         * Hello!\n         * <-- END HTTP\n         * }</pre>\n         */\n        BODY\n    }\n\n    public interface Logger {\n        void log(String message);\n\n        /**\n         * A {@link Logger} defaults output appropriate for the current platform.\n         */\n        Logger DEFAULT = new Logger() {\n            @Override\n            public void log(String message) {\n                Platform.get().log(INFO, message, null);\n            }\n        };\n    }\n\n    public HttpLoggingInterceptor() {\n        this(Logger.DEFAULT);\n    }\n\n    public HttpLoggingInterceptor(Logger logger) {\n        this.logger = logger;\n    }\n\n    private final Logger logger;\n\n    private volatile Level level = Level.NONE;\n\n    /**\n     * Change the level at which this interceptor logs.\n     */\n    public HttpLoggingInterceptor setLevel(Level level) {\n        if (level == null) throw new NullPointerException(\"level == null. Use Level.NONE instead.\");\n        this.level = level;\n        return this;\n    }\n\n    public Level getLevel() {\n        return level;\n    }\n\n    @Override\n    public Response intercept(Chain chain) throws IOException {\n        Level level = this.level;\n\n        Request request = chain.request();\n        if (level == Level.NONE) {\n            return chain.proceed(request);\n        }\n\n        boolean logBody = level == Level.BODY;\n        boolean logHeaders = logBody || level == Level.HEADERS;\n\n        RequestBody requestBody = request.body();\n        boolean hasRequestBody = requestBody != null;\n\n        Connection connection = chain.connection();\n        Protocol protocol = connection != null ? connection.protocol() : Protocol.HTTP_1_1;\n        String requestStartMessage = \"--> \" + request.method() + ' ' + request.url() + ' ' + protocol;\n        if (!logHeaders && hasRequestBody) {\n            requestStartMessage += \" (\" + requestBody.contentLength() + \"-byte body)\";\n        }\n        logger.log(requestStartMessage);\n\n        if (logHeaders) {\n            if (hasRequestBody) {\n                // Request body headers are only present when installed as a network interceptor. Force\n                // them to be included (when available) so there values are known.\n                if (requestBody.contentType() != null) {\n                    logger.log(\"Content-Type: \" + requestBody.contentType());\n                }\n                if (requestBody.contentLength() != -1) {\n                    logger.log(\"Content-Length: \" + requestBody.contentLength());\n                }\n            }\n\n            Headers headers = request.headers();\n            for (int i = 0, count = headers.size(); i < count; i++) {\n                String name = headers.name(i);\n                // Skip headers from the request body as they are explicitly logged above.\n                if (!\"Content-Type\".equalsIgnoreCase(name) && !\"Content-Length\".equalsIgnoreCase(name)) {\n                    logger.log(name + \": \" + headers.value(i));\n                }\n            }\n\n            if (!logBody || !hasRequestBody) {\n                logger.log(\"--> END \" + request.method());\n            } else if (bodyEncoded(request.headers())) {\n                logger.log(\"--> END \" + request.method() + \" (encoded body omitted)\");\n            } else {\n                Buffer buffer = new Buffer();\n                requestBody.writeTo(buffer);\n\n                Charset charset = UTF8;\n                MediaType contentType = requestBody.contentType();\n                if (contentType != null) {\n                    charset = contentType.charset(UTF8);\n                }\n\n                logger.log(\"\");\n                if (isPlaintext(buffer)) {\n                    logger.log(buffer.readString(charset));\n                    logger.log(\"--> END \" + request.method()\n                            + \" (\" + requestBody.contentLength() + \"-byte body)\");\n                } else {\n                    logger.log(\"--> END \" + request.method() + \" (binary \"\n                            + requestBody.contentLength() + \"-byte body omitted)\");\n                }\n            }\n        }\n\n        long startNs = System.nanoTime();\n        Response response;\n        try {\n            response = chain.proceed(request);\n        } catch (Exception e) {\n            logger.log(\"<-- HTTP FAILED: \" + e);\n            throw e;\n        }\n        long tookMs = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startNs);\n\n        ResponseBody responseBody = response.body();\n        long contentLength = responseBody.contentLength();\n        String bodySize = contentLength != -1 ? contentLength + \"-byte\" : \"unknown-length\";\n        logger.log(\"<-- \" + response.code() + ' ' + response.message() + ' '\n                + response.request().url() + \" (\" + tookMs + \"ms\" + (!logHeaders ? \", \"\n                + bodySize + \" body\" : \"\") + ')');\n\n        if (logHeaders) {\n            Headers headers = response.headers();\n            for (int i = 0, count = headers.size(); i < count; i++) {\n                logger.log(headers.name(i) + \": \" + headers.value(i));\n            }\n\n            if (!logBody || !HttpHeaders.hasBody(response)) {\n                logger.log(\"<-- END HTTP\");\n            } else if (bodyEncoded(response.headers())) {\n                logger.log(\"<-- END HTTP (encoded body omitted)\");\n            } else {\n                BufferedSource source = responseBody.source();\n                source.request(Long.MAX_VALUE); // Buffer the entire body.\n                Buffer buffer = source.buffer();\n\n                Charset charset = UTF8;\n                MediaType contentType = responseBody.contentType();\n                if (contentType != null) {\n                    charset = contentType.charset(UTF8);\n                }\n\n                if (!isPlaintext(buffer)) {\n                    logger.log(\"\");\n                    logger.log(\"<-- END HTTP (binary \" + buffer.size() + \"-byte body omitted)\");\n                    return response;\n                }\n\n                if (contentLength != 0) {\n                    logger.log(\"\");\n                    logger.log(buffer.clone().readString(charset));\n                }\n\n                logger.log(\"<-- END HTTP (\" + buffer.size() + \"-byte body)\");\n            }\n        }\n\n        return response;\n    }\n\n    /**\n     * Returns true if the body in question probably contains human readable text. Uses a small sample\n     * of code points to detect unicode control characters commonly used in binary file signatures.\n     */\n    static boolean isPlaintext(Buffer buffer) {\n        try {\n            Buffer prefix = new Buffer();\n            long byteCount = buffer.size() < 64 ? buffer.size() : 64;\n            buffer.copyTo(prefix, 0, byteCount);\n            for (int i = 0; i < 16; i++) {\n                if (prefix.exhausted()) {\n                    break;\n                }\n                int codePoint = prefix.readUtf8CodePoint();\n                if (Character.isISOControl(codePoint) && !Character.isWhitespace(codePoint)) {\n                    return false;\n                }\n            }\n            return true;\n        } catch (EOFException e) {\n            return false; // Truncated UTF-8 sequence.\n        }\n    }\n\n    private boolean bodyEncoded(Headers headers) {\n        String contentEncoding = headers.get(\"Content-Encoding\");\n        return contentEncoding != null && !contentEncoding.equalsIgnoreCase(\"identity\");\n    }\n}\n"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/interfaces/AnalyticsListener.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.androidnetworking.interfaces;\n\n/**\n * Created by amitshekhar on 31/05/16.\n */\npublic interface AnalyticsListener {\n\n    void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache);\n\n}\n"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/interfaces/BitmapRequestListener.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.androidnetworking.interfaces;\n\nimport android.graphics.Bitmap;\n\nimport com.androidnetworking.error.ANError;\n\n/**\n * Created by amitshekhar on 23/05/16.\n */\npublic interface BitmapRequestListener {\n\n    void onResponse(Bitmap response);\n\n    void onError(ANError anError);\n\n}\n"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/interfaces/ConnectionQualityChangeListener.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.androidnetworking.interfaces;\n\nimport com.androidnetworking.common.ConnectionQuality;\n\n/**\n * Created by amitshekhar on 29/05/16.\n */\npublic interface ConnectionQualityChangeListener {\n\n    void onChange(ConnectionQuality currentConnectionQuality, int currentBandwidth);\n}\n"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/interfaces/DownloadListener.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.androidnetworking.interfaces;\n\nimport com.androidnetworking.error.ANError;\n\n/**\n * Created by amitshekhar on 29/04/16.\n */\npublic interface DownloadListener {\n\n    void onDownloadComplete();\n\n    void onError(ANError anError);\n}\n"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/interfaces/DownloadProgressListener.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.androidnetworking.interfaces;\n\n/**\n * Created by amitshekhar on 30/03/16.\n */\npublic interface DownloadProgressListener {\n    void onProgress(long bytesDownloaded, long totalBytes);\n}\n"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/interfaces/JSONArrayRequestListener.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.androidnetworking.interfaces;\n\nimport com.androidnetworking.error.ANError;\n\nimport org.json.JSONArray;\n\n/**\n * Created by amitshekhar on 23/05/16.\n */\npublic interface JSONArrayRequestListener {\n\n    void onResponse(JSONArray response);\n\n    void onError(ANError anError);\n\n}\n"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/interfaces/JSONObjectRequestListener.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.androidnetworking.interfaces;\n\nimport com.androidnetworking.error.ANError;\n\nimport org.json.JSONObject;\n\n/**\n * Created by amitshekhar on 23/05/16.\n */\npublic interface JSONObjectRequestListener {\n\n    void onResponse(JSONObject response);\n\n    void onError(ANError anError);\n\n}\n"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/interfaces/OkHttpResponseAndBitmapRequestListener.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.androidnetworking.interfaces;\n\nimport android.graphics.Bitmap;\n\nimport com.androidnetworking.error.ANError;\n\nimport okhttp3.Response;\n\n/**\n * Created by amitshekhar on 23/05/16.\n */\npublic interface OkHttpResponseAndBitmapRequestListener {\n\n    void onResponse(Response okHttpResponse, Bitmap response);\n\n    void onError(ANError anError);\n\n}\n"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/interfaces/OkHttpResponseAndJSONArrayRequestListener.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.androidnetworking.interfaces;\n\nimport com.androidnetworking.error.ANError;\n\nimport org.json.JSONArray;\n\nimport okhttp3.Response;\n\n/**\n * Created by amitshekhar on 23/05/16.\n */\npublic interface OkHttpResponseAndJSONArrayRequestListener {\n\n    void onResponse(Response okHttpResponse, JSONArray response);\n\n    void onError(ANError anError);\n\n}\n"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/interfaces/OkHttpResponseAndJSONObjectRequestListener.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.androidnetworking.interfaces;\n\nimport com.androidnetworking.error.ANError;\n\nimport org.json.JSONObject;\n\nimport okhttp3.Response;\n\n/**\n * Created by amitshekhar on 23/05/16.\n */\npublic interface OkHttpResponseAndJSONObjectRequestListener {\n\n    void onResponse(Response okHttpResponse, JSONObject response);\n\n    void onError(ANError anError);\n\n}\n"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/interfaces/OkHttpResponseAndParsedRequestListener.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.androidnetworking.interfaces;\n\nimport com.androidnetworking.error.ANError;\n\nimport okhttp3.Response;\n\n/**\n * Created by amitshekhar on 31/07/16.\n */\npublic interface OkHttpResponseAndParsedRequestListener<T> {\n\n    void onResponse(Response okHttpResponse, T response);\n\n    void onError(ANError anError);\n\n}"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/interfaces/OkHttpResponseAndStringRequestListener.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.androidnetworking.interfaces;\n\nimport com.androidnetworking.error.ANError;\n\nimport okhttp3.Response;\n\n/**\n * Created by amitshekhar on 23/05/16.\n */\npublic interface OkHttpResponseAndStringRequestListener {\n\n    void onResponse(Response okHttpResponse, String response);\n\n    void onError(ANError anError);\n\n}\n"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/interfaces/OkHttpResponseListener.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.androidnetworking.interfaces;\n\nimport com.androidnetworking.error.ANError;\n\nimport okhttp3.Response;\n\n/**\n * Created by amitshekhar on 22/08/16.\n */\npublic interface OkHttpResponseListener {\n\n    void onResponse(Response response);\n\n    void onError(ANError anError);\n\n}\n"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/interfaces/ParsedRequestListener.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.androidnetworking.interfaces;\n\nimport com.androidnetworking.error.ANError;\n\n/**\n * Created by amitshekhar on 31/07/16.\n */\npublic interface ParsedRequestListener<T> {\n\n    void onResponse(T response);\n\n    void onError(ANError anError);\n\n}"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/interfaces/Parser.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.androidnetworking.interfaces;\n\nimport java.io.IOException;\nimport java.lang.reflect.Type;\nimport java.util.HashMap;\n\nimport okhttp3.RequestBody;\nimport okhttp3.ResponseBody;\n\n/**\n * Created by amitshekhar on 31/07/16.\n */\npublic interface Parser<F, T> {\n\n    T convert(F value) throws IOException;\n\n    abstract class Factory {\n\n        public Parser<ResponseBody, ?> responseBodyParser(Type type) {\n            return null;\n        }\n\n        public Parser<?, RequestBody> requestBodyParser(Type type) {\n            return null;\n        }\n\n        public Object getObject(String string, Type type) {\n            return null;\n        }\n\n        public String getString(Object object) {\n            return null;\n        }\n\n        public HashMap<String, String> getStringMap(Object object) {\n            return null;\n        }\n\n    }\n\n}"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/interfaces/StringRequestListener.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.androidnetworking.interfaces;\n\nimport com.androidnetworking.error.ANError;\n\n/**\n * Created by amitshekhar on 23/05/16.\n */\npublic interface StringRequestListener {\n\n    void onResponse(String response);\n\n    void onError(ANError anError);\n\n}\n"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/interfaces/UploadProgressListener.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.androidnetworking.interfaces;\n\n/**\n * Created by amitshekhar on 21/04/16.\n */\npublic interface UploadProgressListener {\n    void onProgress(long bytesUploaded, long totalBytes);\n}\n"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/internal/ANImageLoader.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.androidnetworking.internal;\n\nimport android.graphics.Bitmap;\nimport android.graphics.BitmapFactory;\nimport android.os.Handler;\nimport android.os.Looper;\nimport android.widget.ImageView;\n\nimport com.androidnetworking.AndroidNetworking;\nimport com.androidnetworking.cache.LruBitmapCache;\nimport com.androidnetworking.common.ANRequest;\nimport com.androidnetworking.error.ANError;\nimport com.androidnetworking.interfaces.BitmapRequestListener;\n\nimport java.util.HashMap;\nimport java.util.LinkedList;\n\n/**\n * Created by amitshekhar on 23/03/16.\n */\npublic class ANImageLoader {\n\n    // Get max available VM memory, exceeding this amount will throw an\n    // OutOfMemory exception. Stored in kilobytes as LruCache takes an\n    // int in its constructor.\n    private static final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024);\n\n    // Use 1/8th of the available memory for this memory cache.\n    private static final int cacheSize = maxMemory / 8;\n\n    private int mBatchResponseDelayMs = 100;\n\n    private final ImageCache mCache;\n\n    private final HashMap<String, BatchedImageRequest> mInFlightRequests =\n            new HashMap<String, BatchedImageRequest>();\n\n    private final HashMap<String, BatchedImageRequest> mBatchedResponses =\n            new HashMap<String, BatchedImageRequest>();\n\n    private final Handler mHandler = new Handler(Looper.getMainLooper());\n\n    private Runnable mRunnable;\n\n    private BitmapFactory.Options mBitmapOptions = new BitmapFactory.Options();\n\n    private static ANImageLoader sInstance;\n\n    public static void initialize() {\n        getInstance();\n    }\n\n    public static ANImageLoader getInstance() {\n        if (sInstance == null) {\n            synchronized (ANImageLoader.class) {\n                if (sInstance == null) {\n                    sInstance = new ANImageLoader(new LruBitmapCache(cacheSize));\n                }\n            }\n        }\n        return sInstance;\n    }\n\n    public interface ImageCache {\n        Bitmap getBitmap(String key);\n\n        void putBitmap(String key, Bitmap bitmap);\n\n        void evictBitmap(String key);\n\n        void evictAllBitmap();\n    }\n\n    public ANImageLoader(ImageCache imageCache) {\n        mCache = imageCache;\n    }\n\n    public ImageCache getImageCache() {\n        return mCache;\n    }\n\n    public static ImageListener getImageListener(final ImageView view,\n                                                 final int defaultImageResId,\n                                                 final int errorImageResId) {\n        return new ImageListener() {\n            @Override\n            public void onResponse(ImageContainer response, boolean isImmediate) {\n                if (response.getBitmap() != null) {\n                    view.setImageBitmap(response.getBitmap());\n                } else if (defaultImageResId != 0) {\n                    view.setImageResource(defaultImageResId);\n                }\n            }\n\n            @Override\n            public void onError(ANError anError) {\n                if (errorImageResId != 0) {\n                    view.setImageResource(errorImageResId);\n                }\n            }\n        };\n    }\n\n    public interface ImageListener {\n\n        void onResponse(ImageContainer response, boolean isImmediate);\n\n        void onError(ANError anError);\n    }\n\n    public boolean isCached(String requestUrl, int maxWidth, int maxHeight) {\n        return isCached(requestUrl, maxWidth, maxHeight, ImageView.ScaleType.CENTER_INSIDE);\n    }\n\n    public boolean isCached(String requestUrl, int maxWidth, int maxHeight,\n                            ImageView.ScaleType scaleType) {\n        throwIfNotOnMainThread();\n\n        String cacheKey = getCacheKey(requestUrl, maxWidth, maxHeight, scaleType);\n        return mCache.getBitmap(cacheKey) != null;\n    }\n\n    public ImageContainer get(String requestUrl, final ImageListener listener) {\n        return get(requestUrl, listener, 0, 0);\n    }\n\n\n    public ImageContainer get(String requestUrl, ImageListener imageListener,\n                              int maxWidth, int maxHeight) {\n        return get(requestUrl, imageListener, maxWidth, maxHeight,\n                ImageView.ScaleType.CENTER_INSIDE);\n    }\n\n    public ImageContainer get(String requestUrl, ImageListener imageListener,\n                              int maxWidth, int maxHeight, ImageView.ScaleType scaleType) {\n\n        throwIfNotOnMainThread();\n\n        final String cacheKey = getCacheKey(requestUrl, maxWidth, maxHeight, scaleType);\n\n        Bitmap cachedBitmap = mCache.getBitmap(cacheKey);\n        if (cachedBitmap != null) {\n            ImageContainer container = new ImageContainer(cachedBitmap, requestUrl, null, null);\n            imageListener.onResponse(container, true);\n            return container;\n        }\n\n        ImageContainer imageContainer =\n                new ImageContainer(null, requestUrl, cacheKey, imageListener);\n\n        imageListener.onResponse(imageContainer, true);\n\n        BatchedImageRequest request = mInFlightRequests.get(cacheKey);\n        if (request != null) {\n            request.addContainer(imageContainer);\n            return imageContainer;\n        }\n\n        ANRequest newRequest = makeImageRequest(requestUrl, maxWidth, maxHeight, scaleType,\n                cacheKey);\n\n        mInFlightRequests.put(cacheKey,\n                new BatchedImageRequest(newRequest, imageContainer));\n        return imageContainer;\n    }\n\n    protected ANRequest makeImageRequest(String requestUrl, int maxWidth, int maxHeight,\n                                         ImageView.ScaleType scaleType, final String cacheKey) {\n        ANRequest ANRequest = AndroidNetworking.get(requestUrl)\n                .setTag(\"ImageRequestTag\")\n                .setBitmapMaxHeight(maxHeight)\n                .setBitmapMaxWidth(maxWidth)\n                .setImageScaleType(scaleType)\n                .setBitmapConfig(Bitmap.Config.RGB_565)\n                .setBitmapOptions(mBitmapOptions)\n                .build();\n\n        ANRequest.getAsBitmap(new BitmapRequestListener() {\n            @Override\n            public void onResponse(Bitmap response) {\n                onGetImageSuccess(cacheKey, response);\n            }\n\n            @Override\n            public void onError(ANError anError) {\n                onGetImageError(cacheKey, anError);\n            }\n        });\n\n        return ANRequest;\n    }\n\n    public void setBitmapDecodeOptions(BitmapFactory.Options bitmapOptions) {\n        mBitmapOptions = bitmapOptions;\n    }\n\n    public void setBatchedResponseDelay(int newBatchedResponseDelayMs) {\n        mBatchResponseDelayMs = newBatchedResponseDelayMs;\n    }\n\n\n    protected void onGetImageSuccess(String cacheKey, Bitmap response) {\n        mCache.putBitmap(cacheKey, response);\n\n        BatchedImageRequest request = mInFlightRequests.remove(cacheKey);\n\n        if (request != null) {\n            request.mResponseBitmap = response;\n\n            batchResponse(cacheKey, request);\n        }\n    }\n\n    protected void onGetImageError(String cacheKey, ANError anError) {\n        BatchedImageRequest request = mInFlightRequests.remove(cacheKey);\n\n        if (request != null) {\n            request.setError(anError);\n            batchResponse(cacheKey, request);\n        }\n    }\n\n    public class ImageContainer {\n\n        private Bitmap mBitmap;\n\n        private final ImageListener mListener;\n\n        private final String mCacheKey;\n\n        private final String mRequestUrl;\n\n        public ImageContainer(Bitmap bitmap, String requestUrl,\n                              String cacheKey, ImageListener listener) {\n            mBitmap = bitmap;\n            mRequestUrl = requestUrl;\n            mCacheKey = cacheKey;\n            mListener = listener;\n        }\n\n        public void cancelRequest() {\n            if (mListener == null) {\n                return;\n            }\n\n            BatchedImageRequest request = mInFlightRequests.get(mCacheKey);\n            if (request != null) {\n                boolean canceled = request.removeContainerAndCancelIfNecessary(this);\n                if (canceled) {\n                    mInFlightRequests.remove(mCacheKey);\n                }\n            } else {\n                request = mBatchedResponses.get(mCacheKey);\n                if (request != null) {\n                    request.removeContainerAndCancelIfNecessary(this);\n                    if (request.mContainers.size() == 0) {\n                        mBatchedResponses.remove(mCacheKey);\n                    }\n                }\n            }\n        }\n\n        public Bitmap getBitmap() {\n            return mBitmap;\n        }\n\n\n        public String getRequestUrl() {\n            return mRequestUrl;\n        }\n    }\n\n    private class BatchedImageRequest {\n\n        private final ANRequest mRequest;\n\n        private Bitmap mResponseBitmap;\n\n        private ANError mANError;\n\n        private final LinkedList<ImageContainer> mContainers = new LinkedList<ImageContainer>();\n\n        public BatchedImageRequest(ANRequest request, ImageContainer container) {\n            mRequest = request;\n            mContainers.add(container);\n        }\n\n        public void setError(ANError anError) {\n            mANError = anError;\n        }\n\n        public ANError getError() {\n            return mANError;\n        }\n\n        public void addContainer(ImageContainer container) {\n            mContainers.add(container);\n        }\n\n        public boolean removeContainerAndCancelIfNecessary(ImageContainer container) {\n            mContainers.remove(container);\n            if (mContainers.size() == 0) {\n                mRequest.cancel(true);\n                if (mRequest.isCanceled()) {\n                    mRequest.destroy();\n                    ANRequestQueue.getInstance().finish(mRequest);\n                }\n                return true;\n            }\n            return false;\n        }\n    }\n\n    private void batchResponse(String cacheKey, BatchedImageRequest request) {\n        mBatchedResponses.put(cacheKey, request);\n        if (mRunnable == null) {\n            mRunnable = new Runnable() {\n                @Override\n                public void run() {\n                    for (BatchedImageRequest bir : mBatchedResponses.values()) {\n                        for (ImageContainer container : bir.mContainers) {\n                            if (container.mListener == null) {\n                                continue;\n                            }\n                            if (bir.getError() == null) {\n                                container.mBitmap = bir.mResponseBitmap;\n                                container.mListener.onResponse(container, false);\n                            } else {\n                                container.mListener.onError(bir.getError());\n                            }\n                        }\n                    }\n                    mBatchedResponses.clear();\n                    mRunnable = null;\n                }\n\n            };\n            mHandler.postDelayed(mRunnable, mBatchResponseDelayMs);\n        }\n    }\n\n    private void throwIfNotOnMainThread() {\n        if (Looper.myLooper() != Looper.getMainLooper()) {\n            throw new IllegalStateException(\"ImageLoader must be invoked from the main thread.\");\n        }\n    }\n\n    private static String getCacheKey(String url, int maxWidth, int maxHeight,\n                                      ImageView.ScaleType scaleType) {\n        return new StringBuilder(url.length() + 12).append(\"#W\").append(maxWidth)\n                .append(\"#H\").append(maxHeight).append(\"#S\").append(scaleType.ordinal()).append(url)\n                .toString();\n    }\n}\n"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/internal/ANRequestQueue.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.androidnetworking.internal;\n\nimport com.androidnetworking.common.ANRequest;\nimport com.androidnetworking.common.Priority;\nimport com.androidnetworking.core.Core;\n\nimport java.util.Collections;\nimport java.util.Iterator;\nimport java.util.Set;\nimport java.util.concurrent.ConcurrentHashMap;\nimport java.util.concurrent.atomic.AtomicInteger;\n\n/**\n * Created by amitshekhar on 22/03/16.\n */\npublic class ANRequestQueue {\n\n    private final Set<ANRequest> mCurrentRequests =\n            Collections.newSetFromMap(new ConcurrentHashMap<ANRequest, Boolean>());\n    private AtomicInteger mSequenceGenerator = new AtomicInteger();\n    private static ANRequestQueue sInstance = null;\n\n    public static void initialize() {\n        getInstance();\n    }\n\n    public static ANRequestQueue getInstance() {\n        if (sInstance == null) {\n            synchronized (ANRequestQueue.class) {\n                if (sInstance == null) {\n                    sInstance = new ANRequestQueue();\n                }\n            }\n        }\n        return sInstance;\n    }\n\n    public interface RequestFilter {\n        boolean apply(ANRequest request);\n    }\n\n    private void cancel(RequestFilter filter, boolean forceCancel) {\n        try {\n            for (Iterator<ANRequest> iterator = mCurrentRequests.iterator(); iterator.hasNext(); ) {\n                ANRequest request = iterator.next();\n                if (filter.apply(request)) {\n                    request.cancel(forceCancel);\n                    if (request.isCanceled()) {\n                        request.destroy();\n                        iterator.remove();\n                    }\n                }\n            }\n        } catch (Exception e) {\n            e.printStackTrace();\n        }\n    }\n\n    public void cancelAll(boolean forceCancel) {\n        try {\n            for (Iterator<ANRequest> iterator = mCurrentRequests.iterator(); iterator.hasNext(); ) {\n                ANRequest request = iterator.next();\n                request.cancel(forceCancel);\n                if (request.isCanceled()) {\n                    request.destroy();\n                    iterator.remove();\n                }\n            }\n        } catch (Exception e) {\n            e.printStackTrace();\n        }\n    }\n\n    public void cancelRequestWithGivenTag(final Object tag, final boolean forceCancel) {\n        try {\n            if (tag == null) {\n                return;\n            }\n            cancel(new RequestFilter() {\n                @Override\n                public boolean apply(ANRequest request) {\n                    return isRequestWithTheGivenTag(request, tag);\n                }\n            }, forceCancel);\n        } catch (Exception e) {\n            e.printStackTrace();\n        }\n    }\n\n    public int getSequenceNumber() {\n        return mSequenceGenerator.incrementAndGet();\n    }\n\n    public ANRequest addRequest(ANRequest request) {\n        try {\n            mCurrentRequests.add(request);\n        } catch (Exception e) {\n            e.printStackTrace();\n        }\n        try {\n            request.setSequenceNumber(getSequenceNumber());\n            if (request.getPriority() == Priority.IMMEDIATE) {\n                request.setFuture(Core.getInstance()\n                        .getExecutorSupplier()\n                        .forImmediateNetworkTasks()\n                        .submit(new InternalRunnable(request)));\n            } else {\n                request.setFuture(Core.getInstance()\n                        .getExecutorSupplier()\n                        .forNetworkTasks()\n                        .submit(new InternalRunnable(request)));\n            }\n        } catch (Exception e) {\n            e.printStackTrace();\n        }\n        return request;\n    }\n\n    public void finish(ANRequest request) {\n        try {\n            mCurrentRequests.remove(request);\n        } catch (Exception e) {\n            e.printStackTrace();\n        }\n    }\n\n    public boolean isRequestRunning(Object tag) {\n        try {\n            for (ANRequest request : mCurrentRequests) {\n                if (isRequestWithTheGivenTag(request, tag) && request.isRunning()) {\n                    return true;\n                }\n            }\n        } catch (Exception e) {\n            e.printStackTrace();\n        }\n        return false;\n    }\n\n    private boolean isRequestWithTheGivenTag(ANRequest request, Object tag) {\n        if (request.getTag() == null) {\n            return false;\n        }\n        if (request.getTag() instanceof String && tag instanceof String) {\n            final String tempRequestTag = (String) request.getTag();\n            final String tempTag = (String) tag;\n            return tempRequestTag.equals(tempTag);\n        }\n        return request.getTag().equals(tag);\n    }\n\n}\n"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/internal/DownloadProgressHandler.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.androidnetworking.internal;\n\nimport android.os.Handler;\nimport android.os.Looper;\nimport android.os.Message;\n\nimport com.androidnetworking.common.ANConstants;\nimport com.androidnetworking.interfaces.DownloadProgressListener;\nimport com.androidnetworking.model.Progress;\n\n/**\n * Created by amitshekhar on 24/05/16.\n */\npublic class DownloadProgressHandler extends Handler {\n\n    private final DownloadProgressListener mDownloadProgressListener;\n\n    public DownloadProgressHandler(DownloadProgressListener downloadProgressListener) {\n        super(Looper.getMainLooper());\n        mDownloadProgressListener = downloadProgressListener;\n    }\n\n    @Override\n    public void handleMessage(Message msg) {\n        switch (msg.what) {\n            case ANConstants.UPDATE:\n                if (mDownloadProgressListener != null) {\n                    final Progress progress = (Progress) msg.obj;\n                    mDownloadProgressListener.onProgress(progress.currentBytes, progress.totalBytes);\n                }\n                break;\n            default:\n                super.handleMessage(msg);\n                break;\n        }\n    }\n}\n"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/internal/InternalNetworking.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.androidnetworking.internal;\n\n/**\n * Created by amitshekhar on 22/03/16.\n */\n\nimport android.content.Context;\nimport android.net.TrafficStats;\n\nimport com.androidnetworking.common.ANConstants;\nimport com.androidnetworking.common.ANRequest;\nimport com.androidnetworking.common.ConnectionClassManager;\nimport com.androidnetworking.error.ANError;\nimport com.androidnetworking.interceptors.HttpLoggingInterceptor;\nimport com.androidnetworking.interceptors.HttpLoggingInterceptor.Level;\nimport com.androidnetworking.utils.Utils;\n\nimport java.io.File;\nimport java.io.IOException;\nimport java.util.concurrent.TimeUnit;\n\nimport okhttp3.Headers;\nimport okhttp3.Interceptor;\nimport okhttp3.OkHttpClient;\nimport okhttp3.Request;\nimport okhttp3.RequestBody;\nimport okhttp3.Response;\n\nimport static com.androidnetworking.common.Method.DELETE;\nimport static com.androidnetworking.common.Method.GET;\nimport static com.androidnetworking.common.Method.HEAD;\nimport static com.androidnetworking.common.Method.OPTIONS;\nimport static com.androidnetworking.common.Method.PATCH;\nimport static com.androidnetworking.common.Method.POST;\nimport static com.androidnetworking.common.Method.PUT;\n\npublic final class InternalNetworking {\n\n    private InternalNetworking() {\n\n    }\n\n    public static OkHttpClient sHttpClient = getClient();\n\n    public static String sUserAgent = null;\n\n    public static Response performSimpleRequest(ANRequest request) throws ANError {\n        Request okHttpRequest;\n        Response okHttpResponse;\n        try {\n            Request.Builder builder = new Request.Builder().url(request.getUrl());\n            addHeadersToRequestBuilder(builder, request);\n            RequestBody requestBody = null;\n            switch (request.getMethod()) {\n                case GET: {\n                    builder = builder.get();\n                    break;\n                }\n                case POST: {\n                    requestBody = request.getRequestBody();\n                    builder = builder.post(requestBody);\n                    break;\n                }\n                case PUT: {\n                    requestBody = request.getRequestBody();\n                    builder = builder.put(requestBody);\n                    break;\n                }\n                case DELETE: {\n                    requestBody = request.getRequestBody();\n                    builder = builder.delete(requestBody);\n                    break;\n                }\n                case HEAD: {\n                    builder = builder.head();\n                    break;\n                }\n                case OPTIONS: {\n                    builder = builder.method(ANConstants.OPTIONS, null);\n                    break;\n                }\n                case PATCH: {\n                    requestBody = request.getRequestBody();\n                    builder = builder.patch(requestBody);\n                    break;\n                }\n            }\n            if (request.getCacheControl() != null) {\n                builder.cacheControl(request.getCacheControl());\n            }\n            okHttpRequest = builder.build();\n\n            if (request.getOkHttpClient() != null) {\n                request.setCall(request.getOkHttpClient().newBuilder().cache(sHttpClient.cache()).build().newCall(okHttpRequest));\n            } else {\n                request.setCall(sHttpClient.newCall(okHttpRequest));\n            }\n            final long startTime = System.currentTimeMillis();\n            final long startBytes = TrafficStats.getTotalRxBytes();\n            okHttpResponse = request.getCall().execute();\n            final long timeTaken = System.currentTimeMillis() - startTime;\n            if (okHttpResponse.cacheResponse() == null) {\n                final long finalBytes = TrafficStats.getTotalRxBytes();\n                final long diffBytes;\n                if (startBytes == TrafficStats.UNSUPPORTED || finalBytes == TrafficStats.UNSUPPORTED) {\n                    diffBytes = okHttpResponse.body().contentLength();\n                } else {\n                    diffBytes = finalBytes - startBytes;\n                }\n                ConnectionClassManager.getInstance().updateBandwidth(diffBytes, timeTaken);\n                Utils.sendAnalytics(request.getAnalyticsListener(), timeTaken,\n                        (requestBody != null &&\n                                requestBody.contentLength() != 0) ? requestBody.contentLength() : -1,\n                        okHttpResponse.body().contentLength(), false);\n            } else if (request.getAnalyticsListener() != null) {\n                if (okHttpResponse.networkResponse() == null) {\n                    Utils.sendAnalytics(request.getAnalyticsListener(), timeTaken, 0, 0, true);\n                } else {\n                    Utils.sendAnalytics(request.getAnalyticsListener(), timeTaken,\n                            (requestBody != null && requestBody.contentLength() != 0) ? requestBody.contentLength() : -1,\n                            0, true);\n                }\n            }\n        } catch (IOException ioe) {\n            throw new ANError(ioe);\n        }\n        return okHttpResponse;\n    }\n\n    public static Response performDownloadRequest(final ANRequest request) throws ANError {\n        Request okHttpRequest;\n        Response okHttpResponse;\n        try {\n            Request.Builder builder = new Request.Builder().url(request.getUrl());\n            addHeadersToRequestBuilder(builder, request);\n            builder = builder.get();\n            if (request.getCacheControl() != null) {\n                builder.cacheControl(request.getCacheControl());\n            }\n            okHttpRequest = builder.build();\n\n            OkHttpClient okHttpClient;\n\n            if (request.getOkHttpClient() != null) {\n                okHttpClient = request.getOkHttpClient().newBuilder().cache(sHttpClient.cache())\n                        .addNetworkInterceptor(new Interceptor() {\n                            @Override\n                            public Response intercept(Chain chain) throws IOException {\n                                Response originalResponse = chain.proceed(chain.request());\n                                return originalResponse.newBuilder()\n                                        .body(new ResponseProgressBody(originalResponse.body(),\n                                                request.getDownloadProgressListener()))\n                                        .build();\n                            }\n                        }).build();\n            } else {\n                okHttpClient = sHttpClient.newBuilder()\n                        .addNetworkInterceptor(new Interceptor() {\n                            @Override\n                            public Response intercept(Chain chain) throws IOException {\n                                Response originalResponse = chain.proceed(chain.request());\n                                return originalResponse.newBuilder()\n                                        .body(new ResponseProgressBody(originalResponse.body(),\n                                                request.getDownloadProgressListener()))\n                                        .build();\n                            }\n                        }).build();\n            }\n            request.setCall(okHttpClient.newCall(okHttpRequest));\n            final long startTime = System.currentTimeMillis();\n            final long startBytes = TrafficStats.getTotalRxBytes();\n            okHttpResponse = request.getCall().execute();\n            Utils.saveFile(okHttpResponse, request.getDirPath(), request.getFileName());\n            final long timeTaken = System.currentTimeMillis() - startTime;\n            if (okHttpResponse.cacheResponse() == null) {\n                final long finalBytes = TrafficStats.getTotalRxBytes();\n                final long diffBytes;\n                if (startBytes == TrafficStats.UNSUPPORTED || finalBytes == TrafficStats.UNSUPPORTED) {\n                    diffBytes = okHttpResponse.body().contentLength();\n                } else {\n                    diffBytes = finalBytes - startBytes;\n                }\n                ConnectionClassManager.getInstance().updateBandwidth(diffBytes, timeTaken);\n                Utils.sendAnalytics(request.getAnalyticsListener(), timeTaken, -1,\n                        okHttpResponse.body().contentLength(), false);\n            } else if (request.getAnalyticsListener() != null) {\n                Utils.sendAnalytics(request.getAnalyticsListener(), timeTaken, -1, 0, true);\n            }\n        } catch (IOException ioe) {\n            try {\n                File destinationFile = new File(request.getDirPath() + File.separator + request.getFileName());\n                if (destinationFile.exists()) {\n                    destinationFile.delete();\n                }\n            } catch (Exception e) {\n                e.printStackTrace();\n            }\n            throw new ANError(ioe);\n        }\n        return okHttpResponse;\n    }\n\n\n    public static Response performUploadRequest(ANRequest request) throws ANError {\n        Request okHttpRequest;\n        Response okHttpResponse;\n        try {\n            Request.Builder builder = new Request.Builder().url(request.getUrl());\n            addHeadersToRequestBuilder(builder, request);\n            final RequestBody requestBody = request.getMultiPartRequestBody();\n            final long requestBodyLength = requestBody.contentLength();\n            builder = builder.post(new RequestProgressBody(requestBody, request.getUploadProgressListener()));\n            if (request.getCacheControl() != null) {\n                builder.cacheControl(request.getCacheControl());\n            }\n            okHttpRequest = builder.build();\n            if (request.getOkHttpClient() != null) {\n                request.setCall(request.getOkHttpClient()\n                        .newBuilder()\n                        .cache(sHttpClient.cache())\n                        .build()\n                        .newCall(okHttpRequest));\n            } else {\n                request.setCall(sHttpClient.newCall(okHttpRequest));\n            }\n            final long startTime = System.currentTimeMillis();\n            okHttpResponse = request.getCall().execute();\n            final long timeTaken = System.currentTimeMillis() - startTime;\n            if (request.getAnalyticsListener() != null) {\n                if (okHttpResponse.cacheResponse() == null) {\n                    Utils.sendAnalytics(request.getAnalyticsListener(), timeTaken,\n                            requestBodyLength, okHttpResponse.body().contentLength(), false);\n                } else {\n                    if (okHttpResponse.networkResponse() == null) {\n                        Utils.sendAnalytics(request.getAnalyticsListener(), timeTaken, 0, 0, true);\n                    } else {\n                        Utils.sendAnalytics(request.getAnalyticsListener(), timeTaken,\n                                requestBodyLength != 0 ? requestBodyLength : -1, 0, true);\n                    }\n                }\n            }\n        } catch (IOException ioe) {\n            throw new ANError(ioe);\n        }\n        return okHttpResponse;\n    }\n\n    public static OkHttpClient getClient() {\n        if (sHttpClient == null) {\n            return getDefaultClient();\n        }\n        return sHttpClient;\n    }\n\n    public static void addHeadersToRequestBuilder(Request.Builder builder, ANRequest request) {\n        if (request.getUserAgent() != null) {\n            builder.addHeader(ANConstants.USER_AGENT, request.getUserAgent());\n        } else if (sUserAgent != null) {\n            request.setUserAgent(sUserAgent);\n            builder.addHeader(ANConstants.USER_AGENT, sUserAgent);\n        }\n        Headers requestHeaders = request.getHeaders();\n        if (requestHeaders != null) {\n            builder.headers(requestHeaders);\n            if (request.getUserAgent() != null && !requestHeaders.names().contains(ANConstants.USER_AGENT)) {\n                builder.addHeader(ANConstants.USER_AGENT, request.getUserAgent());\n            }\n        }\n    }\n\n    public static OkHttpClient getDefaultClient() {\n        return new OkHttpClient().newBuilder()\n                .connectTimeout(60, TimeUnit.SECONDS)\n                .readTimeout(60, TimeUnit.SECONDS)\n                .writeTimeout(60, TimeUnit.SECONDS)\n                .build();\n    }\n\n    public static void setClientWithCache(Context context) {\n        sHttpClient = new OkHttpClient().newBuilder()\n                .cache(Utils.getCache(context, ANConstants.MAX_CACHE_SIZE, ANConstants.CACHE_DIR_NAME))\n                .connectTimeout(60, TimeUnit.SECONDS)\n                .readTimeout(60, TimeUnit.SECONDS)\n                .writeTimeout(60, TimeUnit.SECONDS)\n                .build();\n    }\n\n    public static void setUserAgent(String userAgent) {\n        sUserAgent = userAgent;\n    }\n\n    public static void setClient(OkHttpClient okHttpClient) {\n        sHttpClient = okHttpClient;\n    }\n\n    public static void enableLogging(Level level) {\n        HttpLoggingInterceptor logging = new HttpLoggingInterceptor();\n        logging.setLevel(level);\n        sHttpClient = getClient()\n                .newBuilder()\n                .addInterceptor(logging)\n                .build();\n    }\n\n}"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/internal/InternalRunnable.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.androidnetworking.internal;\n\nimport com.androidnetworking.common.ANRequest;\nimport com.androidnetworking.common.ANResponse;\nimport com.androidnetworking.common.Priority;\nimport com.androidnetworking.common.ResponseType;\nimport com.androidnetworking.core.Core;\nimport com.androidnetworking.error.ANError;\nimport com.androidnetworking.utils.SourceCloseUtil;\nimport com.androidnetworking.utils.Utils;\n\nimport okhttp3.Response;\n\nimport static com.androidnetworking.common.RequestType.DOWNLOAD;\nimport static com.androidnetworking.common.RequestType.MULTIPART;\nimport static com.androidnetworking.common.RequestType.SIMPLE;\n\n/**\n * Created by amitshekhar on 22/03/16.\n */\npublic class InternalRunnable implements Runnable {\n\n    private final Priority priority;\n    public final int sequence;\n    public final ANRequest request;\n\n    public InternalRunnable(ANRequest request) {\n        this.request = request;\n        this.sequence = request.getSequenceNumber();\n        this.priority = request.getPriority();\n    }\n\n    @Override\n    public void run() {\n        request.setRunning(true);\n        switch (request.getRequestType()) {\n            case SIMPLE:\n                executeSimpleRequest();\n                break;\n            case DOWNLOAD:\n                executeDownloadRequest();\n                break;\n            case MULTIPART:\n                executeUploadRequest();\n                break;\n        }\n        request.setRunning(false);\n    }\n\n    private void executeSimpleRequest() {\n        Response okHttpResponse = null;\n        try {\n            okHttpResponse = InternalNetworking.performSimpleRequest(request);\n\n            if (okHttpResponse == null) {\n                deliverError(request, Utils.getErrorForConnection(new ANError()));\n                return;\n            }\n\n            if (request.getResponseAs() == ResponseType.OK_HTTP_RESPONSE) {\n                request.deliverOkHttpResponse(okHttpResponse);\n                return;\n            }\n            if (okHttpResponse.code() >= 400) {\n                deliverError(request, Utils.getErrorForServerResponse(new ANError(okHttpResponse),\n                        request, okHttpResponse.code()));\n                return;\n            }\n\n            ANResponse response = request.parseResponse(okHttpResponse);\n            if (!response.isSuccess()) {\n                deliverError(request, response.getError());\n                return;\n            }\n            response.setOkHttpResponse(okHttpResponse);\n            request.deliverResponse(response);\n        } catch (Exception e) {\n            deliverError(request, Utils.getErrorForConnection(new ANError(e)));\n        } finally {\n            SourceCloseUtil.close(okHttpResponse, request);\n        }\n    }\n\n    private void executeDownloadRequest() {\n        Response okHttpResponse;\n        try {\n            okHttpResponse = InternalNetworking.performDownloadRequest(request);\n            if (okHttpResponse == null) {\n                deliverError(request, Utils.getErrorForConnection(new ANError()));\n                return;\n            }\n            if (okHttpResponse.code() >= 400) {\n                deliverError(request, Utils.getErrorForServerResponse(new ANError(okHttpResponse),\n                        request, okHttpResponse.code()));\n                return;\n            }\n            request.updateDownloadCompletion();\n        } catch (Exception e) {\n            deliverError(request, Utils.getErrorForConnection(new ANError(e)));\n        }\n    }\n\n    private void executeUploadRequest() {\n        Response okHttpResponse = null;\n        try {\n            okHttpResponse = InternalNetworking.performUploadRequest(request);\n\n            if (okHttpResponse == null) {\n                deliverError(request, Utils.getErrorForConnection(new ANError()));\n                return;\n            }\n\n            if (request.getResponseAs() == ResponseType.OK_HTTP_RESPONSE) {\n                request.deliverOkHttpResponse(okHttpResponse);\n                return;\n            }\n\n            if (okHttpResponse.code() >= 400) {\n                deliverError(request, Utils.getErrorForServerResponse(new ANError(okHttpResponse),\n                        request, okHttpResponse.code()));\n                return;\n            }\n            ANResponse response = request.parseResponse(okHttpResponse);\n            if (!response.isSuccess()) {\n                deliverError(request, response.getError());\n                return;\n            }\n            response.setOkHttpResponse(okHttpResponse);\n            request.deliverResponse(response);\n        } catch (Exception e) {\n            deliverError(request, Utils.getErrorForConnection(new ANError(e)));\n        } finally {\n            SourceCloseUtil.close(okHttpResponse, request);\n        }\n    }\n\n    public Priority getPriority() {\n        return priority;\n    }\n\n    private void deliverError(final ANRequest request, final ANError anError) {\n        Core.getInstance().getExecutorSupplier().forMainThreadTasks().execute(new Runnable() {\n            public void run() {\n                request.deliverError(anError);\n                request.finish();\n            }\n        });\n    }\n}\n"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/internal/RequestProgressBody.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.androidnetworking.internal;\n\nimport com.androidnetworking.common.ANConstants;\nimport com.androidnetworking.interfaces.UploadProgressListener;\nimport com.androidnetworking.model.Progress;\n\nimport java.io.IOException;\n\nimport okhttp3.MediaType;\nimport okhttp3.RequestBody;\nimport okio.Buffer;\nimport okio.BufferedSink;\nimport okio.ForwardingSink;\nimport okio.Okio;\nimport okio.Sink;\n\n/**\n * Created by amitshekhar on 21/04/16.\n */\npublic class RequestProgressBody extends RequestBody {\n    private final RequestBody requestBody;\n    private BufferedSink bufferedSink;\n    private UploadProgressHandler uploadProgressHandler;\n\n    public RequestProgressBody(RequestBody requestBody, UploadProgressListener uploadProgressListener) {\n        this.requestBody = requestBody;\n        if (uploadProgressListener != null) {\n            this.uploadProgressHandler = new UploadProgressHandler(uploadProgressListener);\n        }\n    }\n\n    public MediaType contentType() {\n        return requestBody.contentType();\n    }\n\n    @Override\n    public long contentLength() throws IOException {\n        return requestBody.contentLength();\n    }\n\n    @Override\n    public void writeTo(BufferedSink sink) throws IOException {\n        if (bufferedSink == null) {\n            bufferedSink = Okio.buffer(sink(sink));\n        }\n        requestBody.writeTo(bufferedSink);\n        bufferedSink.flush();\n    }\n\n    private Sink sink(Sink sink) {\n        return new ForwardingSink(sink) {\n            long bytesWritten = 0L;\n            long contentLength = 0L;\n\n            @Override\n            public void write(Buffer source, long byteCount) throws IOException {\n                super.write(source, byteCount);\n                if (contentLength == 0) {\n                    contentLength = contentLength();\n                }\n                bytesWritten += byteCount;\n                if (uploadProgressHandler != null) {\n                    uploadProgressHandler.obtainMessage(ANConstants.UPDATE,\n                            new Progress(bytesWritten, contentLength)).sendToTarget();\n                }\n            }\n        };\n    }\n}"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/internal/ResponseProgressBody.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.androidnetworking.internal;\n\nimport com.androidnetworking.common.ANConstants;\nimport com.androidnetworking.interfaces.DownloadProgressListener;\nimport com.androidnetworking.model.Progress;\n\nimport java.io.IOException;\n\nimport okhttp3.MediaType;\nimport okhttp3.ResponseBody;\nimport okio.Buffer;\nimport okio.BufferedSource;\nimport okio.ForwardingSource;\nimport okio.Okio;\nimport okio.Source;\n\n/**\n * Created by amitshekhar on 24/05/16.\n */\npublic class ResponseProgressBody extends ResponseBody {\n\n    private final ResponseBody mResponseBody;\n    private BufferedSource bufferedSource;\n    private DownloadProgressHandler downloadProgressHandler;\n\n    public ResponseProgressBody(ResponseBody responseBody, DownloadProgressListener downloadProgressListener) {\n        this.mResponseBody = responseBody;\n        if (downloadProgressListener != null) {\n            this.downloadProgressHandler = new DownloadProgressHandler(downloadProgressListener);\n        }\n    }\n\n    @Override\n    public MediaType contentType() {\n        return mResponseBody.contentType();\n    }\n\n    @Override\n    public long contentLength() {\n        return mResponseBody.contentLength();\n    }\n\n    @Override\n    public BufferedSource source() {\n        if (bufferedSource == null) {\n            bufferedSource = Okio.buffer(source(mResponseBody.source()));\n        }\n        return bufferedSource;\n    }\n\n    private Source source(Source source) {\n\n        return new ForwardingSource(source) {\n\n            long totalBytesRead;\n\n            @Override\n            public long read(Buffer sink, long byteCount) throws IOException {\n                long bytesRead = super.read(sink, byteCount);\n                totalBytesRead += ((bytesRead != -1) ? bytesRead : 0);\n                if (downloadProgressHandler != null) {\n                    downloadProgressHandler\n                            .obtainMessage(ANConstants.UPDATE,\n                                    new Progress(totalBytesRead, mResponseBody.contentLength()))\n                            .sendToTarget();\n                }\n                return bytesRead;\n            }\n        };\n    }\n}\n"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/internal/SynchronousCall.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.androidnetworking.internal;\n\nimport com.androidnetworking.common.ANConstants;\nimport com.androidnetworking.common.ANRequest;\nimport com.androidnetworking.common.ANResponse;\nimport com.androidnetworking.common.ResponseType;\nimport com.androidnetworking.error.ANError;\nimport com.androidnetworking.utils.SourceCloseUtil;\nimport com.androidnetworking.utils.Utils;\n\nimport okhttp3.Response;\n\nimport static com.androidnetworking.common.RequestType.DOWNLOAD;\nimport static com.androidnetworking.common.RequestType.MULTIPART;\nimport static com.androidnetworking.common.RequestType.SIMPLE;\n\n/**\n * Created by amitshekhar on 14/09/16.\n */\n@SuppressWarnings(\"unchecked\")\npublic final class SynchronousCall {\n\n    private SynchronousCall() {\n\n    }\n\n    public static <T> ANResponse<T> execute(ANRequest request) {\n        switch (request.getRequestType()) {\n            case SIMPLE:\n                return executeSimpleRequest(request);\n            case DOWNLOAD:\n                return executeDownloadRequest(request);\n            case MULTIPART:\n                return executeUploadRequest(request);\n        }\n        return new ANResponse<>(new ANError());\n    }\n\n    private static <T> ANResponse<T> executeSimpleRequest(ANRequest request) {\n        Response okHttpResponse = null;\n        try {\n            okHttpResponse = InternalNetworking.performSimpleRequest(request);\n            if (okHttpResponse == null) {\n                return new ANResponse<>(Utils.getErrorForConnection(new ANError()));\n            }\n\n            if (request.getResponseAs() == ResponseType.OK_HTTP_RESPONSE) {\n                ANResponse response = new ANResponse(okHttpResponse);\n                response.setOkHttpResponse(okHttpResponse);\n                return response;\n            }\n            if (okHttpResponse.code() >= 400) {\n                ANResponse response = new ANResponse<>(Utils.getErrorForServerResponse(new ANError(okHttpResponse),\n                        request, okHttpResponse.code()));\n                response.setOkHttpResponse(okHttpResponse);\n                return response;\n            }\n            ANResponse response = request.parseResponse(okHttpResponse);\n            response.setOkHttpResponse(okHttpResponse);\n            return response;\n        } catch (ANError se) {\n            return new ANResponse<>(Utils.getErrorForConnection(new ANError(se)));\n        } catch (Exception e) {\n            return new ANResponse<>(Utils.getErrorForConnection(new ANError(e)));\n        } finally {\n            SourceCloseUtil.close(okHttpResponse, request);\n        }\n    }\n\n    private static <T> ANResponse<T> executeDownloadRequest(ANRequest request) {\n        Response okHttpResponse;\n        try {\n            okHttpResponse = InternalNetworking.performDownloadRequest(request);\n            if (okHttpResponse == null) {\n                return new ANResponse<>(Utils.getErrorForConnection(new ANError()));\n            }\n            if (okHttpResponse.code() >= 400) {\n                ANResponse response = new ANResponse<>(Utils.getErrorForServerResponse(new ANError(okHttpResponse),\n                        request, okHttpResponse.code()));\n                response.setOkHttpResponse(okHttpResponse);\n                return response;\n            }\n            ANResponse response = new ANResponse(ANConstants.SUCCESS);\n            response.setOkHttpResponse(okHttpResponse);\n            return response;\n        } catch (ANError se) {\n            return new ANResponse<>(Utils.getErrorForConnection(new ANError(se)));\n        } catch (Exception e) {\n            return new ANResponse<>(Utils.getErrorForConnection(new ANError(e)));\n        }\n    }\n\n    private static <T> ANResponse<T> executeUploadRequest(ANRequest request) {\n        Response okHttpResponse = null;\n        try {\n            okHttpResponse = InternalNetworking.performUploadRequest(request);\n\n            if (okHttpResponse == null) {\n                return new ANResponse<>(Utils.getErrorForConnection(new ANError()));\n            }\n\n            if (request.getResponseAs() == ResponseType.OK_HTTP_RESPONSE) {\n                ANResponse response = new ANResponse(okHttpResponse);\n                response.setOkHttpResponse(okHttpResponse);\n                return response;\n            }\n            if (okHttpResponse.code() >= 400) {\n                ANResponse response = new ANResponse<>(Utils.getErrorForServerResponse(new ANError(okHttpResponse),\n                        request, okHttpResponse.code()));\n                response.setOkHttpResponse(okHttpResponse);\n                return response;\n            }\n            ANResponse response = request.parseResponse(okHttpResponse);\n            response.setOkHttpResponse(okHttpResponse);\n            return response;\n        } catch (ANError se) {\n            return new ANResponse<>(Utils.getErrorForConnection(se));\n        } catch (Exception e) {\n            return new ANResponse<>(Utils.getErrorForConnection(new ANError(e)));\n        } finally {\n            SourceCloseUtil.close(okHttpResponse, request);\n        }\n    }\n}\n"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/internal/UploadProgressHandler.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.androidnetworking.internal;\n\nimport android.os.Handler;\nimport android.os.Looper;\nimport android.os.Message;\n\nimport com.androidnetworking.common.ANConstants;\nimport com.androidnetworking.interfaces.UploadProgressListener;\nimport com.androidnetworking.model.Progress;\n\n/**\n * Created by amitshekhar on 24/05/16.\n */\npublic class UploadProgressHandler extends Handler {\n\n    private final UploadProgressListener mUploadProgressListener;\n\n    public UploadProgressHandler(UploadProgressListener uploadProgressListener) {\n        super(Looper.getMainLooper());\n        mUploadProgressListener = uploadProgressListener;\n    }\n\n    @Override\n    public void handleMessage(Message msg) {\n        switch (msg.what) {\n            case ANConstants.UPDATE:\n                if (mUploadProgressListener != null) {\n                    final Progress progress = (Progress) msg.obj;\n                    mUploadProgressListener.onProgress(progress.currentBytes, progress.totalBytes);\n                }\n                break;\n            default:\n                super.handleMessage(msg);\n                break;\n        }\n    }\n}\n"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/model/MultipartFileBody.java",
    "content": "package com.androidnetworking.model;\n\nimport java.io.File;\n\npublic class MultipartFileBody {\n\n    public final File file;\n    public final String contentType;\n\n    public MultipartFileBody(File file, String contentType) {\n        this.file = file;\n        this.contentType = contentType;\n    }\n\n}\n"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/model/MultipartStringBody.java",
    "content": "package com.androidnetworking.model;\n\npublic class MultipartStringBody {\n\n    public final String value;\n    public final String contentType;\n\n    public MultipartStringBody(String value, String contentType) {\n        this.value = value;\n        this.contentType = contentType;\n    }\n\n}\n"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/model/Progress.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.androidnetworking.model;\n\nimport java.io.Serializable;\n\n/**\n * Created by amitshekhar on 24/05/16.\n */\n\npublic class Progress implements Serializable {\n\n    public long currentBytes;\n    public long totalBytes;\n\n    public Progress(long currentBytes, long totalBytes) {\n        this.currentBytes = currentBytes;\n        this.totalBytes = totalBytes;\n    }\n\n}"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/utils/ParseUtil.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.androidnetworking.utils;\n\nimport com.androidnetworking.gsonparserfactory.GsonParserFactory;\nimport com.androidnetworking.interfaces.Parser;\nimport com.google.gson.Gson;\n\n/**\n * Created by amitshekhar on 15/09/16.\n */\npublic class ParseUtil {\n\n    private static Parser.Factory mParserFactory;\n\n    public static void setParserFactory(Parser.Factory parserFactory) {\n        mParserFactory = parserFactory;\n    }\n\n    public static Parser.Factory getParserFactory() {\n        if (mParserFactory == null) {\n            mParserFactory = new GsonParserFactory(new Gson());\n        }\n        return mParserFactory;\n    }\n\n    public static void shutDown() {\n        mParserFactory = null;\n    }\n\n}\n"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/utils/SourceCloseUtil.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.androidnetworking.utils;\n\nimport com.androidnetworking.common.ANRequest;\nimport com.androidnetworking.common.ResponseType;\n\nimport okhttp3.Response;\n\n/**\n * Created by amitshekhar on 15/09/16.\n */\npublic final class SourceCloseUtil {\n\n    private SourceCloseUtil() {\n    }\n\n    public static void close(Response response, ANRequest request) {\n        if (request.getResponseAs() != ResponseType.OK_HTTP_RESPONSE &&\n                response != null && response.body() != null &&\n                response.body().source() != null) {\n            try {\n                response.body().source().close();\n            } catch (Exception ignore) {\n\n            }\n        }\n    }\n}\n"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/utils/Utils.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.androidnetworking.utils;\n\nimport android.content.Context;\nimport android.graphics.Bitmap;\nimport android.graphics.BitmapFactory;\nimport android.widget.ImageView;\n\nimport com.androidnetworking.common.ANConstants;\nimport com.androidnetworking.common.ANRequest;\nimport com.androidnetworking.common.ANResponse;\nimport com.androidnetworking.core.Core;\nimport com.androidnetworking.error.ANError;\nimport com.androidnetworking.interfaces.AnalyticsListener;\n\nimport java.io.File;\nimport java.io.FileOutputStream;\nimport java.io.IOException;\nimport java.io.InputStream;\nimport java.net.FileNameMap;\nimport java.net.URLConnection;\n\nimport okhttp3.Cache;\nimport okhttp3.Response;\nimport okio.Okio;\n\n/**\n * Created by amitshekhar on 25/03/16.\n */\npublic class Utils {\n\n    public static File getDiskCacheDir(Context context, String uniqueName) {\n        return new File(context.getCacheDir(), uniqueName);\n    }\n\n    public static Cache getCache(Context context, int maxCacheSize, String uniqueName) {\n        return new Cache(getDiskCacheDir(context, uniqueName), maxCacheSize);\n    }\n\n    public static String getMimeType(String path) {\n        FileNameMap fileNameMap = URLConnection.getFileNameMap();\n        String contentTypeFor = fileNameMap.getContentTypeFor(path);\n        if (contentTypeFor == null) {\n            contentTypeFor = \"application/octet-stream\";\n        }\n        return contentTypeFor;\n    }\n\n    public static ANResponse<Bitmap> decodeBitmap(Response response, int maxWidth,\n                                                  int maxHeight, Bitmap.Config decodeConfig,\n                                                  ImageView.ScaleType scaleType) {\n        return decodeBitmap(response, maxWidth, maxHeight, decodeConfig,\n                new BitmapFactory.Options(), scaleType);\n    }\n\n    public static ANResponse<Bitmap> decodeBitmap(Response response, int maxWidth,\n                                                  int maxHeight, Bitmap.Config decodeConfig,\n                                                  BitmapFactory.Options decodeOptions,\n                                                  ImageView.ScaleType scaleType) {\n        byte[] data = new byte[0];\n        try {\n            data = Okio.buffer(response.body().source()).readByteArray();\n        } catch (IOException e) {\n            e.printStackTrace();\n        }\n        Bitmap bitmap = null;\n        if (maxWidth == 0 && maxHeight == 0) {\n            decodeOptions.inPreferredConfig = decodeConfig;\n            bitmap = BitmapFactory.decodeByteArray(data, 0, data.length, decodeOptions);\n        } else {\n            decodeOptions.inJustDecodeBounds = true;\n            BitmapFactory.decodeByteArray(data, 0, data.length, decodeOptions);\n            int actualWidth = decodeOptions.outWidth;\n            int actualHeight = decodeOptions.outHeight;\n\n            int desiredWidth = getResizedDimension(maxWidth, maxHeight,\n                    actualWidth, actualHeight, scaleType);\n            int desiredHeight = getResizedDimension(maxHeight, maxWidth,\n                    actualHeight, actualWidth, scaleType);\n\n            decodeOptions.inJustDecodeBounds = false;\n            decodeOptions.inSampleSize =\n                    findBestSampleSize(actualWidth, actualHeight, desiredWidth, desiredHeight);\n            Bitmap tempBitmap =\n                    BitmapFactory.decodeByteArray(data, 0, data.length, decodeOptions);\n\n            if (tempBitmap != null && (tempBitmap.getWidth() > desiredWidth ||\n                    tempBitmap.getHeight() > desiredHeight)) {\n                bitmap = Bitmap.createScaledBitmap(tempBitmap,\n                        desiredWidth, desiredHeight, true);\n                tempBitmap.recycle();\n            } else {\n                bitmap = tempBitmap;\n            }\n        }\n\n        if (bitmap == null) {\n            return ANResponse.failed(Utils.getErrorForParse(new ANError(response)));\n        } else {\n            return ANResponse.success(bitmap);\n        }\n    }\n\n    private static int getResizedDimension(int maxPrimary, int maxSecondary,\n                                           int actualPrimary, int actualSecondary,\n                                           ImageView.ScaleType scaleType) {\n\n        if ((maxPrimary == 0) && (maxSecondary == 0)) {\n            return actualPrimary;\n        }\n\n        if (scaleType == ImageView.ScaleType.FIT_XY) {\n            if (maxPrimary == 0) {\n                return actualPrimary;\n            }\n            return maxPrimary;\n        }\n\n        if (maxPrimary == 0) {\n            double ratio = (double) maxSecondary / (double) actualSecondary;\n            return (int) (actualPrimary * ratio);\n        }\n\n        if (maxSecondary == 0) {\n            return maxPrimary;\n        }\n\n        double ratio = (double) actualSecondary / (double) actualPrimary;\n        int resized = maxPrimary;\n\n        if (scaleType == ImageView.ScaleType.CENTER_CROP) {\n            if ((resized * ratio) < maxSecondary) {\n                resized = (int) (maxSecondary / ratio);\n            }\n            return resized;\n        }\n\n        if ((resized * ratio) > maxSecondary) {\n            resized = (int) (maxSecondary / ratio);\n        }\n        return resized;\n    }\n\n    public static int findBestSampleSize(int actualWidth, int actualHeight,\n                                         int desiredWidth, int desiredHeight) {\n        double wr = (double) actualWidth / desiredWidth;\n        double hr = (double) actualHeight / desiredHeight;\n        double ratio = Math.min(wr, hr);\n        float n = 1.0f;\n        while ((n * 2) <= ratio) {\n            n *= 2;\n        }\n        return (int) n;\n    }\n\n    public static void saveFile(Response response, String dirPath,\n                                String fileName) throws IOException {\n        InputStream is = null;\n        byte[] buf = new byte[2048];\n        int len;\n        FileOutputStream fos = null;\n        try {\n            is = response.body().byteStream();\n            File dir = new File(dirPath);\n            if (!dir.exists()) {\n                dir.mkdirs();\n            }\n            File file = new File(dir, fileName);\n            fos = new FileOutputStream(file);\n            while ((len = is.read(buf)) != -1) {\n                fos.write(buf, 0, len);\n            }\n            fos.flush();\n        } finally {\n            try {\n                if (is != null) is.close();\n            } catch (IOException e) {\n                e.printStackTrace();\n            }\n            try {\n                if (fos != null) fos.close();\n            } catch (IOException e) {\n                e.printStackTrace();\n            }\n        }\n    }\n\n    public static void sendAnalytics(final AnalyticsListener analyticsListener,\n                                     final long timeTakenInMillis, final long bytesSent,\n                                     final long bytesReceived, final boolean isFromCache) {\n        Core.getInstance().getExecutorSupplier().forMainThreadTasks().execute(new Runnable() {\n            @Override\n            public void run() {\n                if (analyticsListener != null) {\n                    analyticsListener.onReceived(timeTakenInMillis, bytesSent, bytesReceived,\n                            isFromCache);\n                }\n            }\n        });\n    }\n\n    public static ANError getErrorForConnection(ANError error) {\n        error.setErrorDetail(ANConstants.CONNECTION_ERROR);\n        error.setErrorCode(0);\n        return error;\n    }\n\n\n    public static ANError getErrorForServerResponse(ANError error, ANRequest request, int code) {\n        error = request.parseNetworkError(error);\n        error.setErrorCode(code);\n        error.setErrorDetail(ANConstants.RESPONSE_FROM_SERVER_ERROR);\n        return error;\n    }\n\n    public static ANError getErrorForParse(ANError error) {\n        error.setErrorCode(0);\n        error.setErrorDetail(ANConstants.PARSE_ERROR);\n        return error;\n    }\n\n}\n"
  },
  {
    "path": "android-networking/src/main/java/com/androidnetworking/widget/ANImageView.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.androidnetworking.widget;\n\nimport android.content.Context;\nimport android.support.v7.widget.AppCompatImageView;\nimport android.text.TextUtils;\nimport android.util.AttributeSet;\nimport android.view.ViewGroup;\nimport android.widget.ImageView;\n\nimport com.androidnetworking.error.ANError;\nimport com.androidnetworking.internal.ANImageLoader;\n\n/**\n * Created by amitshekhar on 23/03/16.\n */\npublic class ANImageView extends AppCompatImageView {\n\n    private String mUrl;\n\n    private int mDefaultImageId;\n\n    private int mErrorImageId;\n\n    private ANImageLoader.ImageContainer mImageContainer;\n\n    public ANImageView(Context context) {\n        this(context, null);\n    }\n\n    public ANImageView(Context context, AttributeSet attrs) {\n        this(context, attrs, 0);\n    }\n\n    public ANImageView(Context context, AttributeSet attrs, int defStyle) {\n        super(context, attrs, defStyle);\n    }\n\n    public void setImageUrl(String url) {\n        mUrl = url;\n        loadImageIfNecessary(false);\n    }\n\n    public void setDefaultImageResId(int defaultImage) {\n        mDefaultImageId = defaultImage;\n    }\n\n    public void setErrorImageResId(int errorImage) {\n        mErrorImageId = errorImage;\n    }\n\n    void loadImageIfNecessary(final boolean isInLayoutPass) {\n        int width = getWidth();\n        int height = getHeight();\n        ImageView.ScaleType scaleType = getScaleType();\n\n        boolean wrapWidth = false, wrapHeight = false;\n        if (getLayoutParams() != null) {\n            wrapWidth = getLayoutParams().width == ViewGroup.LayoutParams.WRAP_CONTENT;\n            wrapHeight = getLayoutParams().height == ViewGroup.LayoutParams.WRAP_CONTENT;\n        }\n\n        boolean isFullyWrapContent = wrapWidth && wrapHeight;\n        if (width == 0 && height == 0 && !isFullyWrapContent) {\n            return;\n        }\n\n        if (TextUtils.isEmpty(mUrl)) {\n            if (mImageContainer != null) {\n                mImageContainer.cancelRequest();\n                mImageContainer = null;\n            }\n            setDefaultImageOrNull();\n            return;\n        }\n\n        if (mImageContainer != null && mImageContainer.getRequestUrl() != null) {\n            if (mImageContainer.getRequestUrl().equals(mUrl)) {\n                return;\n            } else {\n                mImageContainer.cancelRequest();\n                setDefaultImageOrNull();\n            }\n        }\n\n        int maxWidth = wrapWidth ? 0 : width;\n        int maxHeight = wrapHeight ? 0 : height;\n\n        ANImageLoader.ImageContainer newContainer = ANImageLoader.getInstance().get(mUrl,\n                new ANImageLoader.ImageListener() {\n                    @Override\n                    public void onResponse(final ANImageLoader.ImageContainer response,\n                                           boolean isImmediate) {\n                        if (isImmediate && isInLayoutPass) {\n                            post(new Runnable() {\n                                @Override\n                                public void run() {\n                                    onResponse(response, false);\n                                }\n                            });\n                            return;\n                        }\n\n                        if (response.getBitmap() != null) {\n                            setImageBitmap(response.getBitmap());\n                        } else if (mDefaultImageId != 0) {\n                            setImageResource(mDefaultImageId);\n                        }\n                    }\n\n                    @Override\n                    public void onError(ANError error) {\n                        if (mErrorImageId != 0) {\n                            setImageResource(mErrorImageId);\n                        }\n                    }\n                }, maxWidth, maxHeight, scaleType);\n\n        mImageContainer = newContainer;\n    }\n\n    private void setDefaultImageOrNull() {\n        if (mDefaultImageId != 0) {\n            setImageResource(mDefaultImageId);\n        } else {\n            setImageBitmap(null);\n        }\n    }\n\n    @Override\n    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {\n        super.onLayout(changed, left, top, right, bottom);\n        loadImageIfNecessary(true);\n    }\n\n    @Override\n    protected void onDetachedFromWindow() {\n        if (mImageContainer != null) {\n            mImageContainer.cancelRequest();\n            setImageBitmap(null);\n            mImageContainer = null;\n        }\n        super.onDetachedFromWindow();\n    }\n\n    @Override\n    protected void drawableStateChanged() {\n        super.drawableStateChanged();\n        invalidate();\n    }\n\n}\n"
  },
  {
    "path": "android-networking/src/main/res/values/strings.xml",
    "content": "<!--\n  ~    Copyright (C) 2016 Amit Shekhar\n  ~    Copyright (C) 2011 Android Open Source Project\n  ~\n  ~    Licensed under the Apache License, Version 2.0 (the \"License\");\n  ~    you may not use this file except in compliance with the License.\n  ~    You may obtain a copy of the License at\n  ~\n  ~        http://www.apache.org/licenses/LICENSE-2.0\n  ~\n  ~    Unless required by applicable law or agreed to in writing, software\n  ~    distributed under the License is distributed on an \"AS IS\" BASIS,\n  ~    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  ~    See the License for the specific language governing permissions and\n  ~    limitations under the License.\n  -->\n\n<resources>\n    <string name=\"app_name\">Android Networking</string>\n</resources>\n"
  },
  {
    "path": "android-networking/src/test/java/com/androidnetworking/ExampleUnitTest.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.androidnetworking;\n\nimport org.junit.Test;\n\nimport static org.junit.Assert.*;\n\n/**\n * To work on unit tests, switch the Test Artifact in the Build Variants view.\n */\npublic class ExampleUnitTest {\n    @Test\n    public void addition_isCorrect() throws Exception {\n        assertEquals(4, 2 + 2);\n    }\n}"
  },
  {
    "path": "app/.gitignore",
    "content": "/build\n"
  },
  {
    "path": "app/build.gradle",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\napply plugin: 'com.android.application'\n\nandroid {\n    compileSdkVersion rootProject.ext.compileSdkVersion\n    buildToolsVersion rootProject.ext.buildToolsVersion\n\n    defaultConfig {\n        applicationId \"com.networking\"\n        minSdkVersion rootProject.ext.minSdkVersion\n        targetSdkVersion rootProject.ext.targetSdkVersion\n        versionCode 1\n        versionName \"1.0\"\n    }\n    buildTypes {\n        release {\n            minifyEnabled false\n            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'\n        }\n    }\n}\n\ndependencies {\n    implementation fileTree(dir: 'libs', include: ['*.jar'])\n    testImplementation \"junit:junit:$rootProject.ext.jUnitVersion\"\n    implementation \"com.android.support:appcompat-v7:$rootProject.ext.supportAppCompatVersion\"\n    implementation project(':android-networking')\n}\n"
  },
  {
    "path": "app/proguard-rules.pro",
    "content": "# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in /Users/amitshekhar/Library/Android/sdk/tools/proguard/proguard-android.txt\n# You can edit the include path and order by changing the proguardFiles\n# directive in build.gradle.\n#\n# For more details, see\n#   http://developer.android.com/guide/developing/tools/proguard.html\n\n# Add any project specific keep options here:\n\n# If your project uses WebView with JS, uncomment the following\n# and specify the fully qualified class name to the JavaScript interface\n# class:\n#-keepclassmembers class fqcn.of.javascript.interface.for.webview {\n#   public *;\n#}\n"
  },
  {
    "path": "app/src/androidTest/java/com/androidnetworking/ApplicationTest.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.androidnetworking;\n\nimport android.app.Application;\nimport android.test.ApplicationTestCase;\n\n/**\n * <a href=\"http://d.android.com/tools/testing/testing_android.html\">Testing Fundamentals</a>\n */\npublic class ApplicationTest extends ApplicationTestCase<Application> {\n    public ApplicationTest() {\n        super(Application.class);\n    }\n}"
  },
  {
    "path": "app/src/main/AndroidManifest.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n  ~    Copyright (C) 2016 Amit Shekhar\n  ~    Copyright (C) 2011 Android Open Source Project\n  ~\n  ~    Licensed under the Apache License, Version 2.0 (the \"License\");\n  ~    you may not use this file except in compliance with the License.\n  ~    You may obtain a copy of the License at\n  ~\n  ~        http://www.apache.org/licenses/LICENSE-2.0\n  ~\n  ~    Unless required by applicable law or agreed to in writing, software\n  ~    distributed under the License is distributed on an \"AS IS\" BASIS,\n  ~    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  ~    See the License for the specific language governing permissions and\n  ~    limitations under the License.\n  -->\n\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    package=\"com.networking\">\n\n    <uses-permission android:name=\"android.permission.INTERNET\" />\n    <uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\" />\n\n    <application\n        android:name=\".MyApplication\"\n        android:allowBackup=\"true\"\n        android:icon=\"@mipmap/ic_launcher\"\n        android:label=\"@string/app_name\"\n        android:supportsRtl=\"true\"\n        android:theme=\"@style/AppTheme\">\n        <activity android:name=\".MainActivity\">\n            <intent-filter>\n                <action android:name=\"android.intent.action.MAIN\" />\n\n                <category android:name=\"android.intent.category.LAUNCHER\" />\n            </intent-filter>\n        </activity>\n\n        <activity android:name=\".ImageGridActivity\"></activity>\n        <activity android:name=\".ApiTestActivity\"></activity>\n        <activity android:name=\".OkHttpResponseTestActivity\"></activity>\n        <activity android:name=\".WebSocketActivity\"></activity>\n    </application>\n\n</manifest>\n"
  },
  {
    "path": "app/src/main/java/com/networking/ApiEndPoint.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.networking;\n\n/**\n * Created by amitshekhar on 29/03/16.\n */\npublic class ApiEndPoint {\n\n    public static final String BASE_URL = \"https://fierce-cove-29863.herokuapp.com\";\n    public static final String GET_JSON_ARRAY = \"/getAllUsers/{pageNumber}\";\n    public static final String GET_JSON_OBJECT = \"/getAnUserDetail/{userId}\";\n    public static final String CHECK_FOR_HEADER = \"/checkForHeader\";\n    public static final String POST_CREATE_AN_USER = \"/createAnUser\";\n    public static final String UPLOAD_IMAGE = \"/uploadImage\";\n\n}\n"
  },
  {
    "path": "app/src/main/java/com/networking/ApiTestActivity.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.networking;\n\nimport android.os.Bundle;\nimport android.os.Environment;\nimport android.os.Looper;\nimport android.support.v7.app.AppCompatActivity;\nimport android.util.Log;\nimport android.view.View;\n\nimport com.androidnetworking.AndroidNetworking;\nimport com.androidnetworking.common.ANRequest;\nimport com.androidnetworking.common.ANResponse;\nimport com.androidnetworking.common.Priority;\nimport com.androidnetworking.error.ANError;\nimport com.androidnetworking.interfaces.AnalyticsListener;\nimport com.androidnetworking.interfaces.DownloadListener;\nimport com.androidnetworking.interfaces.DownloadProgressListener;\nimport com.androidnetworking.interfaces.JSONArrayRequestListener;\nimport com.androidnetworking.interfaces.JSONObjectRequestListener;\nimport com.androidnetworking.interfaces.OkHttpResponseListener;\nimport com.androidnetworking.interfaces.ParsedRequestListener;\nimport com.androidnetworking.interfaces.UploadProgressListener;\nimport com.networking.model.User;\nimport com.networking.utils.Utils;\n\nimport org.json.JSONArray;\nimport org.json.JSONException;\nimport org.json.JSONObject;\n\nimport java.io.File;\nimport java.io.IOException;\nimport java.util.List;\nimport java.util.concurrent.Executors;\nimport java.util.concurrent.TimeUnit;\n\nimport okhttp3.OkHttpClient;\nimport okhttp3.Response;\n\n/**\n * Created by amitshekhar on 30/03/16.\n */\npublic class ApiTestActivity extends AppCompatActivity {\n\n    private static final String TAG = ApiTestActivity.class.getSimpleName();\n\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_api_test);\n    }\n\n    public void prefetch(View view) {\n        AndroidNetworking.get(ApiEndPoint.BASE_URL + ApiEndPoint.GET_JSON_ARRAY)\n                .addPathParameter(\"pageNumber\", \"0\")\n                .addQueryParameter(\"limit\", \"3\")\n                .setTag(this)\n                .setPriority(Priority.LOW)\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .prefetch();\n    }\n\n    public void prefetchDownload(View view) {\n        String url = \"http://www.colorado.edu/conflict/peace/download/peace_problem.ZIP\";\n        AndroidNetworking.download(url, Utils.getRootDirPath(getApplicationContext()), \"file1.zip\")\n                .setPriority(Priority.HIGH)\n                .setTag(this)\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .prefetch();\n    }\n\n    public void getAllUsers(View view) {\n        AndroidNetworking.get(ApiEndPoint.BASE_URL + ApiEndPoint.GET_JSON_ARRAY)\n                .addPathParameter(\"pageNumber\", \"0\")\n                .addQueryParameter(\"limit\", \"3\")\n                .setTag(this)\n                .setPriority(Priority.LOW)\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .getAsObjectList(User.class, new ParsedRequestListener<List<User>>() {\n                    @Override\n                    public void onResponse(List<User> users) {\n                        Log.d(TAG, \"userList size : \" + users.size());\n                        for (User user : users) {\n                            Log.d(TAG, \"id : \" + user.id);\n                            Log.d(TAG, \"firstname : \" + user.firstname);\n                            Log.d(TAG, \"lastname : \" + user.lastname);\n                        }\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        Utils.logError(TAG, anError);\n                    }\n                });\n    }\n\n    public void getAnUser(View view) {\n        AndroidNetworking.get(ApiEndPoint.BASE_URL + ApiEndPoint.GET_JSON_OBJECT)\n                .addPathParameter(\"userId\", \"1\")\n                .setTag(this)\n                .setPriority(Priority.LOW)\n                .setUserAgent(\"getAnUser\")\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .getAsObject(User.class, new ParsedRequestListener<User>() {\n                    @Override\n                    public void onResponse(User user) {\n                        Log.d(TAG, \"id : \" + user.id);\n                        Log.d(TAG, \"firstname : \" + user.firstname);\n                        Log.d(TAG, \"lastname : \" + user.lastname);\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        Utils.logError(TAG, anError);\n                    }\n                });\n    }\n\n    public void checkForHeaderGet(View view) {\n\n        ANRequest.GetRequestBuilder getRequestBuilder = new ANRequest.GetRequestBuilder(ApiEndPoint.BASE_URL + ApiEndPoint.CHECK_FOR_HEADER);\n\n        getRequestBuilder.addHeaders(\"token\", \"1234\")\n                .setTag(this)\n                .setPriority(Priority.LOW)\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .getAsJSONObject(new JSONObjectRequestListener() {\n                    @Override\n                    public void onResponse(JSONObject response) {\n                        Log.d(TAG, \"onResponse object : \" + response.toString());\n                        Log.d(TAG, \"onResponse isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                    }\n\n                    @Override\n                    public void onError(ANError error) {\n                        if (error.getErrorCode() != 0) {\n                            // received ANError from server\n                            // error.getErrorCode() - the ANError code from server\n                            // error.getErrorBody() - the ANError body from server\n                            // error.getErrorDetail() - just a ANError detail\n                            Log.d(TAG, \"onError errorCode : \" + error.getErrorCode());\n                            Log.d(TAG, \"onError errorBody : \" + error.getErrorBody());\n                            Log.d(TAG, \"onError errorDetail : \" + error.getErrorDetail());\n                        } else {\n                            // error.getErrorDetail() : connectionError, parseError, requestCancelledError\n                            Log.d(TAG, \"onError errorDetail : \" + error.getErrorDetail());\n                        }\n                    }\n                });\n    }\n\n    public void checkForHeaderPost(View view) {\n\n        ANRequest.PostRequestBuilder postRequestBuilder = AndroidNetworking.post(ApiEndPoint.BASE_URL + ApiEndPoint.CHECK_FOR_HEADER);\n\n        postRequestBuilder.addHeaders(\"token\", \"1234\");\n\n        ANRequest anRequest = postRequestBuilder.setTag(this)\n                .setPriority(Priority.LOW)\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build();\n\n        anRequest.setAnalyticsListener(new AnalyticsListener() {\n            @Override\n            public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                Log.d(TAG, \" bytesSent : \" + bytesSent);\n                Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                Log.d(TAG, \" isFromCache : \" + isFromCache);\n            }\n        });\n\n        anRequest.getAsJSONObject(new JSONObjectRequestListener() {\n            @Override\n            public void onResponse(JSONObject response) {\n                Log.d(TAG, \"onResponse object : \" + response.toString());\n                Log.d(TAG, \"onResponse isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n            }\n\n            @Override\n            public void onError(ANError error) {\n                if (error.getErrorCode() != 0) {\n                    // received ANError from server\n                    // error.getErrorCode() - the ANError code from server\n                    // error.getErrorBody() - the ANError body from server\n                    // error.getErrorDetail() - just a ANError detail\n                    Log.d(TAG, \"onError errorCode : \" + error.getErrorCode());\n                    Log.d(TAG, \"onError errorBody : \" + error.getErrorBody());\n                    Log.d(TAG, \"onError errorDetail : \" + error.getErrorDetail());\n                } else {\n                    // error.getErrorDetail() : connectionError, parseError, requestCancelledError\n                    Log.d(TAG, \"onError errorDetail : \" + error.getErrorDetail());\n                }\n            }\n        });\n    }\n\n    public void createAnUser(View view) {\n        AndroidNetworking.post(ApiEndPoint.BASE_URL + ApiEndPoint.POST_CREATE_AN_USER)\n                .addBodyParameter(\"firstname\", \"Suman\")\n                .addBodyParameter(\"lastname\", \"Shekhar\")\n                .setTag(this)\n                .setPriority(Priority.LOW)\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .getAsJSONObject(new JSONObjectRequestListener() {\n                    @Override\n                    public void onResponse(JSONObject response) {\n                        Log.d(TAG, \"onResponse object : \" + response.toString());\n                        Log.d(TAG, \"onResponse isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                    }\n\n                    @Override\n                    public void onError(ANError error) {\n                        if (error.getErrorCode() != 0) {\n                            // received ANError from server\n                            // error.getErrorCode() - the ANError code from server\n                            // error.getErrorBody() - the ANError body from server\n                            // error.getErrorDetail() - just a ANError detail\n                            Log.d(TAG, \"onError errorCode : \" + error.getErrorCode());\n                            Log.d(TAG, \"onError errorBody : \" + error.getErrorBody());\n                            Log.d(TAG, \"onError errorDetail : \" + error.getErrorDetail());\n                        } else {\n                            // error.getErrorDetail() : connectionError, parseError, requestCancelledError\n                            Log.d(TAG, \"onError errorDetail : \" + error.getErrorDetail());\n                        }\n                    }\n                });\n    }\n\n\n    public void createAnUserJSONObject(View view) {\n        JSONObject jsonObject = new JSONObject();\n        try {\n            jsonObject.put(\"firstname\", \"Rohit\");\n            jsonObject.put(\"lastname\", \"Kumar\");\n        } catch (JSONException e) {\n            e.printStackTrace();\n        }\n        AndroidNetworking.post(ApiEndPoint.BASE_URL + ApiEndPoint.POST_CREATE_AN_USER)\n                .addJSONObjectBody(jsonObject)\n                .setTag(this)\n                .setPriority(Priority.LOW)\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .getAsJSONObject(new JSONObjectRequestListener() {\n                    @Override\n                    public void onResponse(JSONObject response) {\n                        Log.d(TAG, \"onResponse object : \" + response.toString());\n                        Log.d(TAG, \"onResponse isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                    }\n\n                    @Override\n                    public void onError(ANError error) {\n                        if (error.getErrorCode() != 0) {\n                            // received ANError from server\n                            // error.getErrorCode() - the ANError code from server\n                            // error.getErrorBody() - the ANError body from server\n                            // error.getErrorDetail() - just a ANError detail\n                            Log.d(TAG, \"onError errorCode : \" + error.getErrorCode());\n                            Log.d(TAG, \"onError errorBody : \" + error.getErrorBody());\n                            Log.d(TAG, \"onError errorDetail : \" + error.getErrorDetail());\n                        } else {\n                            // error.getErrorDetail() : connectionError, parseError, requestCancelledError\n                            Log.d(TAG, \"onError errorDetail : \" + error.getErrorDetail());\n                        }\n                    }\n                });\n    }\n\n    public void downloadFile(final View view) {\n        String url = \"http://www.colorado.edu/conflict/peace/download/peace_problem.ZIP\";\n        AndroidNetworking.download(url, Utils.getRootDirPath(getApplicationContext()), \"file1.zip\")\n                .setPriority(Priority.HIGH)\n                .setTag(this)\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .setDownloadProgressListener(new DownloadProgressListener() {\n                    @Override\n                    public void onProgress(long bytesDownloaded, long totalBytes) {\n                        Log.d(TAG, \"bytesDownloaded : \" + bytesDownloaded + \" totalBytes : \" + totalBytes);\n                        Log.d(TAG, \"setDownloadProgressListener isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                    }\n                })\n                .startDownload(new DownloadListener() {\n                    @Override\n                    public void onDownloadComplete() {\n                        Log.d(TAG, \"File download Completed\");\n                        Log.d(TAG, \"onDownloadComplete isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                    }\n\n                    @Override\n                    public void onError(ANError error) {\n                        if (error.getErrorCode() != 0) {\n                            // received ANError from server\n                            // error.getErrorCode() - the ANError code from server\n                            // error.getErrorBody() - the ANError body from server\n                            // error.getErrorDetail() - just an ANError detail\n                            Log.d(TAG, \"onError errorCode : \" + error.getErrorCode());\n                            Log.d(TAG, \"onError errorBody : \" + error.getErrorBody());\n                            Log.d(TAG, \"onError errorDetail : \" + error.getErrorDetail());\n                        } else {\n                            // error.getErrorDetail() : connectionError, parseError, requestCancelledError\n                            Log.d(TAG, \"onError errorDetail : \" + error.getErrorDetail());\n                        }\n                    }\n                });\n    }\n\n    public void downloadImage(final View view) {\n        String url = \"http://i.imgur.com/AtbX9iX.png\";\n        AndroidNetworking.download(url, Utils.getRootDirPath(getApplicationContext()), \"image1.png\")\n                .setPriority(Priority.MEDIUM)\n                .setTag(this)\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .startDownload(new DownloadListener() {\n                    @Override\n                    public void onDownloadComplete() {\n                        Log.d(TAG, \"Image download Completed\");\n                        Log.d(TAG, \"onDownloadComplete isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                    }\n\n                    @Override\n                    public void onError(ANError error) {\n                        if (error.getErrorCode() != 0) {\n                            // received ANError from server\n                            // error.getErrorCode() - the ANError code from server\n                            // error.getErrorBody() - the ANError body from server\n                            // error.getErrorDetail() - just a ANError detail\n                            Log.d(TAG, \"onError errorCode : \" + error.getErrorCode());\n                            Log.d(TAG, \"onError errorBody : \" + error.getErrorBody());\n                            Log.d(TAG, \"onError errorDetail : \" + error.getErrorDetail());\n                        } else {\n                            // error.getErrorDetail() : connectionError, parseError, requestCancelledError\n                            Log.d(TAG, \"onError errorDetail : \" + error.getErrorDetail());\n                        }\n                    }\n                });\n    }\n\n    public void uploadImage(final View view) {\n        final String key = \"image\";\n        final File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath(), \"test.png\");\n        AndroidNetworking.upload(ApiEndPoint.BASE_URL + ApiEndPoint.UPLOAD_IMAGE)\n                .setPriority(Priority.MEDIUM)\n                .addMultipartFile(key, file)\n                .setTag(this)\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .setUploadProgressListener(new UploadProgressListener() {\n                    @Override\n                    public void onProgress(long bytesUploaded, long totalBytes) {\n                        Log.d(TAG, \"bytesUploaded : \" + bytesUploaded + \" totalBytes : \" + totalBytes);\n                        Log.d(TAG, \"setUploadProgressListener isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                    }\n                })\n                .getAsJSONObject(new JSONObjectRequestListener() {\n                    @Override\n                    public void onResponse(JSONObject response) {\n                        Log.d(TAG, \"Image upload Completed\");\n                        Log.d(TAG, \"onResponse object : \" + response.toString());\n                    }\n\n                    @Override\n                    public void onError(ANError error) {\n                        if (error.getErrorCode() != 0) {\n                            // received ANError from server\n                            // error.getErrorCode() - the ANError code from server\n                            // error.getErrorBody() - the ANError body from server\n                            // error.getErrorDetail() - just a ANError detail\n                            Log.d(TAG, \"onError errorCode : \" + error.getErrorCode());\n                            Log.d(TAG, \"onError errorBody : \" + error.getErrorBody());\n                            Log.d(TAG, \"onError errorDetail : \" + error.getErrorDetail());\n                        } else {\n                            // error.getErrorDetail() : connectionError, parseError, requestCancelledError\n                            Log.d(TAG, \"onError errorDetail : \" + error.getErrorDetail());\n                        }\n                    }\n                });\n    }\n\n    public void doNotCacheResponse(View view) {\n        AndroidNetworking.get(ApiEndPoint.BASE_URL + ApiEndPoint.GET_JSON_ARRAY)\n                .addPathParameter(\"pageNumber\", \"0\")\n                .addQueryParameter(\"limit\", \"3\")\n                .setTag(this)\n                .setPriority(Priority.LOW)\n                .doNotCacheResponse()\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .getAsJSONArray(new JSONArrayRequestListener() {\n                    @Override\n                    public void onResponse(JSONArray response) {\n                        Log.d(TAG, \"onResponse array : \" + response.toString());\n                        Log.d(TAG, \"onResponse isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                    }\n\n                    @Override\n                    public void onError(ANError error) {\n                        if (error.getErrorCode() != 0) {\n                            // received ANError from server\n                            // error.getErrorCode() - the ANError code from server\n                            // error.getErrorBody() - the ANError body from server\n                            // error.getErrorDetail() - just a ANError detail\n                            Log.d(TAG, \"onError errorCode : \" + error.getErrorCode());\n                            Log.d(TAG, \"onError errorBody : \" + error.getErrorBody());\n                            Log.d(TAG, \"onError errorDetail : \" + error.getErrorDetail());\n                        } else {\n                            // error.getErrorDetail() : connectionError, parseError, requestCancelledError\n                            Log.d(TAG, \"onError errorDetail : \" + error.getErrorDetail());\n                        }\n                    }\n                });\n    }\n\n    public void getResponseOnlyIfCached(View view) {\n        AndroidNetworking.get(ApiEndPoint.BASE_URL + ApiEndPoint.GET_JSON_ARRAY)\n                .addPathParameter(\"pageNumber\", \"0\")\n                .addQueryParameter(\"limit\", \"3\")\n                .setTag(this)\n                .setPriority(Priority.LOW)\n                .getResponseOnlyIfCached()\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .getAsJSONArray(new JSONArrayRequestListener() {\n                    @Override\n                    public void onResponse(JSONArray response) {\n                        Log.d(TAG, \"onResponse array : \" + response.toString());\n                        Log.d(TAG, \"onResponse isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                    }\n\n                    @Override\n                    public void onError(ANError error) {\n                        if (error.getErrorCode() != 0) {\n                            // received ANError from server\n                            // error.getErrorCode() - the ANError code from server\n                            // error.getErrorBody() - the ANError body from server\n                            // error.getErrorDetail() - just a ANError detail\n                            Log.d(TAG, \"onError errorCode : \" + error.getErrorCode());\n                            Log.d(TAG, \"onError errorBody : \" + error.getErrorBody());\n                            Log.d(TAG, \"onError errorDetail : \" + error.getErrorDetail());\n                        } else {\n                            // error.getErrorDetail() : connectionError, parseError, requestCancelledError\n                            Log.d(TAG, \"onError errorDetail : \" + error.getErrorDetail());\n                        }\n                    }\n                });\n    }\n\n    public void getResponseOnlyFromNetwork(View view) {\n        AndroidNetworking.get(ApiEndPoint.BASE_URL + ApiEndPoint.GET_JSON_ARRAY)\n                .addPathParameter(\"pageNumber\", \"0\")\n                .addQueryParameter(\"limit\", \"3\")\n                .setTag(this)\n                .setPriority(Priority.LOW)\n                .getResponseOnlyFromNetwork()\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .getAsJSONArray(new JSONArrayRequestListener() {\n                    @Override\n                    public void onResponse(JSONArray response) {\n                        Log.d(TAG, \"onResponse array : \" + response.toString());\n                        Log.d(TAG, \"onResponse isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                    }\n\n                    @Override\n                    public void onError(ANError error) {\n                        if (error.getErrorCode() != 0) {\n                            // received ANError from server\n                            // error.getErrorCode() - the ANError code from server\n                            // error.getErrorBody() - the ANError body from server\n                            // error.getErrorDetail() - just a ANError detail\n                            Log.d(TAG, \"onError errorCode : \" + error.getErrorCode());\n                            Log.d(TAG, \"onError errorBody : \" + error.getErrorBody());\n                            Log.d(TAG, \"onError errorDetail : \" + error.getErrorDetail());\n                        } else {\n                            // error.getErrorDetail() : connectionError, parseError, requestCancelledError\n                            Log.d(TAG, \"onError errorDetail : \" + error.getErrorDetail());\n                        }\n                    }\n                });\n    }\n\n    public void setMaxAgeCacheControl(View view) {\n        AndroidNetworking.get(ApiEndPoint.BASE_URL + ApiEndPoint.GET_JSON_ARRAY)\n                .addPathParameter(\"pageNumber\", \"0\")\n                .addQueryParameter(\"limit\", \"3\")\n                .setTag(this)\n                .setPriority(Priority.LOW)\n                .setMaxAgeCacheControl(0, TimeUnit.SECONDS)\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .getAsJSONArray(new JSONArrayRequestListener() {\n                    @Override\n                    public void onResponse(JSONArray response) {\n                        Log.d(TAG, \"onResponse array : \" + response.toString());\n                        Log.d(TAG, \"onResponse isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                    }\n\n                    @Override\n                    public void onError(ANError error) {\n                        if (error.getErrorCode() != 0) {\n                            // received ANError from server\n                            // error.getErrorCode() - the ANError code from server\n                            // error.getErrorBody() - the ANError body from server\n                            // error.getErrorDetail() - just a ANError detail\n                            Log.d(TAG, \"onError errorCode : \" + error.getErrorCode());\n                            Log.d(TAG, \"onError errorBody : \" + error.getErrorBody());\n                            Log.d(TAG, \"onError errorDetail : \" + error.getErrorDetail());\n                        } else {\n                            // error.getErrorDetail() : connectionError, parseError, requestCancelledError\n                            Log.d(TAG, \"onError errorDetail : \" + error.getErrorDetail());\n                        }\n                    }\n                });\n    }\n\n    public void setMaxStaleCacheControl(View view) {\n        AndroidNetworking.get(ApiEndPoint.BASE_URL + ApiEndPoint.GET_JSON_ARRAY)\n                .addPathParameter(\"pageNumber\", \"0\")\n                .addQueryParameter(\"limit\", \"3\")\n                .setTag(this)\n                .setPriority(Priority.LOW)\n                .setMaxStaleCacheControl(365, TimeUnit.SECONDS)\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .getAsJSONArray(new JSONArrayRequestListener() {\n                    @Override\n                    public void onResponse(JSONArray response) {\n                        Log.d(TAG, \"onResponse array : \" + response.toString());\n                        Log.d(TAG, \"onResponse isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                    }\n\n                    @Override\n                    public void onError(ANError error) {\n                        if (error.getErrorCode() != 0) {\n                            // received ANError from server\n                            // error.getErrorCode() - the ANError code from server\n                            // error.getErrorBody() - the ANError body from server\n                            // error.getErrorDetail() - just a ANError detail\n                            Log.d(TAG, \"onError errorCode : \" + error.getErrorCode());\n                            Log.d(TAG, \"onError errorBody : \" + error.getErrorBody());\n                            Log.d(TAG, \"onError errorDetail : \" + error.getErrorDetail());\n                        } else {\n                            // error.getErrorDetail() : connectionError, parseError, requestCancelledError\n                            Log.d(TAG, \"onError errorDetail : \" + error.getErrorDetail());\n                        }\n                    }\n                });\n    }\n\n    public void cleanupDestinationTest(View view) {\n        String url = \"http://i.imgur.com/m6K1DCQ.jpg\";\n        AndroidNetworking.download(url, Utils.getRootDirPath(getApplicationContext()), \"cleanupDestinationTest.jpg\")\n                .setPriority(Priority.HIGH)\n                .setTag(\"cleanupDestinationTest\")\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .setDownloadProgressListener(new DownloadProgressListener() {\n                    @Override\n                    public void onProgress(long bytesDownloaded, long totalBytes) {\n                        Log.d(TAG, \"bytesDownloaded : \" + bytesDownloaded + \" totalBytes : \" + totalBytes);\n                        Log.d(TAG, \"setDownloadProgressListener isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                        if (bytesDownloaded > 50) {\n                            AndroidNetworking.cancel(\"cleanupDestinationTest\");\n                            Log.d(TAG, \"cancel: cleanupDestinationTest\");\n                        }\n                    }\n                })\n                .startDownload(new DownloadListener() {\n                    @Override\n                    public void onDownloadComplete() {\n                        Log.d(TAG, \"File download Completed\");\n                        Log.d(TAG, \"onDownloadComplete isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                    }\n\n                    @Override\n                    public void onError(ANError error) {\n                        if (error.getErrorCode() != 0) {\n                            // received ANError from server\n                            // error.getErrorCode() - the ANError code from server\n                            // error.getErrorBody() - the ANError body from server\n                            // error.getErrorDetail() - just an ANError detail\n                            Log.d(TAG, \"onError errorCode : \" + error.getErrorCode());\n                            Log.d(TAG, \"onError errorBody : \" + error.getErrorBody());\n                            Log.d(TAG, \"onError errorDetail : \" + error.getErrorDetail());\n                        } else {\n                            // error.getErrorDetail() : connectionError, parseError, requestCancelledError\n                            Log.d(TAG, \"onError errorDetail : \" + error.getErrorDetail());\n                        }\n                    }\n                });\n    }\n\n    public void disableGzipForCustomRequest(View view) {\n        AndroidNetworking.post(ApiEndPoint.BASE_URL + ApiEndPoint.POST_CREATE_AN_USER)\n                .addBodyParameter(\"firstname\", \"Amit\")\n                .addBodyParameter(\"lastname\", \"Shekhar\")\n                .setTag(this)\n                .setOkHttpClient(new OkHttpClient())\n                .setPriority(Priority.LOW)\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .getAsJSONObject(new JSONObjectRequestListener() {\n                    @Override\n                    public void onResponse(JSONObject response) {\n                        Log.d(TAG, \"onResponse object : \" + response.toString());\n                        Log.d(TAG, \"onResponse isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                    }\n\n                    @Override\n                    public void onError(ANError error) {\n                        if (error.getErrorCode() != 0) {\n                            // received ANError from server\n                            // error.getErrorCode() - the ANError code from server\n                            // error.getErrorBody() - the ANError body from server\n                            // error.getErrorDetail() - just a ANError detail\n                            Log.d(TAG, \"onError errorCode : \" + error.getErrorCode());\n                            Log.d(TAG, \"onError errorBody : \" + error.getErrorBody());\n                            Log.d(TAG, \"onError errorDetail : \" + error.getErrorDetail());\n                        } else {\n                            // error.getErrorDetail() : connectionError, parseError, requestCancelledError\n                            Log.d(TAG, \"onError errorDetail : \" + error.getErrorDetail());\n                        }\n                    }\n                });\n    }\n\n    public void checkCacheForCustomClient(View view) {\n        String url = \"http://www.colorado.edu/conflict/peace/download/peace_problem.ZIP\";\n        AndroidNetworking.download(url, Utils.getRootDirPath(getApplicationContext()), \"file1.zip\")\n                .setPriority(Priority.HIGH)\n                .setTag(this)\n                .setOkHttpClient(new OkHttpClient())\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .setDownloadProgressListener(new DownloadProgressListener() {\n                    @Override\n                    public void onProgress(long bytesDownloaded, long totalBytes) {\n                        Log.d(TAG, \"bytesDownloaded : \" + bytesDownloaded + \" totalBytes : \" + totalBytes);\n                        Log.d(TAG, \"setDownloadProgressListener isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                    }\n                })\n                .startDownload(new DownloadListener() {\n                    @Override\n                    public void onDownloadComplete() {\n                        Log.d(TAG, \"File download Completed\");\n                        Log.d(TAG, \"onDownloadComplete isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                    }\n\n                    @Override\n                    public void onError(ANError error) {\n                        if (error.getErrorCode() != 0) {\n                            // received ANError from server\n                            // error.getErrorCode() - the ANError code from server\n                            // error.getErrorBody() - the ANError body from server\n                            // error.getErrorDetail() - just an ANError detail\n                            Log.d(TAG, \"onError errorCode : \" + error.getErrorCode());\n                            Log.d(TAG, \"onError errorBody : \" + error.getErrorBody());\n                            Log.d(TAG, \"onError errorDetail : \" + error.getErrorDetail());\n                        } else {\n                            // error.getErrorDetail() : connectionError, parseError, requestCancelledError\n                            Log.d(TAG, \"onError errorDetail : \" + error.getErrorDetail());\n                        }\n                    }\n                });\n    }\n\n    public void checkOkHttpResponse(View view) {\n\n        AndroidNetworking.get(ApiEndPoint.BASE_URL + ApiEndPoint.GET_JSON_ARRAY)\n                .addPathParameter(\"pageNumber\", \"0\")\n                .addQueryParameter(\"limit\", \"3\")\n                .setTag(this)\n                .setPriority(Priority.LOW)\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .getAsOkHttpResponse(new OkHttpResponseListener() {\n                    @Override\n                    public void onResponse(Response response) {\n                        if (response != null) {\n                            if (response.isSuccessful()) {\n                                Log.d(TAG, \"response is successful\");\n                                try {\n                                    Log.d(TAG, \"response : \" + response.body().source().readUtf8());\n                                } catch (IOException e) {\n                                    e.printStackTrace();\n                                }\n                            } else {\n                                Log.d(TAG, \"response is not successful\");\n                            }\n                        } else {\n                            Log.d(TAG, \"response is null\");\n                        }\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        Utils.logError(TAG, anError);\n                    }\n                });\n\n        AndroidNetworking.post(ApiEndPoint.BASE_URL + ApiEndPoint.POST_CREATE_AN_USER)\n                .addBodyParameter(\"firstname\", \"Suman\")\n                .addBodyParameter(\"lastname\", \"Shekhar\")\n                .setTag(this)\n                .setPriority(Priority.LOW)\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .getAsOkHttpResponse(new OkHttpResponseListener() {\n                    @Override\n                    public void onResponse(Response response) {\n                        if (response != null) {\n                            if (response.isSuccessful()) {\n                                Log.d(TAG, \"response is successful\");\n                                try {\n                                    Log.d(TAG, \"response : \" + response.body().source().readUtf8());\n                                } catch (IOException e) {\n                                    e.printStackTrace();\n                                }\n                            } else {\n                                Log.d(TAG, \"response is not successful\");\n                            }\n                        } else {\n                            Log.d(TAG, \"response is null\");\n                        }\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        Utils.logError(TAG, anError);\n                    }\n                });\n\n        AndroidNetworking.upload(ApiEndPoint.BASE_URL + ApiEndPoint.UPLOAD_IMAGE)\n                .setPriority(Priority.MEDIUM)\n                .addMultipartFile(\"image\", new File(Environment.getExternalStorageDirectory().getAbsolutePath(), \"test.png\"))\n                .setTag(this)\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .setUploadProgressListener(new UploadProgressListener() {\n                    @Override\n                    public void onProgress(long bytesUploaded, long totalBytes) {\n                        Log.d(TAG, \"bytesUploaded : \" + bytesUploaded + \" totalBytes : \" + totalBytes);\n                        Log.d(TAG, \"setUploadProgressListener isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                    }\n                })\n                .getAsOkHttpResponse(new OkHttpResponseListener() {\n                    @Override\n                    public void onResponse(Response response) {\n                        if (response != null) {\n                            if (response.isSuccessful()) {\n                                Log.d(TAG, \"response is successful\");\n                                try {\n                                    Log.d(TAG, \"response : \" + response.body().source().readUtf8());\n                                } catch (IOException e) {\n                                    e.printStackTrace();\n                                }\n                            } else {\n                                Log.d(TAG, \"response is not successful\");\n                            }\n                        } else {\n                            Log.d(TAG, \"response is null\");\n                        }\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        Utils.logError(TAG, anError);\n                    }\n                });\n    }\n\n\n    public void checkSynchronousCall(View view) {\n        new Thread(new Runnable() {\n            @Override\n            public void run() {\n\n                String url = \"http://www.colorado.edu/conflict/peace/download/peace_problem.ZIP\";\n                ANRequest requestOne = AndroidNetworking\n                        .download(url, Utils.getRootDirPath(getApplicationContext()), \"file1.zip\")\n                        .build()\n                        .setAnalyticsListener(new AnalyticsListener() {\n                            @Override\n                            public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                                Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                                Log.d(TAG, \" bytesSent : \" + bytesSent);\n                                Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                                Log.d(TAG, \" isFromCache : \" + isFromCache);\n                            }\n                        })\n                        .setDownloadProgressListener(new DownloadProgressListener() {\n                            @Override\n                            public void onProgress(long bytesDownloaded, long totalBytes) {\n                                Log.d(TAG, \"bytesDownloaded : \" + bytesDownloaded + \" totalBytes : \" + totalBytes);\n                                Log.d(TAG, \"setDownloadProgressListener isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n\n                            }\n                        });\n                ANResponse<String> responseOne = requestOne.executeForDownload();\n\n                if (responseOne.isSuccess()) {\n                    Log.d(TAG, \"checkSynchronousCall : download success\");\n                    Log.d(TAG, \"checkSynchronousCall : download result \" + responseOne.getResult());\n                    Response response = responseOne.getOkHttpResponse();\n                    Log.d(TAG, \"checkSynchronousCall : headers : \" + response.headers().toString());\n                } else {\n                    Log.d(TAG, \"checkSynchronousCall : download failed\");\n                    Utils.logError(TAG, responseOne.getError());\n                }\n\n\n                ANRequest requestTwo = AndroidNetworking.get(ApiEndPoint.BASE_URL + ApiEndPoint.GET_JSON_ARRAY)\n                        .addPathParameter(\"pageNumber\", \"0\")\n                        .addQueryParameter(\"limit\", \"3\")\n                        .build()\n                        .setAnalyticsListener(new AnalyticsListener() {\n                            @Override\n                            public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                                Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                                Log.d(TAG, \" bytesSent : \" + bytesSent);\n                                Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                                Log.d(TAG, \" isFromCache : \" + isFromCache);\n                            }\n                        });\n                ANResponse<List<User>> responseTwo = requestTwo.executeForObjectList(User.class);\n\n                if (responseTwo.isSuccess()) {\n                    Log.d(TAG, \"checkSynchronousCall : response success\");\n                    List<User> users = responseTwo.getResult();\n                    Log.d(TAG, \"userList size : \" + users.size());\n                    for (User user : users) {\n                        Log.d(TAG, \"id : \" + user.id);\n                        Log.d(TAG, \"firstname : \" + user.firstname);\n                        Log.d(TAG, \"lastname : \" + user.lastname);\n                    }\n                    Response response = responseTwo.getOkHttpResponse();\n                    Log.d(TAG, \"checkSynchronousCall : headers : \" + response.headers().toString());\n                } else {\n                    Log.d(TAG, \"checkSynchronousCall : response failed\");\n                    Utils.logError(TAG, responseTwo.getError());\n                }\n\n\n                JSONObject jsonObject = new JSONObject();\n                try {\n                    jsonObject.put(\"firstname\", \"Rohit\");\n                    jsonObject.put(\"lastname\", \"Kumar\");\n                } catch (JSONException e) {\n                    e.printStackTrace();\n                }\n\n\n                ANRequest requestThree = AndroidNetworking.post(ApiEndPoint.BASE_URL + ApiEndPoint.POST_CREATE_AN_USER)\n                        .addJSONObjectBody(jsonObject)\n                        .build()\n                        .setAnalyticsListener(new AnalyticsListener() {\n                            @Override\n                            public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                                Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                                Log.d(TAG, \" bytesSent : \" + bytesSent);\n                                Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                                Log.d(TAG, \" isFromCache : \" + isFromCache);\n                            }\n                        });\n                ANResponse<JSONObject> responseThree = requestThree.executeForJSONObject();\n\n                if (responseThree.isSuccess()) {\n                    Log.d(TAG, \"checkSynchronousCall : jsonObjectANResponse success\");\n                    JSONObject jsonObjectFinal = responseThree.getResult();\n                    Log.d(TAG, \"checkSynchronousCall : jsonObjectANResponse result \" + jsonObjectFinal.toString());\n                    Response response = responseThree.getOkHttpResponse();\n                    Log.d(TAG, \"checkSynchronousCall : headers : \" + response.headers().toString());\n                } else {\n                    Log.d(TAG, \"checkSynchronousCall : jsonObjectANResponse failed\");\n                    Utils.logError(TAG, responseThree.getError());\n                }\n\n\n                ANRequest requestFour = AndroidNetworking.get(ApiEndPoint.BASE_URL + ApiEndPoint.GET_JSON_ARRAY)\n                        .addPathParameter(\"pageNumber\", \"0\")\n                        .addQueryParameter(\"limit\", \"3\")\n                        .build()\n                        .setAnalyticsListener(new AnalyticsListener() {\n                            @Override\n                            public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                                Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                                Log.d(TAG, \" bytesSent : \" + bytesSent);\n                                Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                                Log.d(TAG, \" isFromCache : \" + isFromCache);\n                            }\n                        });\n                ANResponse<Response> responseFour = requestFour.executeForOkHttpResponse();\n\n\n                if (responseFour.isSuccess()) {\n                    Log.d(TAG, \"checkSynchronousCall : okHttpResponse success\");\n                    Response okHttpResponse = responseFour.getResult();\n                    if (okHttpResponse != null) {\n                        if (okHttpResponse.isSuccessful()) {\n                            Log.d(TAG, \"response is successful\");\n                            try {\n                                Log.d(TAG, \"response : \" + okHttpResponse.body().source().readUtf8());\n                            } catch (IOException e) {\n                                e.printStackTrace();\n                            }\n                        } else {\n                            Log.d(TAG, \"response is not successful\");\n                        }\n                    } else {\n                        Log.d(TAG, \"response is null\");\n                    }\n                } else {\n                    Log.d(TAG, \"checkSynchronousCall : okHttpResponse failed\");\n                    Utils.logError(TAG, responseFour.getError());\n                }\n            }\n        }).start();\n    }\n\n    public void checkOptionsRequest(View view) {\n        AndroidNetworking.options(\"https://api.github.com/square/okhttp/issues\")\n                .build()\n                .getAsOkHttpResponse(new OkHttpResponseListener() {\n                    @Override\n                    public void onResponse(Response response) {\n                        Log.d(TAG, \"response : \" + response.headers().toString());\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        Utils.logError(TAG, anError);\n                    }\n                });\n    }\n\n    public void getCurrentConnectionQuality(View view) {\n        Log.d(TAG, \"getCurrentConnectionQuality : \" + AndroidNetworking.getCurrentConnectionQuality() + \" currentBandwidth : \" + AndroidNetworking.getCurrentBandwidth());\n    }\n}\n"
  },
  {
    "path": "app/src/main/java/com/networking/ImageGridActivity.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.networking;\n\nimport android.os.Bundle;\nimport android.support.v4.app.FragmentActivity;\nimport android.support.v4.app.FragmentTransaction;\n\nimport com.networking.fragments.ImageGridFragment;\n\n/**\n * Created by amitshekhar on 23/03/16.\n */\npublic class ImageGridActivity extends FragmentActivity {\n    private static final String TAG = \"ImageGridActivity\";\n\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n\n        if (getSupportFragmentManager().findFragmentByTag(TAG) == null) {\n            final FragmentTransaction ft = getSupportFragmentManager().beginTransaction();\n            ft.add(android.R.id.content, new ImageGridFragment(), TAG);\n            ft.commit();\n        }\n    }\n}\n"
  },
  {
    "path": "app/src/main/java/com/networking/MainActivity.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.networking;\n\nimport android.content.Intent;\nimport android.graphics.Bitmap;\nimport android.os.Bundle;\nimport android.support.v7.app.AppCompatActivity;\nimport android.util.Log;\nimport android.view.View;\nimport android.widget.ImageView;\n\nimport com.androidnetworking.AndroidNetworking;\nimport com.androidnetworking.common.Priority;\nimport com.androidnetworking.error.ANError;\nimport com.androidnetworking.interfaces.AnalyticsListener;\nimport com.androidnetworking.interfaces.BitmapRequestListener;\nimport com.androidnetworking.interfaces.JSONArrayRequestListener;\nimport com.androidnetworking.interfaces.JSONObjectRequestListener;\nimport com.androidnetworking.internal.ANImageLoader;\nimport com.androidnetworking.widget.ANImageView;\nimport com.networking.provider.Images;\n\nimport org.json.JSONArray;\nimport org.json.JSONObject;\n\npublic class MainActivity extends AppCompatActivity {\n\n    private static final String TAG = MainActivity.class.getSimpleName();\n    private static final String URL_IMAGE = \"http://i.imgur.com/2M7Hasn.png\";\n    private static final String URL_IMAGE_LOADER = \"http://i.imgur.com/52md06W.jpg\";\n\n    private ImageView imageView;\n    private ANImageView ANImageView;\n\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_main);\n        imageView = (ImageView) findViewById(R.id.imageView);\n        ANImageView = (ANImageView) findViewById(R.id.greatImageView);\n        ANImageView.setDefaultImageResId(R.drawable.ic_toys_black_24dp);\n        ANImageView.setErrorImageResId(R.drawable.ic_error_outline_black_24dp);\n        ANImageView.setImageUrl(Images.imageThumbUrls[0]);\n        makeJSONArrayRequest();\n        makeJSONObjectRequest();\n    }\n\n    private void makeJSONArrayRequest() {\n        AndroidNetworking.get(ApiEndPoint.BASE_URL + ApiEndPoint.GET_JSON_ARRAY)\n                .setTag(this)\n                .addPathParameter(\"pageNumber\", \"0\")\n                .addQueryParameter(\"limit\", \"3\")\n                .setPriority(Priority.LOW)\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .getAsJSONArray(new JSONArrayRequestListener() {\n                    @Override\n                    public void onResponse(JSONArray response) {\n                        Log.d(TAG, \"onResponse array : \" + response.toString());\n                    }\n\n                    @Override\n                    public void onError(ANError error) {\n                        if (error.getErrorCode() != 0) {\n                            // received ANError from server\n                            // error.getErrorCode() - the ANError code from server\n                            // error.getErrorBody() - the ANError body from server\n                            // error.getErrorDetail() - just a ANError detail\n                            Log.d(TAG, \"onError errorCode : \" + error.getErrorCode());\n                            Log.d(TAG, \"onError errorBody : \" + error.getErrorBody());\n                            Log.d(TAG, \"onError errorDetail : \" + error.getErrorDetail());\n                        } else {\n                            // error.getErrorDetail() : connectionError, parseError, requestCancelledError\n                            Log.d(TAG, \"onError errorDetail : \" + error.getErrorDetail());\n                        }\n                    }\n                });\n    }\n\n    private void makeJSONObjectRequest() {\n        AndroidNetworking.get(ApiEndPoint.BASE_URL + ApiEndPoint.GET_JSON_OBJECT)\n                .setTag(this)\n                .addPathParameter(\"userId\", \"1\")\n                .setPriority(Priority.HIGH)\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .getAsJSONObject(new JSONObjectRequestListener() {\n                    @Override\n                    public void onResponse(JSONObject response) {\n                        Log.d(TAG, \"onResponse object : \" + response.toString());\n                    }\n\n                    @Override\n                    public void onError(ANError error) {\n                        if (error.getErrorCode() != 0) {\n                            // received ANError from server\n                            // error.getErrorCode() - the ANError code from server\n                            // error.getErrorBody() - the ANError body from server\n                            // error.getErrorDetail() - just a ANError detail\n                            Log.d(TAG, \"onError errorCode : \" + error.getErrorCode());\n                            Log.d(TAG, \"onError errorBody : \" + error.getErrorBody());\n                            Log.d(TAG, \"onError errorDetail : \" + error.getErrorDetail());\n                        } else {\n                            // error.getErrorDetail() : connectionError, parseError, requestCancelledError\n                            Log.d(TAG, \"onError errorDetail : \" + error.getErrorDetail());\n                        }\n                    }\n                });\n    }\n\n    public void makeRequests(View view) {\n        for (int i = 0; i < 10; i++) {\n            makeJSONArrayRequest();\n            makeJSONObjectRequest();\n        }\n    }\n\n    public void cancelAllRequests(View view) {\n        Log.d(TAG, \"isRequestRunning before cancel : \" + AndroidNetworking.isRequestRunning(this));\n        AndroidNetworking.cancel(this);\n        Log.d(TAG, \"isRequestRunning after cancel : \" + AndroidNetworking.isRequestRunning(this));\n    }\n\n    public void loadImageDirect(View view) {\n        AndroidNetworking.get(URL_IMAGE)\n                .setTag(\"imageRequestTag\")\n                .setPriority(Priority.MEDIUM)\n                .setImageScaleType(null)\n                .setBitmapMaxHeight(0)\n                .setBitmapMaxWidth(0)\n                .setBitmapConfig(Bitmap.Config.ARGB_8888)\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .getAsBitmap(new BitmapRequestListener() {\n                    @Override\n                    public void onResponse(Bitmap response) {\n                        Log.d(TAG, \"onResponse Bitmap\");\n                        imageView.setImageBitmap(response);\n                    }\n\n                    @Override\n                    public void onError(ANError error) {\n                        if (error.getErrorCode() != 0) {\n                            // received ANError from server\n                            // error.getErrorCode() - the ANError code from server\n                            // error.getErrorBody() - the ANError body from server\n                            // error.getErrorDetail() - just a ANError detail\n                            Log.d(TAG, \"onError errorCode : \" + error.getErrorCode());\n                            Log.d(TAG, \"onError errorBody : \" + error.getErrorBody());\n                            Log.d(TAG, \"onError errorDetail : \" + error.getErrorDetail());\n                        } else {\n                            // error.getErrorDetail() : connectionError, parseError, requestCancelledError\n                            Log.d(TAG, \"onError errorDetail : \" + error.getErrorDetail());\n                        }\n                    }\n                });\n    }\n\n    public void loadImageFromImageLoader(View view) {\n        ANImageLoader.getInstance().get(URL_IMAGE_LOADER, ANImageLoader.getImageListener(imageView,\n                R.drawable.ic_toys_black_24dp, R.drawable.ic_error_outline_black_24dp));\n    }\n\n    public void startGridActivity(View view) {\n        startActivity(new Intent(MainActivity.this, ImageGridActivity.class));\n    }\n\n    public void startApiTestActivity(View view) {\n        startActivity(new Intent(MainActivity.this, ApiTestActivity.class));\n    }\n\n    public void startOkHttpResponseTestActivity(View view) {\n        startActivity(new Intent(MainActivity.this, OkHttpResponseTestActivity.class));\n    }\n\n    public void startWebSocketActivity(View view) {\n        startActivity(new Intent(MainActivity.this, WebSocketActivity.class));\n    }\n}\n"
  },
  {
    "path": "app/src/main/java/com/networking/MyApplication.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.networking;\n\nimport android.app.Application;\nimport android.graphics.BitmapFactory;\nimport android.util.Log;\n\nimport com.androidnetworking.AndroidNetworking;\nimport com.androidnetworking.common.ConnectionQuality;\nimport com.androidnetworking.interfaces.ConnectionQualityChangeListener;\n\n/**\n * Created by amitshekhar on 22/03/16.\n */\npublic class MyApplication extends Application {\n\n    private static final String TAG = MyApplication.class.getSimpleName();\n    private static MyApplication appInstance = null;\n\n    public static MyApplication getInstance() {\n        return appInstance;\n    }\n\n    @Override\n    public void onCreate() {\n        super.onCreate();\n        appInstance = this;\n        AndroidNetworking.initialize(getApplicationContext());\n        BitmapFactory.Options options = new BitmapFactory.Options();\n        options.inPurgeable = true;\n        AndroidNetworking.setBitmapDecodeOptions(options);\n        AndroidNetworking.enableLogging();\n        AndroidNetworking.setConnectionQualityChangeListener(new ConnectionQualityChangeListener() {\n            @Override\n            public void onChange(ConnectionQuality currentConnectionQuality, int currentBandwidth) {\n                Log.d(TAG, \"onChange: currentConnectionQuality : \" + currentConnectionQuality + \" currentBandwidth : \" + currentBandwidth);\n            }\n        });\n\n    }\n\n}\n"
  },
  {
    "path": "app/src/main/java/com/networking/OkHttpResponseTestActivity.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.networking;\n\nimport android.os.Bundle;\nimport android.os.Environment;\nimport android.os.Looper;\nimport android.support.v7.app.AppCompatActivity;\nimport android.util.Log;\nimport android.view.View;\n\nimport com.androidnetworking.AndroidNetworking;\nimport com.androidnetworking.common.ANRequest;\nimport com.androidnetworking.common.ANResponse;\nimport com.androidnetworking.common.Priority;\nimport com.androidnetworking.error.ANError;\nimport com.androidnetworking.interfaces.AnalyticsListener;\nimport com.androidnetworking.interfaces.DownloadListener;\nimport com.androidnetworking.interfaces.DownloadProgressListener;\nimport com.androidnetworking.interfaces.OkHttpResponseAndJSONArrayRequestListener;\nimport com.androidnetworking.interfaces.OkHttpResponseAndJSONObjectRequestListener;\nimport com.androidnetworking.interfaces.OkHttpResponseAndParsedRequestListener;\nimport com.androidnetworking.interfaces.OkHttpResponseListener;\nimport com.androidnetworking.interfaces.UploadProgressListener;\nimport com.networking.model.User;\nimport com.networking.utils.Utils;\n\nimport org.json.JSONArray;\nimport org.json.JSONException;\nimport org.json.JSONObject;\n\nimport java.io.File;\nimport java.io.IOException;\nimport java.util.List;\nimport java.util.concurrent.Executors;\nimport java.util.concurrent.TimeUnit;\n\nimport okhttp3.OkHttpClient;\nimport okhttp3.Response;\n\n/**\n * Created by amitshekhar on 30/03/16.\n */\npublic class OkHttpResponseTestActivity extends AppCompatActivity {\n\n    private static final String TAG = OkHttpResponseTestActivity.class.getSimpleName();\n\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_api_test);\n    }\n\n    public void prefetch(View view) {\n        AndroidNetworking.get(ApiEndPoint.BASE_URL + ApiEndPoint.GET_JSON_ARRAY)\n                .addPathParameter(\"pageNumber\", \"0\")\n                .addQueryParameter(\"limit\", \"3\")\n                .setTag(this)\n                .setPriority(Priority.LOW)\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .prefetch();\n    }\n\n    public void prefetchDownload(View view) {\n        String url = \"http://www.colorado.edu/conflict/peace/download/peace_problem.ZIP\";\n        AndroidNetworking.download(url, Utils.getRootDirPath(getApplicationContext()), \"file1.zip\")\n                .setPriority(Priority.HIGH)\n                .setTag(this)\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .prefetch();\n    }\n\n    public void getAllUsers(View view) {\n        AndroidNetworking.get(ApiEndPoint.BASE_URL + ApiEndPoint.GET_JSON_ARRAY)\n                .addPathParameter(\"pageNumber\", \"0\")\n                .addQueryParameter(\"limit\", \"3\")\n                .setTag(this)\n                .setPriority(Priority.LOW)\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .getAsOkHttpResponseAndObjectList(User.class, new OkHttpResponseAndParsedRequestListener<List<User>>() {\n                    @Override\n                    public void onResponse(Response okHttpResponse, List<User> users) {\n                        Log.d(TAG, \"userList size : \" + users.size());\n                        for (User user : users) {\n                            Log.d(TAG, \"id : \" + user.id);\n                            Log.d(TAG, \"firstname : \" + user.firstname);\n                            Log.d(TAG, \"lastname : \" + user.lastname);\n                        }\n                        if (okHttpResponse.isSuccessful()) {\n                            Log.d(TAG, \"onResponse success headers : \" + okHttpResponse.headers().toString());\n                        } else {\n                            Log.d(TAG, \"onResponse not success headers : \" + okHttpResponse.headers().toString());\n                        }\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        Utils.logError(TAG, anError);\n                    }\n                });\n    }\n\n    public void getAnUser(View view) {\n        AndroidNetworking.get(ApiEndPoint.BASE_URL + ApiEndPoint.GET_JSON_OBJECT)\n                .addPathParameter(\"userId\", \"1\")\n                .setTag(this)\n                .setPriority(Priority.LOW)\n                .setUserAgent(\"getAnUser\")\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .getAsOkHttpResponseAndObject(User.class, new OkHttpResponseAndParsedRequestListener<User>() {\n                    @Override\n                    public void onResponse(Response okHttpResponse, User user) {\n                        Log.d(TAG, \"id : \" + user.id);\n                        Log.d(TAG, \"firstname : \" + user.firstname);\n                        Log.d(TAG, \"lastname : \" + user.lastname);\n                        if (okHttpResponse.isSuccessful()) {\n                            Log.d(TAG, \"onResponse success headers : \" + okHttpResponse.headers().toString());\n                        } else {\n                            Log.d(TAG, \"onResponse not success headers : \" + okHttpResponse.headers().toString());\n                        }\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        Utils.logError(TAG, anError);\n                    }\n                });\n    }\n\n    public void checkForHeaderGet(View view) {\n\n        ANRequest.GetRequestBuilder getRequestBuilder = new ANRequest.GetRequestBuilder(ApiEndPoint.BASE_URL + ApiEndPoint.CHECK_FOR_HEADER);\n\n        getRequestBuilder.addHeaders(\"token\", \"1234\")\n                .setTag(this)\n                .setPriority(Priority.LOW)\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                }).getAsOkHttpResponseAndJSONObject(new OkHttpResponseAndJSONObjectRequestListener() {\n            @Override\n            public void onResponse(Response okHttpResponse, JSONObject response) {\n                Log.d(TAG, \"onResponse object : \" + response.toString());\n                if (okHttpResponse.isSuccessful()) {\n                    Log.d(TAG, \"onResponse success headers : \" + okHttpResponse.headers().toString());\n                } else {\n                    Log.d(TAG, \"onResponse not success headers : \" + okHttpResponse.headers().toString());\n                }\n            }\n\n            @Override\n            public void onError(ANError anError) {\n                Utils.logError(TAG, anError);\n            }\n        });\n    }\n\n    public void checkForHeaderPost(View view) {\n\n        ANRequest.PostRequestBuilder postRequestBuilder = AndroidNetworking.post(ApiEndPoint.BASE_URL + ApiEndPoint.CHECK_FOR_HEADER);\n\n        postRequestBuilder.addHeaders(\"token\", \"1234\");\n\n        ANRequest anRequest = postRequestBuilder.setTag(this)\n                .setPriority(Priority.LOW)\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build();\n\n        anRequest.setAnalyticsListener(new AnalyticsListener() {\n            @Override\n            public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                Log.d(TAG, \" bytesSent : \" + bytesSent);\n                Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                Log.d(TAG, \" isFromCache : \" + isFromCache);\n            }\n        });\n\n        anRequest.getAsOkHttpResponseAndJSONObject(new OkHttpResponseAndJSONObjectRequestListener() {\n            @Override\n            public void onResponse(Response okHttpResponse, JSONObject response) {\n                Log.d(TAG, \"onResponse object : \" + response.toString());\n                Log.d(TAG, \"onResponse isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                if (okHttpResponse.isSuccessful()) {\n                    Log.d(TAG, \"onResponse success headers : \" + okHttpResponse.headers().toString());\n                } else {\n                    Log.d(TAG, \"onResponse not success headers : \" + okHttpResponse.headers().toString());\n                }\n            }\n\n            @Override\n            public void onError(ANError anError) {\n                Utils.logError(TAG, anError);\n            }\n        });\n    }\n\n    public void createAnUser(View view) {\n        AndroidNetworking.post(ApiEndPoint.BASE_URL + ApiEndPoint.POST_CREATE_AN_USER)\n                .addBodyParameter(\"firstname\", \"Suman\")\n                .addBodyParameter(\"lastname\", \"Shekhar\")\n                .setTag(this)\n                .setPriority(Priority.LOW)\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .getAsOkHttpResponseAndJSONObject(new OkHttpResponseAndJSONObjectRequestListener() {\n                    @Override\n                    public void onResponse(Response okHttpResponse, JSONObject response) {\n                        Log.d(TAG, \"onResponse object : \" + response.toString());\n                        Log.d(TAG, \"onResponse isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                        if (okHttpResponse.isSuccessful()) {\n                            Log.d(TAG, \"onResponse success headers : \" + okHttpResponse.headers().toString());\n                        } else {\n                            Log.d(TAG, \"onResponse not success headers : \" + okHttpResponse.headers().toString());\n                        }\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        Utils.logError(TAG, anError);\n                    }\n                });\n    }\n\n\n    public void createAnUserJSONObject(View view) {\n        JSONObject jsonObject = new JSONObject();\n        try {\n            jsonObject.put(\"firstname\", \"Rohit\");\n            jsonObject.put(\"lastname\", \"Kumar\");\n        } catch (JSONException e) {\n            e.printStackTrace();\n        }\n        AndroidNetworking.post(ApiEndPoint.BASE_URL + ApiEndPoint.POST_CREATE_AN_USER)\n                .addJSONObjectBody(jsonObject)\n                .setTag(this)\n                .setPriority(Priority.LOW)\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                }).getAsOkHttpResponseAndJSONObject(new OkHttpResponseAndJSONObjectRequestListener() {\n            @Override\n            public void onResponse(Response okHttpResponse, JSONObject response) {\n                Log.d(TAG, \"onResponse object : \" + response.toString());\n                Log.d(TAG, \"onResponse isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                if (okHttpResponse.isSuccessful()) {\n                    Log.d(TAG, \"onResponse success headers : \" + okHttpResponse.headers().toString());\n                } else {\n                    Log.d(TAG, \"onResponse not success headers : \" + okHttpResponse.headers().toString());\n                }\n            }\n\n            @Override\n            public void onError(ANError anError) {\n                Utils.logError(TAG, anError);\n            }\n        });\n    }\n\n    public void downloadFile(final View view) {\n        String url = \"http://www.colorado.edu/conflict/peace/download/peace_problem.ZIP\";\n        AndroidNetworking.download(url, Utils.getRootDirPath(getApplicationContext()), \"file1.zip\")\n                .setPriority(Priority.HIGH)\n                .setTag(this)\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .setDownloadProgressListener(new DownloadProgressListener() {\n                    @Override\n                    public void onProgress(long bytesDownloaded, long totalBytes) {\n                        Log.d(TAG, \"bytesDownloaded : \" + bytesDownloaded + \" totalBytes : \" + totalBytes);\n                        Log.d(TAG, \"setDownloadProgressListener isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                    }\n                })\n                .startDownload(new DownloadListener() {\n                    @Override\n                    public void onDownloadComplete() {\n                        Log.d(TAG, \"File download Completed\");\n                        Log.d(TAG, \"onDownloadComplete isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                    }\n\n                    @Override\n                    public void onError(ANError error) {\n                        if (error.getErrorCode() != 0) {\n                            // received ANError from server\n                            // error.getErrorCode() - the ANError code from server\n                            // error.getErrorBody() - the ANError body from server\n                            // error.getErrorDetail() - just an ANError detail\n                            Log.d(TAG, \"onError errorCode : \" + error.getErrorCode());\n                            Log.d(TAG, \"onError errorBody : \" + error.getErrorBody());\n                            Log.d(TAG, \"onError errorDetail : \" + error.getErrorDetail());\n                        } else {\n                            // error.getErrorDetail() : connectionError, parseError, requestCancelledError\n                            Log.d(TAG, \"onError errorDetail : \" + error.getErrorDetail());\n                        }\n                    }\n                });\n    }\n\n    public void downloadImage(final View view) {\n        String url = \"http://i.imgur.com/AtbX9iX.png\";\n        AndroidNetworking.download(url, Utils.getRootDirPath(getApplicationContext()), \"image1.png\")\n                .setPriority(Priority.MEDIUM)\n                .setTag(this)\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .startDownload(new DownloadListener() {\n                    @Override\n                    public void onDownloadComplete() {\n                        Log.d(TAG, \"Image download Completed\");\n                        Log.d(TAG, \"onDownloadComplete isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                    }\n\n                    @Override\n                    public void onError(ANError error) {\n                        if (error.getErrorCode() != 0) {\n                            // received ANError from server\n                            // error.getErrorCode() - the ANError code from server\n                            // error.getErrorBody() - the ANError body from server\n                            // error.getErrorDetail() - just a ANError detail\n                            Log.d(TAG, \"onError errorCode : \" + error.getErrorCode());\n                            Log.d(TAG, \"onError errorBody : \" + error.getErrorBody());\n                            Log.d(TAG, \"onError errorDetail : \" + error.getErrorDetail());\n                        } else {\n                            // error.getErrorDetail() : connectionError, parseError, requestCancelledError\n                            Log.d(TAG, \"onError errorDetail : \" + error.getErrorDetail());\n                        }\n                    }\n                });\n    }\n\n    public void uploadImage(final View view) {\n        AndroidNetworking.upload(ApiEndPoint.BASE_URL + ApiEndPoint.UPLOAD_IMAGE)\n                .setPriority(Priority.MEDIUM)\n                .addMultipartFile(\"image\", new File(Environment.getExternalStorageDirectory().getAbsolutePath(), \"test.png\"))\n                .setTag(this)\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .setUploadProgressListener(new UploadProgressListener() {\n                    @Override\n                    public void onProgress(long bytesUploaded, long totalBytes) {\n                        Log.d(TAG, \"bytesUploaded : \" + bytesUploaded + \" totalBytes : \" + totalBytes);\n                        Log.d(TAG, \"setUploadProgressListener isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                    }\n                })\n                .getAsOkHttpResponseAndJSONObject(new OkHttpResponseAndJSONObjectRequestListener() {\n                    @Override\n                    public void onResponse(Response okHttpResponse, JSONObject response) {\n                        Log.d(TAG, \"Image upload Completed\");\n                        Log.d(TAG, \"onResponse object : \" + response.toString());\n                        Log.d(TAG, \"onResponse isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                        if (okHttpResponse.isSuccessful()) {\n                            Log.d(TAG, \"onResponse success headers : \" + okHttpResponse.headers().toString());\n                        } else {\n                            Log.d(TAG, \"onResponse not success headers : \" + okHttpResponse.headers().toString());\n                        }\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        Utils.logError(TAG, anError);\n                    }\n                });\n    }\n\n    public void doNotCacheResponse(View view) {\n        AndroidNetworking.get(ApiEndPoint.BASE_URL + ApiEndPoint.GET_JSON_ARRAY)\n                .addPathParameter(\"pageNumber\", \"0\")\n                .addQueryParameter(\"limit\", \"3\")\n                .setTag(this)\n                .setPriority(Priority.LOW)\n                .doNotCacheResponse()\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .getAsOkHttpResponseAndJSONArray(new OkHttpResponseAndJSONArrayRequestListener() {\n                    @Override\n                    public void onResponse(Response okHttpResponse, JSONArray response) {\n                        Log.d(TAG, \"onResponse object : \" + response.toString());\n                        Log.d(TAG, \"onResponse isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                        if (okHttpResponse.isSuccessful()) {\n                            Log.d(TAG, \"onResponse success headers : \" + okHttpResponse.headers().toString());\n                        } else {\n                            Log.d(TAG, \"onResponse not success headers : \" + okHttpResponse.headers().toString());\n                        }\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        Utils.logError(TAG, anError);\n                    }\n                });\n    }\n\n    public void getResponseOnlyIfCached(View view) {\n        AndroidNetworking.get(ApiEndPoint.BASE_URL + ApiEndPoint.GET_JSON_ARRAY)\n                .addPathParameter(\"pageNumber\", \"0\")\n                .addQueryParameter(\"limit\", \"3\")\n                .setTag(this)\n                .setPriority(Priority.LOW)\n                .getResponseOnlyIfCached()\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .getAsOkHttpResponseAndJSONArray(new OkHttpResponseAndJSONArrayRequestListener() {\n                    @Override\n                    public void onResponse(Response okHttpResponse, JSONArray response) {\n                        Log.d(TAG, \"onResponse object : \" + response.toString());\n                        Log.d(TAG, \"onResponse isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                        if (okHttpResponse.isSuccessful()) {\n                            Log.d(TAG, \"onResponse success headers : \" + okHttpResponse.headers().toString());\n                        } else {\n                            Log.d(TAG, \"onResponse not success headers : \" + okHttpResponse.headers().toString());\n                        }\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        Utils.logError(TAG, anError);\n                    }\n                });\n    }\n\n    public void getResponseOnlyFromNetwork(View view) {\n        AndroidNetworking.get(ApiEndPoint.BASE_URL + ApiEndPoint.GET_JSON_ARRAY)\n                .addPathParameter(\"pageNumber\", \"0\")\n                .addQueryParameter(\"limit\", \"3\")\n                .setTag(this)\n                .setPriority(Priority.LOW)\n                .getResponseOnlyFromNetwork()\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .getAsOkHttpResponseAndJSONArray(new OkHttpResponseAndJSONArrayRequestListener() {\n                    @Override\n                    public void onResponse(Response okHttpResponse, JSONArray response) {\n                        Log.d(TAG, \"onResponse object : \" + response.toString());\n                        Log.d(TAG, \"onResponse isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                        if (okHttpResponse.isSuccessful()) {\n                            Log.d(TAG, \"onResponse success headers : \" + okHttpResponse.headers().toString());\n                        } else {\n                            Log.d(TAG, \"onResponse not success headers : \" + okHttpResponse.headers().toString());\n                        }\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        Utils.logError(TAG, anError);\n                    }\n                });\n    }\n\n    public void setMaxAgeCacheControl(View view) {\n        AndroidNetworking.get(ApiEndPoint.BASE_URL + ApiEndPoint.GET_JSON_ARRAY)\n                .addPathParameter(\"pageNumber\", \"0\")\n                .addQueryParameter(\"limit\", \"3\")\n                .setTag(this)\n                .setPriority(Priority.LOW)\n                .setMaxAgeCacheControl(0, TimeUnit.SECONDS)\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .getAsOkHttpResponseAndJSONArray(new OkHttpResponseAndJSONArrayRequestListener() {\n                    @Override\n                    public void onResponse(Response okHttpResponse, JSONArray response) {\n                        Log.d(TAG, \"onResponse object : \" + response.toString());\n                        Log.d(TAG, \"onResponse isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                        if (okHttpResponse.isSuccessful()) {\n                            Log.d(TAG, \"onResponse success headers : \" + okHttpResponse.headers().toString());\n                        } else {\n                            Log.d(TAG, \"onResponse not success headers : \" + okHttpResponse.headers().toString());\n                        }\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        Utils.logError(TAG, anError);\n                    }\n                });\n    }\n\n    public void setMaxStaleCacheControl(View view) {\n        AndroidNetworking.get(ApiEndPoint.BASE_URL + ApiEndPoint.GET_JSON_ARRAY)\n                .addPathParameter(\"pageNumber\", \"0\")\n                .addQueryParameter(\"limit\", \"3\")\n                .setTag(this)\n                .setPriority(Priority.LOW)\n                .setMaxStaleCacheControl(365, TimeUnit.SECONDS)\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .getAsOkHttpResponseAndJSONArray(new OkHttpResponseAndJSONArrayRequestListener() {\n                    @Override\n                    public void onResponse(Response okHttpResponse, JSONArray response) {\n                        Log.d(TAG, \"onResponse object : \" + response.toString());\n                        Log.d(TAG, \"onResponse isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                        if (okHttpResponse.isSuccessful()) {\n                            Log.d(TAG, \"onResponse success headers : \" + okHttpResponse.headers().toString());\n                        } else {\n                            Log.d(TAG, \"onResponse not success headers : \" + okHttpResponse.headers().toString());\n                        }\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        Utils.logError(TAG, anError);\n                    }\n                });\n    }\n\n    public void cleanupDestinationTest(View view) {\n        String url = \"http://i.imgur.com/m6K1DCQ.jpg\";\n        AndroidNetworking.download(url, Utils.getRootDirPath(getApplicationContext()), \"cleanupDestinationTest.jpg\")\n                .setPriority(Priority.HIGH)\n                .setTag(\"cleanupDestinationTest\")\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .setDownloadProgressListener(new DownloadProgressListener() {\n                    @Override\n                    public void onProgress(long bytesDownloaded, long totalBytes) {\n                        Log.d(TAG, \"bytesDownloaded : \" + bytesDownloaded + \" totalBytes : \" + totalBytes);\n                        Log.d(TAG, \"setDownloadProgressListener isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                        if (bytesDownloaded > 50) {\n                            AndroidNetworking.cancel(\"cleanupDestinationTest\");\n                            Log.d(TAG, \"cancel: cleanupDestinationTest\");\n                        }\n                    }\n                })\n                .startDownload(new DownloadListener() {\n                    @Override\n                    public void onDownloadComplete() {\n                        Log.d(TAG, \"File download Completed\");\n                        Log.d(TAG, \"onDownloadComplete isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                    }\n\n                    @Override\n                    public void onError(ANError error) {\n                        if (error.getErrorCode() != 0) {\n                            // received ANError from server\n                            // error.getErrorCode() - the ANError code from server\n                            // error.getErrorBody() - the ANError body from server\n                            // error.getErrorDetail() - just an ANError detail\n                            Log.d(TAG, \"onError errorCode : \" + error.getErrorCode());\n                            Log.d(TAG, \"onError errorBody : \" + error.getErrorBody());\n                            Log.d(TAG, \"onError errorDetail : \" + error.getErrorDetail());\n                        } else {\n                            // error.getErrorDetail() : connectionError, parseError, requestCancelledError\n                            Log.d(TAG, \"onError errorDetail : \" + error.getErrorDetail());\n                        }\n                    }\n                });\n    }\n\n    public void disableGzipForCustomRequest(View view) {\n        AndroidNetworking.post(ApiEndPoint.BASE_URL + ApiEndPoint.POST_CREATE_AN_USER)\n                .addBodyParameter(\"firstname\", \"Amit\")\n                .addBodyParameter(\"lastname\", \"Shekhar\")\n                .setTag(this)\n                .setOkHttpClient(new OkHttpClient())\n                .setPriority(Priority.LOW)\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .getAsOkHttpResponseAndJSONObject(new OkHttpResponseAndJSONObjectRequestListener() {\n                    @Override\n                    public void onResponse(Response okHttpResponse, JSONObject response) {\n                        Log.d(TAG, \"onResponse object : \" + response.toString());\n                        Log.d(TAG, \"onResponse isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                        if (okHttpResponse.isSuccessful()) {\n                            Log.d(TAG, \"onResponse success headers : \" + okHttpResponse.headers().toString());\n                        } else {\n                            Log.d(TAG, \"onResponse not success headers : \" + okHttpResponse.headers().toString());\n                        }\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        Utils.logError(TAG, anError);\n                    }\n                });\n    }\n\n    public void checkCacheForCustomClient(View view) {\n        String url = \"http://www.colorado.edu/conflict/peace/download/peace_problem.ZIP\";\n        AndroidNetworking.download(url, Utils.getRootDirPath(getApplicationContext()), \"file1.zip\")\n                .setPriority(Priority.HIGH)\n                .setTag(this)\n                .setOkHttpClient(new OkHttpClient())\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .setDownloadProgressListener(new DownloadProgressListener() {\n                    @Override\n                    public void onProgress(long bytesDownloaded, long totalBytes) {\n                        Log.d(TAG, \"bytesDownloaded : \" + bytesDownloaded + \" totalBytes : \" + totalBytes);\n                        Log.d(TAG, \"setDownloadProgressListener isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                    }\n                })\n                .startDownload(new DownloadListener() {\n                    @Override\n                    public void onDownloadComplete() {\n                        Log.d(TAG, \"File download Completed\");\n                        Log.d(TAG, \"onDownloadComplete isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                    }\n\n                    @Override\n                    public void onError(ANError error) {\n                        if (error.getErrorCode() != 0) {\n                            // received ANError from server\n                            // error.getErrorCode() - the ANError code from server\n                            // error.getErrorBody() - the ANError body from server\n                            // error.getErrorDetail() - just an ANError detail\n                            Log.d(TAG, \"onError errorCode : \" + error.getErrorCode());\n                            Log.d(TAG, \"onError errorBody : \" + error.getErrorBody());\n                            Log.d(TAG, \"onError errorDetail : \" + error.getErrorDetail());\n                        } else {\n                            // error.getErrorDetail() : connectionError, parseError, requestCancelledError\n                            Log.d(TAG, \"onError errorDetail : \" + error.getErrorDetail());\n                        }\n                    }\n                });\n    }\n\n    public void checkOkHttpResponse(View view) {\n\n        AndroidNetworking.get(ApiEndPoint.BASE_URL + ApiEndPoint.GET_JSON_ARRAY)\n                .addPathParameter(\"pageNumber\", \"0\")\n                .addQueryParameter(\"limit\", \"3\")\n                .setTag(this)\n                .setPriority(Priority.LOW)\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .getAsOkHttpResponse(new OkHttpResponseListener() {\n                    @Override\n                    public void onResponse(Response response) {\n                        if (response != null) {\n                            if (response.isSuccessful()) {\n                                Log.d(TAG, \"response is successful\");\n                                try {\n                                    Log.d(TAG, \"response : \" + response.body().source().readUtf8());\n                                } catch (IOException e) {\n                                    e.printStackTrace();\n                                }\n                            } else {\n                                Log.d(TAG, \"response is not successful\");\n                            }\n                        } else {\n                            Log.d(TAG, \"response is null\");\n                        }\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        Utils.logError(TAG, anError);\n                    }\n                });\n\n        AndroidNetworking.post(ApiEndPoint.BASE_URL + ApiEndPoint.POST_CREATE_AN_USER)\n                .addBodyParameter(\"firstname\", \"Suman\")\n                .addBodyParameter(\"lastname\", \"Shekhar\")\n                .setTag(this)\n                .setPriority(Priority.LOW)\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .getAsOkHttpResponse(new OkHttpResponseListener() {\n                    @Override\n                    public void onResponse(Response response) {\n                        if (response != null) {\n                            if (response.isSuccessful()) {\n                                Log.d(TAG, \"response is successful\");\n                                try {\n                                    Log.d(TAG, \"response : \" + response.body().source().readUtf8());\n                                } catch (IOException e) {\n                                    e.printStackTrace();\n                                }\n                            } else {\n                                Log.d(TAG, \"response is not successful\");\n                            }\n                        } else {\n                            Log.d(TAG, \"response is null\");\n                        }\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        Utils.logError(TAG, anError);\n                    }\n                });\n\n        AndroidNetworking.upload(ApiEndPoint.BASE_URL + ApiEndPoint.UPLOAD_IMAGE)\n                .setPriority(Priority.MEDIUM)\n                .addMultipartFile(\"image\", new File(Environment.getExternalStorageDirectory().getAbsolutePath(), \"test.png\"))\n                .setTag(this)\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .setUploadProgressListener(new UploadProgressListener() {\n                    @Override\n                    public void onProgress(long bytesUploaded, long totalBytes) {\n                        Log.d(TAG, \"bytesUploaded : \" + bytesUploaded + \" totalBytes : \" + totalBytes);\n                        Log.d(TAG, \"setUploadProgressListener isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                    }\n                })\n                .getAsOkHttpResponse(new OkHttpResponseListener() {\n                    @Override\n                    public void onResponse(Response response) {\n                        if (response != null) {\n                            if (response.isSuccessful()) {\n                                Log.d(TAG, \"response is successful\");\n                                try {\n                                    Log.d(TAG, \"response : \" + response.body().source().readUtf8());\n                                } catch (IOException e) {\n                                    e.printStackTrace();\n                                }\n                            } else {\n                                Log.d(TAG, \"response is not successful\");\n                            }\n                        } else {\n                            Log.d(TAG, \"response is null\");\n                        }\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        Utils.logError(TAG, anError);\n                    }\n                });\n    }\n\n\n    public void checkSynchronousCall(View view) {\n        new Thread(new Runnable() {\n            @Override\n            public void run() {\n\n                String url = \"http://www.colorado.edu/conflict/peace/download/peace_problem.ZIP\";\n                ANRequest requestOne = AndroidNetworking\n                        .download(url, Utils.getRootDirPath(getApplicationContext()), \"file1.zip\")\n                        .setPriority(Priority.HIGH)\n                        .setTag(this)\n                        .build()\n                        .setAnalyticsListener(new AnalyticsListener() {\n                            @Override\n                            public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                                Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                                Log.d(TAG, \" bytesSent : \" + bytesSent);\n                                Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                                Log.d(TAG, \" isFromCache : \" + isFromCache);\n                            }\n                        })\n                        .setDownloadProgressListener(new DownloadProgressListener() {\n                            @Override\n                            public void onProgress(long bytesDownloaded, long totalBytes) {\n                                Log.d(TAG, \"bytesDownloaded : \" + bytesDownloaded + \" totalBytes : \" + totalBytes);\n                                Log.d(TAG, \"setDownloadProgressListener isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n\n                            }\n                        });\n                ANResponse<String> responseOne = requestOne.executeForDownload();\n\n                if (responseOne.isSuccess()) {\n                    Log.d(TAG, \"checkSynchronousCall : download success\");\n                    Log.d(TAG, \"checkSynchronousCall : download result \" + responseOne.getResult());\n                    Response response = responseOne.getOkHttpResponse();\n                    Log.d(TAG, \"checkSynchronousCall : headers : \" + response.headers().toString());\n                } else {\n                    Log.d(TAG, \"checkSynchronousCall : download failed\");\n                    Utils.logError(TAG, responseOne.getError());\n                }\n\n\n                ANRequest requestTwo = AndroidNetworking.get(ApiEndPoint.BASE_URL + ApiEndPoint.GET_JSON_ARRAY)\n                        .addPathParameter(\"pageNumber\", \"0\")\n                        .addQueryParameter(\"limit\", \"3\")\n                        .setTag(this)\n                        .setPriority(Priority.LOW)\n                        .build()\n                        .setAnalyticsListener(new AnalyticsListener() {\n                            @Override\n                            public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                                Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                                Log.d(TAG, \" bytesSent : \" + bytesSent);\n                                Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                                Log.d(TAG, \" isFromCache : \" + isFromCache);\n                            }\n                        });\n                ANResponse<List<User>> responseTwo = requestTwo.executeForObjectList(User.class);\n\n                if (responseTwo.isSuccess()) {\n                    Log.d(TAG, \"checkSynchronousCall : response success\");\n                    List<User> users = responseTwo.getResult();\n                    Log.d(TAG, \"userList size : \" + users.size());\n                    for (User user : users) {\n                        Log.d(TAG, \"id : \" + user.id);\n                        Log.d(TAG, \"firstname : \" + user.firstname);\n                        Log.d(TAG, \"lastname : \" + user.lastname);\n                    }\n                    Response response = responseTwo.getOkHttpResponse();\n                    Log.d(TAG, \"checkSynchronousCall : headers : \" + response.headers().toString());\n                } else {\n                    Log.d(TAG, \"checkSynchronousCall : response failed\");\n                    Utils.logError(TAG, responseTwo.getError());\n                }\n\n\n                JSONObject jsonObject = new JSONObject();\n                try {\n                    jsonObject.put(\"firstname\", \"Rohit\");\n                    jsonObject.put(\"lastname\", \"Kumar\");\n                } catch (JSONException e) {\n                    e.printStackTrace();\n                }\n\n\n                ANRequest requestThree = AndroidNetworking.post(ApiEndPoint.BASE_URL + ApiEndPoint.POST_CREATE_AN_USER)\n                        .addJSONObjectBody(jsonObject)\n                        .setTag(this)\n                        .setPriority(Priority.LOW)\n                        .build()\n                        .setAnalyticsListener(new AnalyticsListener() {\n                            @Override\n                            public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                                Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                                Log.d(TAG, \" bytesSent : \" + bytesSent);\n                                Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                                Log.d(TAG, \" isFromCache : \" + isFromCache);\n                            }\n                        });\n                ANResponse<JSONObject> responseThree = requestThree.executeForJSONObject();\n\n                if (responseThree.isSuccess()) {\n                    Log.d(TAG, \"checkSynchronousCall : jsonObjectANResponse success\");\n                    JSONObject jsonObjectFinal = responseThree.getResult();\n                    Log.d(TAG, \"checkSynchronousCall : jsonObjectANResponse result \" + jsonObjectFinal.toString());\n                    Response response = responseThree.getOkHttpResponse();\n                    Log.d(TAG, \"checkSynchronousCall : headers : \" + response.headers().toString());\n                } else {\n                    Log.d(TAG, \"checkSynchronousCall : jsonObjectANResponse failed\");\n                    Utils.logError(TAG, responseThree.getError());\n                }\n\n\n                ANRequest requestFour = AndroidNetworking.get(ApiEndPoint.BASE_URL + ApiEndPoint.GET_JSON_ARRAY)\n                        .addPathParameter(\"pageNumber\", \"0\")\n                        .addQueryParameter(\"limit\", \"3\")\n                        .setTag(this)\n                        .setPriority(Priority.LOW)\n                        .build()\n                        .setAnalyticsListener(new AnalyticsListener() {\n                            @Override\n                            public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                                Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                                Log.d(TAG, \" bytesSent : \" + bytesSent);\n                                Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                                Log.d(TAG, \" isFromCache : \" + isFromCache);\n                            }\n                        });\n                ANResponse<Response> responseFour = requestFour.executeForOkHttpResponse();\n\n\n                if (responseFour.isSuccess()) {\n                    Log.d(TAG, \"checkSynchronousCall : okHttpResponse success\");\n                    Response okHttpResponse = responseFour.getResult();\n                    if (okHttpResponse != null) {\n                        if (okHttpResponse.isSuccessful()) {\n                            Log.d(TAG, \"response is successful\");\n                            try {\n                                Log.d(TAG, \"response : \" + okHttpResponse.body().source().readUtf8());\n                            } catch (IOException e) {\n                                e.printStackTrace();\n                            }\n                        } else {\n                            Log.d(TAG, \"response is not successful\");\n                        }\n                    } else {\n                        Log.d(TAG, \"response is null\");\n                    }\n                } else {\n                    Log.d(TAG, \"checkSynchronousCall : okHttpResponse failed\");\n                    Utils.logError(TAG, responseFour.getError());\n                }\n            }\n        }).start();\n    }\n\n    public void checkOptionsRequest(View view) {\n        AndroidNetworking.options(\"https://api.github.com/square/okhttp/issues\")\n                .build()\n                .getAsOkHttpResponse(new OkHttpResponseListener() {\n                    @Override\n                    public void onResponse(Response response) {\n                        Log.d(TAG, \"response : \" + response.headers().toString());\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        Utils.logError(TAG, anError);\n                    }\n                });\n    }\n\n    public void getCurrentConnectionQuality(View view) {\n        Log.d(TAG, \"getCurrentConnectionQuality : \" + AndroidNetworking.getCurrentConnectionQuality() + \" currentBandwidth : \" + AndroidNetworking.getCurrentBandwidth());\n    }\n}\n"
  },
  {
    "path": "app/src/main/java/com/networking/WebSocketActivity.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.networking;\n\nimport android.os.Bundle;\nimport android.support.v7.app.AppCompatActivity;\nimport android.widget.TextView;\n\nimport java.util.concurrent.TimeUnit;\n\nimport okhttp3.OkHttpClient;\nimport okhttp3.Request;\nimport okhttp3.Response;\nimport okhttp3.WebSocket;\nimport okhttp3.WebSocketListener;\nimport okio.ByteString;\n\n/**\n * Created by amitshekhar on 09/12/16.\n */\n\npublic class WebSocketActivity extends AppCompatActivity {\n\n    private static final String TAG = WebSocketActivity.class.getSimpleName();\n    private TextView textView;\n    private WebSocket webSocket;\n\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_web_socket);\n        textView = (TextView) findViewById(R.id.textView);\n    }\n\n    @Override\n    protected void onStart() {\n        super.onStart();\n        connectWebSocket();\n    }\n\n    @Override\n    protected void onStop() {\n        super.onStop();\n        disconnectWebSocket();\n    }\n\n    private void connectWebSocket() {\n        OkHttpClient client = new OkHttpClient.Builder()\n                .readTimeout(0, TimeUnit.MILLISECONDS)\n                .build();\n\n        Request request = new Request.Builder()\n                .url(\"ws://echo.websocket.org\")\n                .build();\n        webSocket = client.newWebSocket(request, getWebSocketListener());\n    }\n\n    private void disconnectWebSocket() {\n        if (webSocket != null) {\n            webSocket.cancel();\n        }\n    }\n\n    private WebSocketListener getWebSocketListener() {\n        return new WebSocketListener() {\n            @Override\n            public void onOpen(WebSocket webSocket, Response response) {\n                webSocket.send(\"Hello...\");\n                webSocket.send(\"...World!\");\n                webSocket.send(ByteString.decodeHex(\"deadbeef\"));\n                webSocket.close(1000, \"Goodbye, World!\");\n            }\n\n            @Override\n            public void onMessage(WebSocket webSocket, final String text) {\n                runOnUiThread(new Runnable() {\n                    @Override\n                    public void run() {\n                        textView.append(\"\\n\");\n                        textView.append(\"MESSAGE: \" + text);\n                    }\n                });\n            }\n\n            @Override\n            public void onMessage(WebSocket webSocket,final ByteString bytes) {\n                runOnUiThread(new Runnable() {\n                    @Override\n                    public void run() {\n                        textView.append(\"\\n\");\n                        textView.append(\"MESSAGE: \" + bytes.hex());\n                    }\n                });\n            }\n\n            @Override\n            public void onClosing(WebSocket webSocket,final int code,final String reason) {\n                webSocket.close(1000, null);\n                runOnUiThread(new Runnable() {\n                    @Override\n                    public void run() {\n                        textView.append(\"\\n\");\n                        textView.append(\"CLOSE: \" + code + \" \" + reason);\n                    }\n                });\n            }\n\n            @Override\n            public void onFailure(WebSocket webSocket, Throwable t, Response response) {\n                t.printStackTrace();\n            }\n        };\n    }\n}\n"
  },
  {
    "path": "app/src/main/java/com/networking/fragments/ImageGridFragment.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.networking.fragments;\n\nimport android.annotation.TargetApi;\nimport android.content.Context;\nimport android.os.Build;\nimport android.os.Bundle;\nimport android.support.v4.app.Fragment;\nimport android.util.TypedValue;\nimport android.view.LayoutInflater;\nimport android.view.View;\nimport android.view.ViewGroup;\nimport android.view.ViewTreeObserver;\nimport android.widget.AbsListView;\nimport android.widget.AdapterView;\nimport android.widget.BaseAdapter;\nimport android.widget.GridView;\nimport android.widget.ImageView;\n\nimport com.androidnetworking.widget.ANImageView;\nimport com.networking.R;\nimport com.networking.provider.Images;\n\n/**\n * Created by amitshekhar on 23/03/16.\n */\npublic class ImageGridFragment extends Fragment implements AdapterView.OnItemClickListener {\n    private static final String TAG = \"ImageGridFragment\";\n\n    private int mImageThumbSize;\n    private int mImageThumbSpacing;\n    private ImageAdapter mAdapter;\n\n    public ImageGridFragment() {\n    }\n\n    @Override\n    public void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setHasOptionsMenu(true);\n\n        mImageThumbSize = getResources().getDimensionPixelSize(R.dimen.image_thumbnail_size);\n        mImageThumbSpacing = getResources().getDimensionPixelSize(R.dimen.image_thumbnail_spacing);\n        mAdapter = new ImageAdapter(getActivity());\n\n    }\n\n    @Override\n    public View onCreateView(\n            LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {\n\n        final View v = inflater.inflate(R.layout.image_grid_fragment, container, false);\n        final GridView mGridView = (GridView) v.findViewById(R.id.gridView);\n        mGridView.setAdapter(mAdapter);\n        mGridView.setOnItemClickListener(this);\n        mGridView.getViewTreeObserver().addOnGlobalLayoutListener(\n                new ViewTreeObserver.OnGlobalLayoutListener() {\n                    @TargetApi(Build.VERSION_CODES.JELLY_BEAN)\n                    @Override\n                    public void onGlobalLayout() {\n                        if (mAdapter.getNumColumns() == 0) {\n                            final int numColumns = (int) Math.floor(\n                                    mGridView.getWidth() / (mImageThumbSize + mImageThumbSpacing));\n                            if (numColumns > 0) {\n                                final int columnWidth =\n                                        (mGridView.getWidth() / numColumns) - mImageThumbSpacing;\n                                mAdapter.setNumColumns(numColumns);\n                                mAdapter.setItemHeight(columnWidth);\n\n                                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {\n                                    mGridView.getViewTreeObserver()\n                                            .removeOnGlobalLayoutListener(this);\n                                } else {\n                                    mGridView.getViewTreeObserver()\n                                            .removeGlobalOnLayoutListener(this);\n                                }\n                            }\n                        }\n                    }\n                });\n\n        return v;\n    }\n\n    @Override\n    public void onResume() {\n        super.onResume();\n        mAdapter.notifyDataSetChanged();\n    }\n\n    @Override\n    public void onPause() {\n        super.onPause();\n    }\n\n    @Override\n    public void onDestroy() {\n        super.onDestroy();\n    }\n\n    @TargetApi(Build.VERSION_CODES.JELLY_BEAN)\n    @Override\n    public void onItemClick(AdapterView<?> parent, View v, int position, long id) {\n\n    }\n\n\n    private class ImageAdapter extends BaseAdapter {\n\n        private final Context mContext;\n        private int mItemHeight = 0;\n        private int mNumColumns = 0;\n        private int mActionBarHeight = 0;\n        private GridView.LayoutParams mImageViewLayoutParams;\n\n        public ImageAdapter(Context context) {\n            super();\n            mContext = context;\n            mImageViewLayoutParams = new GridView.LayoutParams(\n                    ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);\n            TypedValue tv = new TypedValue();\n            if (context.getTheme().resolveAttribute(\n                    android.R.attr.actionBarSize, tv, true)) {\n                mActionBarHeight = TypedValue.complexToDimensionPixelSize(\n                        tv.data, context.getResources().getDisplayMetrics());\n            }\n        }\n\n        @Override\n        public int getCount() {\n            if (getNumColumns() == 0) {\n                return 0;\n            }\n\n            return Images.imageThumbUrls.length + mNumColumns;\n        }\n\n        @Override\n        public Object getItem(int position) {\n            return position < mNumColumns ?\n                    null : Images.imageThumbUrls[position - mNumColumns];\n        }\n\n        @Override\n        public long getItemId(int position) {\n            return position < mNumColumns ? 0 : position - mNumColumns;\n        }\n\n        @Override\n        public int getViewTypeCount() {\n            return 2;\n        }\n\n        @Override\n        public int getItemViewType(int position) {\n            return (position < mNumColumns) ? 1 : 0;\n        }\n\n        @Override\n        public boolean hasStableIds() {\n            return true;\n        }\n\n        @Override\n        public View getView(int position, View convertView, ViewGroup container) {\n            if (position < mNumColumns) {\n                if (convertView == null) {\n                    convertView = new View(mContext);\n                }\n                convertView.setLayoutParams(new AbsListView.LayoutParams(\n                        ViewGroup.LayoutParams.MATCH_PARENT, mActionBarHeight));\n                return convertView;\n            }\n\n            ANImageView imageView;\n            if (convertView == null) {\n                imageView = new ANImageView(mContext);\n                imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);\n                imageView.setLayoutParams(mImageViewLayoutParams);\n            } else {\n                imageView = (ANImageView) convertView;\n            }\n\n            if (imageView.getLayoutParams().height != mItemHeight) {\n                imageView.setLayoutParams(mImageViewLayoutParams);\n            }\n            imageView.setDefaultImageResId(R.drawable.ic_toys_black_24dp);\n            imageView.setErrorImageResId(R.drawable.ic_error_outline_black_24dp);\n            imageView.setImageUrl(Images.imageThumbUrls[position - mNumColumns]);\n\n            return imageView;\n        }\n\n        public void setItemHeight(int height) {\n            if (height == mItemHeight) {\n                return;\n            }\n            mItemHeight = height;\n            mImageViewLayoutParams =\n                    new GridView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, mItemHeight);\n            notifyDataSetChanged();\n        }\n\n        public void setNumColumns(int numColumns) {\n            mNumColumns = numColumns;\n        }\n\n        public int getNumColumns() {\n            return mNumColumns;\n        }\n    }\n}\n"
  },
  {
    "path": "app/src/main/java/com/networking/model/User.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.networking.model;\n\n/**\n * Created by amitshekhar on 31/07/16.\n */\npublic class User {\n\n    public long id;\n    public String firstname;\n    public String lastname;\n    public boolean isFollowing;\n\n}\n"
  },
  {
    "path": "app/src/main/java/com/networking/provider/Images.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.networking.provider;\n\n/**\n * Created by amitshekhar on 23/03/16.\n */\n\n/**\n * Some simple test data to use for this sample app.\n */\npublic class Images {\n\n    /**\n     * This are PicasaWeb URLs and could potentially change. Ideally the PicasaWeb API should be\n     * used to fetch the URLs.\n     * <p>\n     * Credit to Romain Guy for the photos:\n     * http://www.curious-creature.org/\n     * https://plus.google.com/109538161516040592207/about\n     * http://www.flickr.com/photos/romainguy\n     */\n    public final static String[] imageUrls = new String[]{\n            \"https://lh6.googleusercontent.com/-55osAWw3x0Q/URquUtcFr5I/AAAAAAAAAbs/rWlj1RUKrYI/s1024/A%252520Photographer.jpg\",\n            \"https://lh4.googleusercontent.com/--dq8niRp7W4/URquVgmXvgI/AAAAAAAAAbs/-gnuLQfNnBA/s1024/A%252520Song%252520of%252520Ice%252520and%252520Fire.jpg\",\n            \"https://lh5.googleusercontent.com/-7qZeDtRKFKc/URquWZT1gOI/AAAAAAAAAbs/hqWgteyNXsg/s1024/Another%252520Rockaway%252520Sunset.jpg\",\n            \"https://lh3.googleusercontent.com/--L0Km39l5J8/URquXHGcdNI/AAAAAAAAAbs/3ZrSJNrSomQ/s1024/Antelope%252520Butte.jpg\",\n            \"https://lh6.googleusercontent.com/-8HO-4vIFnlw/URquZnsFgtI/AAAAAAAAAbs/WT8jViTF7vw/s1024/Antelope%252520Hallway.jpg\",\n            \"https://lh4.googleusercontent.com/-WIuWgVcU3Qw/URqubRVcj4I/AAAAAAAAAbs/YvbwgGjwdIQ/s1024/Antelope%252520Walls.jpg\",\n            \"https://lh6.googleusercontent.com/-UBmLbPELvoQ/URqucCdv0kI/AAAAAAAAAbs/IdNhr2VQoQs/s1024/Apre%2525CC%252580s%252520la%252520Pluie.jpg\",\n            \"https://lh3.googleusercontent.com/-s-AFpvgSeew/URquc6dF-JI/AAAAAAAAAbs/Mt3xNGRUd68/s1024/Backlit%252520Cloud.jpg\",\n            \"https://lh5.googleusercontent.com/-bvmif9a9YOQ/URquea3heHI/AAAAAAAAAbs/rcr6wyeQtAo/s1024/Bee%252520and%252520Flower.jpg\",\n            \"https://lh5.googleusercontent.com/-n7mdm7I7FGs/URqueT_BT-I/AAAAAAAAAbs/9MYmXlmpSAo/s1024/Bonzai%252520Rock%252520Sunset.jpg\",\n            \"https://lh6.googleusercontent.com/-4CN4X4t0M1k/URqufPozWzI/AAAAAAAAAbs/8wK41lg1KPs/s1024/Caterpillar.jpg\",\n            \"https://lh3.googleusercontent.com/-rrFnVC8xQEg/URqufdrLBaI/AAAAAAAAAbs/s69WYy_fl1E/s1024/Chess.jpg\",\n            \"https://lh5.googleusercontent.com/-WVpRptWH8Yw/URqugh-QmDI/AAAAAAAAAbs/E-MgBgtlUWU/s1024/Chihuly.jpg\",\n            \"https://lh5.googleusercontent.com/-0BDXkYmckbo/URquhKFW84I/AAAAAAAAAbs/ogQtHCTk2JQ/s1024/Closed%252520Door.jpg\",\n            \"https://lh3.googleusercontent.com/-PyggXXZRykM/URquh-kVvoI/AAAAAAAAAbs/hFtDwhtrHHQ/s1024/Colorado%252520River%252520Sunset.jpg\",\n            \"https://lh3.googleusercontent.com/-ZAs4dNZtALc/URquikvOCWI/AAAAAAAAAbs/DXz4h3dll1Y/s1024/Colors%252520of%252520Autumn.jpg\",\n            \"https://lh4.googleusercontent.com/-GztnWEIiMz8/URqukVCU7bI/AAAAAAAAAbs/jo2Hjv6MZ6M/s1024/Countryside.jpg\",\n            \"https://lh4.googleusercontent.com/-bEg9EZ9QoiM/URquklz3FGI/AAAAAAAAAbs/UUuv8Ac2BaE/s1024/Death%252520Valley%252520-%252520Dunes.jpg\",\n            \"https://lh6.googleusercontent.com/-ijQJ8W68tEE/URqulGkvFEI/AAAAAAAAAbs/zPXvIwi_rFw/s1024/Delicate%252520Arch.jpg\",\n            \"https://lh5.googleusercontent.com/-Oh8mMy2ieng/URqullDwehI/AAAAAAAAAbs/TbdeEfsaIZY/s1024/Despair.jpg\",\n            \"https://lh5.googleusercontent.com/-gl0y4UiAOlk/URqumC_KjBI/AAAAAAAAAbs/PM1eT7dn4oo/s1024/Eagle%252520Fall%252520Sunrise.jpg\",\n            \"https://lh3.googleusercontent.com/-hYYHd2_vXPQ/URqumtJa9eI/AAAAAAAAAbs/wAalXVkbSh0/s1024/Electric%252520Storm.jpg\",\n            \"https://lh5.googleusercontent.com/-PyY_yiyjPTo/URqunUOhHFI/AAAAAAAAAbs/azZoULNuJXc/s1024/False%252520Kiva.jpg\",\n            \"https://lh6.googleusercontent.com/-PYvLVdvXywk/URqunwd8hfI/AAAAAAAAAbs/qiMwgkFvf6I/s1024/Fitzgerald%252520Streaks.jpg\",\n            \"https://lh4.googleusercontent.com/-KIR_UobIIqY/URquoCZ9SlI/AAAAAAAAAbs/Y4d4q8sXu4c/s1024/Foggy%252520Sunset.jpg\",\n            \"https://lh6.googleusercontent.com/-9lzOk_OWZH0/URquoo4xYoI/AAAAAAAAAbs/AwgzHtNVCwU/s1024/Frantic.jpg\",\n            \"https://lh3.googleusercontent.com/-0X3JNaKaz48/URqupH78wpI/AAAAAAAAAbs/lHXxu_zbH8s/s1024/Golden%252520Gate%252520Afternoon.jpg\",\n            \"https://lh6.googleusercontent.com/-95sb5ag7ABc/URqupl95RDI/AAAAAAAAAbs/g73R20iVTRA/s1024/Golden%252520Gate%252520Fog.jpg\",\n            \"https://lh3.googleusercontent.com/-JB9v6rtgHhk/URqup21F-zI/AAAAAAAAAbs/64Fb8qMZWXk/s1024/Golden%252520Grass.jpg\",\n            \"https://lh4.googleusercontent.com/-EIBGfnuLtII/URquqVHwaRI/AAAAAAAAAbs/FA4McV2u8VE/s1024/Grand%252520Teton.jpg\",\n            \"https://lh4.googleusercontent.com/-WoMxZvmN9nY/URquq1v2AoI/AAAAAAAAAbs/grj5uMhL6NA/s1024/Grass%252520Closeup.jpg\",\n            \"https://lh3.googleusercontent.com/-6hZiEHXx64Q/URqurxvNdqI/AAAAAAAAAbs/kWMXM3o5OVI/s1024/Green%252520Grass.jpg\",\n            \"https://lh5.googleusercontent.com/-6LVb9OXtQ60/URquteBFuKI/AAAAAAAAAbs/4F4kRgecwFs/s1024/Hanging%252520Leaf.jpg\",\n            \"https://lh4.googleusercontent.com/-zAvf__52ONk/URqutT_IuxI/AAAAAAAAAbs/D_bcuc0thoU/s1024/Highway%2525201.jpg\",\n            \"https://lh6.googleusercontent.com/-H4SrUg615rA/URquuL27fXI/AAAAAAAAAbs/4aEqJfiMsOU/s1024/Horseshoe%252520Bend%252520Sunset.jpg\",\n            \"https://lh4.googleusercontent.com/-JhFi4fb_Pqw/URquuX-QXbI/AAAAAAAAAbs/IXpYUxuweYM/s1024/Horseshoe%252520Bend.jpg\",\n            \"https://lh5.googleusercontent.com/-UGgssvFRJ7g/URquueyJzGI/AAAAAAAAAbs/yYIBlLT0toM/s1024/Into%252520the%252520Blue.jpg\",\n            \"https://lh3.googleusercontent.com/-CH7KoupI7uI/URquu0FF__I/AAAAAAAAAbs/R7GDmI7v_G0/s1024/Jelly%252520Fish%2525202.jpg\",\n            \"https://lh4.googleusercontent.com/-pwuuw6yhg8U/URquvPxR3FI/AAAAAAAAAbs/VNGk6f-tsGE/s1024/Jelly%252520Fish%2525203.jpg\",\n            \"https://lh5.googleusercontent.com/-GoUQVw1fnFw/URquv6xbC0I/AAAAAAAAAbs/zEUVTQQ43Zc/s1024/Kauai.jpg\",\n            \"https://lh6.googleusercontent.com/-8QdYYQEpYjw/URquwvdh88I/AAAAAAAAAbs/cktDy-ysfHo/s1024/Kyoto%252520Sunset.jpg\",\n            \"https://lh4.googleusercontent.com/-vPeekyDjOE0/URquwzJ28qI/AAAAAAAAAbs/qxcyXULsZrg/s1024/Lake%252520Tahoe%252520Colors.jpg\",\n            \"https://lh4.googleusercontent.com/-xBPxWpD4yxU/URquxWHk8AI/AAAAAAAAAbs/ARDPeDYPiMY/s1024/Lava%252520from%252520the%252520Sky.jpg\",\n            \"https://lh3.googleusercontent.com/-897VXrJB6RE/URquxxxd-5I/AAAAAAAAAbs/j-Cz4T4YvIw/s1024/Leica%25252050mm%252520Summilux.jpg\",\n            \"https://lh5.googleusercontent.com/-qSJ4D4iXzGo/URquyDWiJ1I/AAAAAAAAAbs/k2pBXeWehOA/s1024/Leica%25252050mm%252520Summilux.jpg\",\n            \"https://lh6.googleusercontent.com/-dwlPg83vzLg/URquylTVuFI/AAAAAAAAAbs/G6SyQ8b4YsI/s1024/Leica%252520M8%252520%252528Front%252529.jpg\",\n            \"https://lh3.googleusercontent.com/-R3_EYAyJvfk/URquzQBv8eI/AAAAAAAAAbs/b9xhpUM3pEI/s1024/Light%252520to%252520Sand.jpg\",\n            \"https://lh3.googleusercontent.com/-fHY5h67QPi0/URqu0Cp4J1I/AAAAAAAAAbs/0lG6m94Z6vM/s1024/Little%252520Bit%252520of%252520Paradise.jpg\",\n            \"https://lh5.googleusercontent.com/-TzF_LwrCnRM/URqu0RddPOI/AAAAAAAAAbs/gaj2dLiuX0s/s1024/Lone%252520Pine%252520Sunset.jpg\",\n            \"https://lh3.googleusercontent.com/-4HdpJ4_DXU4/URqu046dJ9I/AAAAAAAAAbs/eBOodtk2_uk/s1024/Lonely%252520Rock.jpg\",\n            \"https://lh6.googleusercontent.com/-erbF--z-W4s/URqu1ajSLkI/AAAAAAAAAbs/xjDCDO1INzM/s1024/Longue%252520Vue.jpg\",\n            \"https://lh6.googleusercontent.com/-0CXJRdJaqvc/URqu1opNZNI/AAAAAAAAAbs/PFB2oPUU7Lk/s1024/Look%252520Me%252520in%252520the%252520Eye.jpg\",\n            \"https://lh3.googleusercontent.com/-D_5lNxnDN6g/URqu2Tk7HVI/AAAAAAAAAbs/p0ddca9W__Y/s1024/Lost%252520in%252520a%252520Field.jpg\",\n            \"https://lh6.googleusercontent.com/-flsqwMrIk2Q/URqu24PcmjI/AAAAAAAAAbs/5ocIH85XofM/s1024/Marshall%252520Beach%252520Sunset.jpg\",\n            \"https://lh4.googleusercontent.com/-Y4lgryEVTmU/URqu28kG3gI/AAAAAAAAAbs/OjXpekqtbJ4/s1024/Mono%252520Lake%252520Blue.jpg\",\n            \"https://lh4.googleusercontent.com/-AaHAJPmcGYA/URqu3PIldHI/AAAAAAAAAbs/lcTqk1SIcRs/s1024/Monument%252520Valley%252520Overlook.jpg\",\n            \"https://lh4.googleusercontent.com/-vKxfdQ83dQA/URqu31Yq_BI/AAAAAAAAAbs/OUoGk_2AyfM/s1024/Moving%252520Rock.jpg\",\n            \"https://lh5.googleusercontent.com/-CG62QiPpWXg/URqu4ia4vRI/AAAAAAAAAbs/0YOdqLAlcAc/s1024/Napali%252520Coast.jpg\",\n            \"https://lh6.googleusercontent.com/-wdGrP5PMmJQ/URqu5PZvn7I/AAAAAAAAAbs/m0abEcdPXe4/s1024/One%252520Wheel.jpg\",\n            \"https://lh6.googleusercontent.com/-6WS5DoCGuOA/URqu5qx1UgI/AAAAAAAAAbs/giMw2ixPvrY/s1024/Open%252520Sky.jpg\",\n            \"https://lh6.googleusercontent.com/-u8EHKj8G8GQ/URqu55sM6yI/AAAAAAAAAbs/lIXX_GlTdmI/s1024/Orange%252520Sunset.jpg\",\n            \"https://lh6.googleusercontent.com/-74Z5qj4bTDE/URqu6LSrJrI/AAAAAAAAAbs/XzmVkw90szQ/s1024/Orchid.jpg\",\n            \"https://lh6.googleusercontent.com/-lEQE4h6TePE/URqu6t_lSkI/AAAAAAAAAbs/zvGYKOea_qY/s1024/Over%252520there.jpg\",\n            \"https://lh5.googleusercontent.com/-cauH-53JH2M/URqu66v_USI/AAAAAAAAAbs/EucwwqclfKQ/s1024/Plumes.jpg\",\n            \"https://lh3.googleusercontent.com/-eDLT2jHDoy4/URqu7axzkAI/AAAAAAAAAbs/iVZE-xJ7lZs/s1024/Rainbokeh.jpg\",\n            \"https://lh5.googleusercontent.com/-j1NLqEFIyco/URqu8L1CGcI/AAAAAAAAAbs/aqZkgX66zlI/s1024/Rainbow.jpg\",\n            \"https://lh5.googleusercontent.com/-DRnqmK0t4VU/URqu8XYN9yI/AAAAAAAAAbs/LgvF_592WLU/s1024/Rice%252520Fields.jpg\",\n            \"https://lh3.googleusercontent.com/-hwh1v3EOGcQ/URqu8qOaKwI/AAAAAAAAAbs/IljRJRnbJGw/s1024/Rockaway%252520Fire%252520Sky.jpg\",\n            \"https://lh5.googleusercontent.com/-wjV6FQk7tlk/URqu9jCQ8sI/AAAAAAAAAbs/RyYUpdo-c9o/s1024/Rockaway%252520Flow.jpg\",\n            \"https://lh6.googleusercontent.com/-6cAXNfo7D20/URqu-BdzgPI/AAAAAAAAAbs/OmsYllzJqwo/s1024/Rockaway%252520Sunset%252520Sky.jpg\",\n            \"https://lh3.googleusercontent.com/-sl8fpGPS-RE/URqu_BOkfgI/AAAAAAAAAbs/Dg2Fv-JxOeg/s1024/Russian%252520Ridge%252520Sunset.jpg\",\n            \"https://lh6.googleusercontent.com/-gVtY36mMBIg/URqu_q91lkI/AAAAAAAAAbs/3CiFMBcy5MA/s1024/Rust%252520Knot.jpg\",\n            \"https://lh6.googleusercontent.com/-GHeImuHqJBE/URqu_FKfVLI/AAAAAAAAAbs/axuEJeqam7Q/s1024/Sailing%252520Stones.jpg\",\n            \"https://lh3.googleusercontent.com/-hBbYZjTOwGc/URqu_ycpIrI/AAAAAAAAAbs/nAdJUXnGJYE/s1024/Seahorse.jpg\",\n            \"https://lh3.googleusercontent.com/-Iwi6-i6IexY/URqvAYZHsVI/AAAAAAAAAbs/5ETWl4qXsFE/s1024/Shinjuku%252520Street.jpg\",\n            \"https://lh6.googleusercontent.com/-amhnySTM_MY/URqvAlb5KoI/AAAAAAAAAbs/pFCFgzlKsn0/s1024/Sierra%252520Heavens.jpg\",\n            \"https://lh5.googleusercontent.com/-dJgjepFrYSo/URqvBVJZrAI/AAAAAAAAAbs/v-F5QWpYO6s/s1024/Sierra%252520Sunset.jpg\",\n            \"https://lh4.googleusercontent.com/-Z4zGiC5nWdc/URqvBdEwivI/AAAAAAAAAbs/ZRZR1VJ84QA/s1024/Sin%252520Lights.jpg\",\n            \"https://lh4.googleusercontent.com/-_0cYiWW8ccY/URqvBz3iM4I/AAAAAAAAAbs/9N_Wq8MhLTY/s1024/Starry%252520Lake.jpg\",\n            \"https://lh3.googleusercontent.com/-A9LMoRyuQUA/URqvCYx_JoI/AAAAAAAAAbs/s7sde1Bz9cI/s1024/Starry%252520Night.jpg\",\n            \"https://lh3.googleusercontent.com/-KtLJ3k858eY/URqvC_2h_bI/AAAAAAAAAbs/zzEBImwDA_g/s1024/Stream.jpg\",\n            \"https://lh5.googleusercontent.com/-dFB7Lad6RcA/URqvDUftwWI/AAAAAAAAAbs/BrhoUtXTN7o/s1024/Strip%252520Sunset.jpg\",\n            \"https://lh5.googleusercontent.com/-at6apgFiN20/URqvDyffUZI/AAAAAAAAAbs/clABCx171bE/s1024/Sunset%252520Hills.jpg\",\n            \"https://lh4.googleusercontent.com/-7-EHhtQthII/URqvEYTk4vI/AAAAAAAAAbs/QSJZoB3YjVg/s1024/Tenaya%252520Lake%2525202.jpg\",\n            \"https://lh6.googleusercontent.com/-8MrjV_a-Pok/URqvFC5repI/AAAAAAAAAbs/9inKTg9fbCE/s1024/Tenaya%252520Lake.jpg\",\n            \"https://lh5.googleusercontent.com/-B1HW-z4zwao/URqvFWYRwUI/AAAAAAAAAbs/8Peli53Bs8I/s1024/The%252520Cave%252520BW.jpg\",\n            \"https://lh3.googleusercontent.com/-PO4E-xZKAnQ/URqvGRqjYkI/AAAAAAAAAbs/42nyADFsXag/s1024/The%252520Fisherman.jpg\",\n            \"https://lh4.googleusercontent.com/-iLyZlzfdy7s/URqvG0YScdI/AAAAAAAAAbs/1J9eDKmkXtk/s1024/The%252520Night%252520is%252520Coming.jpg\",\n            \"https://lh6.googleusercontent.com/-G-k7YkkUco0/URqvHhah6fI/AAAAAAAAAbs/_taQQG7t0vo/s1024/The%252520Road.jpg\",\n            \"https://lh6.googleusercontent.com/-h-ALJt7kSus/URqvIThqYfI/AAAAAAAAAbs/ejiv35olWS8/s1024/Tokyo%252520Heights.jpg\",\n            \"https://lh5.googleusercontent.com/-Hy9k-TbS7xg/URqvIjQMOxI/AAAAAAAAAbs/RSpmmOATSkg/s1024/Tokyo%252520Highway.jpg\",\n            \"https://lh6.googleusercontent.com/-83oOvMb4OZs/URqvJL0T7lI/AAAAAAAAAbs/c5TECZ6RONM/s1024/Tokyo%252520Smog.jpg\",\n            \"https://lh3.googleusercontent.com/-FB-jfgREEfI/URqvJI3EXAI/AAAAAAAAAbs/XfyweiRF4v8/s1024/Tufa%252520at%252520Night.jpg\",\n            \"https://lh4.googleusercontent.com/-vngKD5Z1U8w/URqvJUCEgPI/AAAAAAAAAbs/ulxCMVcU6EU/s1024/Valley%252520Sunset.jpg\",\n            \"https://lh6.googleusercontent.com/-DOz5I2E2oMQ/URqvKMND1kI/AAAAAAAAAbs/Iqf0IsInleo/s1024/Windmill%252520Sunrise.jpg\",\n            \"https://lh5.googleusercontent.com/-biyiyWcJ9MU/URqvKculiAI/AAAAAAAAAbs/jyPsCplJOpE/s1024/Windmill.jpg\",\n            \"https://lh4.googleusercontent.com/-PDT167_xRdA/URqvK36mLcI/AAAAAAAAAbs/oi2ik9QseMI/s1024/Windmills.jpg\",\n            \"https://lh5.googleusercontent.com/-kI_QdYx7VlU/URqvLXCB6gI/AAAAAAAAAbs/N31vlZ6u89o/s1024/Yet%252520Another%252520Rockaway%252520Sunset.jpg\",\n            \"https://lh4.googleusercontent.com/-e9NHZ5k5MSs/URqvMIBZjtI/AAAAAAAAAbs/1fV810rDNfQ/s1024/Yosemite%252520Tree.jpg\",\n    };\n\n    /**\n     * This are PicasaWeb thumbnail URLs and could potentially change. Ideally the PicasaWeb API\n     * should be used to fetch the URLs.\n     * <p>\n     * Credit to Romain Guy for the photos:\n     * http://www.curious-creature.org/\n     * https://plus.google.com/109538161516040592207/about\n     * http://www.flickr.com/photos/romainguy\n     */\n    public final static String[] imageThumbUrls = new String[]{\n            \"https://lh6.googleusercontent.com/-55osAWw3x0Q/URquUtcFr5I/AAAAAAAAAbs/rWlj1RUKrYI/s240-c/A%252520Photographer.jpg\",\n            \"https://lh4.googleusercontent.com/--dq8niRp7W4/URquVgmXvgI/AAAAAAAAAbs/-gnuLQfNnBA/s240-c/A%252520Song%252520of%252520Ice%252520and%252520Fire.jpg\",\n            \"https://lh5.googleusercontent.com/-7qZeDtRKFKc/URquWZT1gOI/AAAAAAAAAbs/hqWgteyNXsg/s240-c/Another%252520Rockaway%252520Sunset.jpg\",\n            \"https://lh3.googleusercontent.com/--L0Km39l5J8/URquXHGcdNI/AAAAAAAAAbs/3ZrSJNrSomQ/s240-c/Antelope%252520Butte.jpg\",\n            \"https://lh6.googleusercontent.com/-8HO-4vIFnlw/URquZnsFgtI/AAAAAAAAAbs/WT8jViTF7vw/s240-c/Antelope%252520Hallway.jpg\",\n            \"https://lh4.googleusercontent.com/-WIuWgVcU3Qw/URqubRVcj4I/AAAAAAAAAbs/YvbwgGjwdIQ/s240-c/Antelope%252520Walls.jpg\",\n            \"https://lh6.googleusercontent.com/-UBmLbPELvoQ/URqucCdv0kI/AAAAAAAAAbs/IdNhr2VQoQs/s240-c/Apre%2525CC%252580s%252520la%252520Pluie.jpg\",\n            \"https://lh3.googleusercontent.com/-s-AFpvgSeew/URquc6dF-JI/AAAAAAAAAbs/Mt3xNGRUd68/s240-c/Backlit%252520Cloud.jpg\",\n            \"https://lh5.googleusercontent.com/-bvmif9a9YOQ/URquea3heHI/AAAAAAAAAbs/rcr6wyeQtAo/s240-c/Bee%252520and%252520Flower.jpg\",\n            \"https://lh5.googleusercontent.com/-n7mdm7I7FGs/URqueT_BT-I/AAAAAAAAAbs/9MYmXlmpSAo/s240-c/Bonzai%252520Rock%252520Sunset.jpg\",\n            \"https://lh6.googleusercontent.com/-4CN4X4t0M1k/URqufPozWzI/AAAAAAAAAbs/8wK41lg1KPs/s240-c/Caterpillar.jpg\",\n            \"https://lh3.googleusercontent.com/-rrFnVC8xQEg/URqufdrLBaI/AAAAAAAAAbs/s69WYy_fl1E/s240-c/Chess.jpg\",\n            \"https://lh5.googleusercontent.com/-WVpRptWH8Yw/URqugh-QmDI/AAAAAAAAAbs/E-MgBgtlUWU/s240-c/Chihuly.jpg\",\n            \"https://lh5.googleusercontent.com/-0BDXkYmckbo/URquhKFW84I/AAAAAAAAAbs/ogQtHCTk2JQ/s240-c/Closed%252520Door.jpg\",\n            \"https://lh3.googleusercontent.com/-PyggXXZRykM/URquh-kVvoI/AAAAAAAAAbs/hFtDwhtrHHQ/s240-c/Colorado%252520River%252520Sunset.jpg\",\n            \"https://lh3.googleusercontent.com/-ZAs4dNZtALc/URquikvOCWI/AAAAAAAAAbs/DXz4h3dll1Y/s240-c/Colors%252520of%252520Autumn.jpg\",\n            \"https://lh4.googleusercontent.com/-GztnWEIiMz8/URqukVCU7bI/AAAAAAAAAbs/jo2Hjv6MZ6M/s240-c/Countryside.jpg\",\n            \"https://lh4.googleusercontent.com/-bEg9EZ9QoiM/URquklz3FGI/AAAAAAAAAbs/UUuv8Ac2BaE/s240-c/Death%252520Valley%252520-%252520Dunes.jpg\",\n            \"https://lh6.googleusercontent.com/-ijQJ8W68tEE/URqulGkvFEI/AAAAAAAAAbs/zPXvIwi_rFw/s240-c/Delicate%252520Arch.jpg\",\n            \"https://lh5.googleusercontent.com/-Oh8mMy2ieng/URqullDwehI/AAAAAAAAAbs/TbdeEfsaIZY/s240-c/Despair.jpg\",\n            \"https://lh5.googleusercontent.com/-gl0y4UiAOlk/URqumC_KjBI/AAAAAAAAAbs/PM1eT7dn4oo/s240-c/Eagle%252520Fall%252520Sunrise.jpg\",\n            \"https://lh3.googleusercontent.com/-hYYHd2_vXPQ/URqumtJa9eI/AAAAAAAAAbs/wAalXVkbSh0/s240-c/Electric%252520Storm.jpg\",\n            \"https://lh5.googleusercontent.com/-PyY_yiyjPTo/URqunUOhHFI/AAAAAAAAAbs/azZoULNuJXc/s240-c/False%252520Kiva.jpg\",\n            \"https://lh6.googleusercontent.com/-PYvLVdvXywk/URqunwd8hfI/AAAAAAAAAbs/qiMwgkFvf6I/s240-c/Fitzgerald%252520Streaks.jpg\",\n            \"https://lh4.googleusercontent.com/-KIR_UobIIqY/URquoCZ9SlI/AAAAAAAAAbs/Y4d4q8sXu4c/s240-c/Foggy%252520Sunset.jpg\",\n            \"https://lh6.googleusercontent.com/-9lzOk_OWZH0/URquoo4xYoI/AAAAAAAAAbs/AwgzHtNVCwU/s240-c/Frantic.jpg\",\n            \"https://lh3.googleusercontent.com/-0X3JNaKaz48/URqupH78wpI/AAAAAAAAAbs/lHXxu_zbH8s/s240-c/Golden%252520Gate%252520Afternoon.jpg\",\n            \"https://lh6.googleusercontent.com/-95sb5ag7ABc/URqupl95RDI/AAAAAAAAAbs/g73R20iVTRA/s240-c/Golden%252520Gate%252520Fog.jpg\",\n            \"https://lh3.googleusercontent.com/-JB9v6rtgHhk/URqup21F-zI/AAAAAAAAAbs/64Fb8qMZWXk/s240-c/Golden%252520Grass.jpg\",\n            \"https://lh4.googleusercontent.com/-EIBGfnuLtII/URquqVHwaRI/AAAAAAAAAbs/FA4McV2u8VE/s240-c/Grand%252520Teton.jpg\",\n            \"https://lh4.googleusercontent.com/-WoMxZvmN9nY/URquq1v2AoI/AAAAAAAAAbs/grj5uMhL6NA/s240-c/Grass%252520Closeup.jpg\",\n            \"https://lh3.googleusercontent.com/-6hZiEHXx64Q/URqurxvNdqI/AAAAAAAAAbs/kWMXM3o5OVI/s240-c/Green%252520Grass.jpg\",\n            \"https://lh5.googleusercontent.com/-6LVb9OXtQ60/URquteBFuKI/AAAAAAAAAbs/4F4kRgecwFs/s240-c/Hanging%252520Leaf.jpg\",\n            \"https://lh4.googleusercontent.com/-zAvf__52ONk/URqutT_IuxI/AAAAAAAAAbs/D_bcuc0thoU/s240-c/Highway%2525201.jpg\",\n            \"https://lh6.googleusercontent.com/-H4SrUg615rA/URquuL27fXI/AAAAAAAAAbs/4aEqJfiMsOU/s240-c/Horseshoe%252520Bend%252520Sunset.jpg\",\n            \"https://lh4.googleusercontent.com/-JhFi4fb_Pqw/URquuX-QXbI/AAAAAAAAAbs/IXpYUxuweYM/s240-c/Horseshoe%252520Bend.jpg\",\n            \"https://lh5.googleusercontent.com/-UGgssvFRJ7g/URquueyJzGI/AAAAAAAAAbs/yYIBlLT0toM/s240-c/Into%252520the%252520Blue.jpg\",\n            \"https://lh3.googleusercontent.com/-CH7KoupI7uI/URquu0FF__I/AAAAAAAAAbs/R7GDmI7v_G0/s240-c/Jelly%252520Fish%2525202.jpg\",\n            \"https://lh4.googleusercontent.com/-pwuuw6yhg8U/URquvPxR3FI/AAAAAAAAAbs/VNGk6f-tsGE/s240-c/Jelly%252520Fish%2525203.jpg\",\n            \"https://lh5.googleusercontent.com/-GoUQVw1fnFw/URquv6xbC0I/AAAAAAAAAbs/zEUVTQQ43Zc/s240-c/Kauai.jpg\",\n            \"https://lh6.googleusercontent.com/-8QdYYQEpYjw/URquwvdh88I/AAAAAAAAAbs/cktDy-ysfHo/s240-c/Kyoto%252520Sunset.jpg\",\n            \"https://lh4.googleusercontent.com/-vPeekyDjOE0/URquwzJ28qI/AAAAAAAAAbs/qxcyXULsZrg/s240-c/Lake%252520Tahoe%252520Colors.jpg\",\n            \"https://lh4.googleusercontent.com/-xBPxWpD4yxU/URquxWHk8AI/AAAAAAAAAbs/ARDPeDYPiMY/s240-c/Lava%252520from%252520the%252520Sky.jpg\",\n            \"https://lh3.googleusercontent.com/-897VXrJB6RE/URquxxxd-5I/AAAAAAAAAbs/j-Cz4T4YvIw/s240-c/Leica%25252050mm%252520Summilux.jpg\",\n            \"https://lh5.googleusercontent.com/-qSJ4D4iXzGo/URquyDWiJ1I/AAAAAAAAAbs/k2pBXeWehOA/s240-c/Leica%25252050mm%252520Summilux.jpg\",\n            \"https://lh6.googleusercontent.com/-dwlPg83vzLg/URquylTVuFI/AAAAAAAAAbs/G6SyQ8b4YsI/s240-c/Leica%252520M8%252520%252528Front%252529.jpg\",\n            \"https://lh3.googleusercontent.com/-R3_EYAyJvfk/URquzQBv8eI/AAAAAAAAAbs/b9xhpUM3pEI/s240-c/Light%252520to%252520Sand.jpg\",\n            \"https://lh3.googleusercontent.com/-fHY5h67QPi0/URqu0Cp4J1I/AAAAAAAAAbs/0lG6m94Z6vM/s240-c/Little%252520Bit%252520of%252520Paradise.jpg\",\n            \"https://lh5.googleusercontent.com/-TzF_LwrCnRM/URqu0RddPOI/AAAAAAAAAbs/gaj2dLiuX0s/s240-c/Lone%252520Pine%252520Sunset.jpg\",\n            \"https://lh3.googleusercontent.com/-4HdpJ4_DXU4/URqu046dJ9I/AAAAAAAAAbs/eBOodtk2_uk/s240-c/Lonely%252520Rock.jpg\",\n            \"https://lh6.googleusercontent.com/-erbF--z-W4s/URqu1ajSLkI/AAAAAAAAAbs/xjDCDO1INzM/s240-c/Longue%252520Vue.jpg\",\n            \"https://lh6.googleusercontent.com/-0CXJRdJaqvc/URqu1opNZNI/AAAAAAAAAbs/PFB2oPUU7Lk/s240-c/Look%252520Me%252520in%252520the%252520Eye.jpg\",\n            \"https://lh3.googleusercontent.com/-D_5lNxnDN6g/URqu2Tk7HVI/AAAAAAAAAbs/p0ddca9W__Y/s240-c/Lost%252520in%252520a%252520Field.jpg\",\n            \"https://lh6.googleusercontent.com/-flsqwMrIk2Q/URqu24PcmjI/AAAAAAAAAbs/5ocIH85XofM/s240-c/Marshall%252520Beach%252520Sunset.jpg\",\n            \"https://lh4.googleusercontent.com/-Y4lgryEVTmU/URqu28kG3gI/AAAAAAAAAbs/OjXpekqtbJ4/s240-c/Mono%252520Lake%252520Blue.jpg\",\n            \"https://lh4.googleusercontent.com/-AaHAJPmcGYA/URqu3PIldHI/AAAAAAAAAbs/lcTqk1SIcRs/s240-c/Monument%252520Valley%252520Overlook.jpg\",\n            \"https://lh4.googleusercontent.com/-vKxfdQ83dQA/URqu31Yq_BI/AAAAAAAAAbs/OUoGk_2AyfM/s240-c/Moving%252520Rock.jpg\",\n            \"https://lh5.googleusercontent.com/-CG62QiPpWXg/URqu4ia4vRI/AAAAAAAAAbs/0YOdqLAlcAc/s240-c/Napali%252520Coast.jpg\",\n            \"https://lh6.googleusercontent.com/-wdGrP5PMmJQ/URqu5PZvn7I/AAAAAAAAAbs/m0abEcdPXe4/s240-c/One%252520Wheel.jpg\",\n            \"https://lh6.googleusercontent.com/-6WS5DoCGuOA/URqu5qx1UgI/AAAAAAAAAbs/giMw2ixPvrY/s240-c/Open%252520Sky.jpg\",\n            \"https://lh6.googleusercontent.com/-u8EHKj8G8GQ/URqu55sM6yI/AAAAAAAAAbs/lIXX_GlTdmI/s240-c/Orange%252520Sunset.jpg\",\n            \"https://lh6.googleusercontent.com/-74Z5qj4bTDE/URqu6LSrJrI/AAAAAAAAAbs/XzmVkw90szQ/s240-c/Orchid.jpg\",\n            \"https://lh6.googleusercontent.com/-lEQE4h6TePE/URqu6t_lSkI/AAAAAAAAAbs/zvGYKOea_qY/s240-c/Over%252520there.jpg\",\n            \"https://lh5.googleusercontent.com/-cauH-53JH2M/URqu66v_USI/AAAAAAAAAbs/EucwwqclfKQ/s240-c/Plumes.jpg\",\n            \"https://lh3.googleusercontent.com/-eDLT2jHDoy4/URqu7axzkAI/AAAAAAAAAbs/iVZE-xJ7lZs/s240-c/Rainbokeh.jpg\",\n            \"https://lh5.googleusercontent.com/-j1NLqEFIyco/URqu8L1CGcI/AAAAAAAAAbs/aqZkgX66zlI/s240-c/Rainbow.jpg\",\n            \"https://lh5.googleusercontent.com/-DRnqmK0t4VU/URqu8XYN9yI/AAAAAAAAAbs/LgvF_592WLU/s240-c/Rice%252520Fields.jpg\",\n            \"https://lh3.googleusercontent.com/-hwh1v3EOGcQ/URqu8qOaKwI/AAAAAAAAAbs/IljRJRnbJGw/s240-c/Rockaway%252520Fire%252520Sky.jpg\",\n            \"https://lh5.googleusercontent.com/-wjV6FQk7tlk/URqu9jCQ8sI/AAAAAAAAAbs/RyYUpdo-c9o/s240-c/Rockaway%252520Flow.jpg\",\n            \"https://lh6.googleusercontent.com/-6cAXNfo7D20/URqu-BdzgPI/AAAAAAAAAbs/OmsYllzJqwo/s240-c/Rockaway%252520Sunset%252520Sky.jpg\",\n            \"https://lh3.googleusercontent.com/-sl8fpGPS-RE/URqu_BOkfgI/AAAAAAAAAbs/Dg2Fv-JxOeg/s240-c/Russian%252520Ridge%252520Sunset.jpg\",\n            \"https://lh6.googleusercontent.com/-gVtY36mMBIg/URqu_q91lkI/AAAAAAAAAbs/3CiFMBcy5MA/s240-c/Rust%252520Knot.jpg\",\n            \"https://lh6.googleusercontent.com/-GHeImuHqJBE/URqu_FKfVLI/AAAAAAAAAbs/axuEJeqam7Q/s240-c/Sailing%252520Stones.jpg\",\n            \"https://lh3.googleusercontent.com/-hBbYZjTOwGc/URqu_ycpIrI/AAAAAAAAAbs/nAdJUXnGJYE/s240-c/Seahorse.jpg\",\n            \"https://lh3.googleusercontent.com/-Iwi6-i6IexY/URqvAYZHsVI/AAAAAAAAAbs/5ETWl4qXsFE/s240-c/Shinjuku%252520Street.jpg\",\n            \"https://lh6.googleusercontent.com/-amhnySTM_MY/URqvAlb5KoI/AAAAAAAAAbs/pFCFgzlKsn0/s240-c/Sierra%252520Heavens.jpg\",\n            \"https://lh5.googleusercontent.com/-dJgjepFrYSo/URqvBVJZrAI/AAAAAAAAAbs/v-F5QWpYO6s/s240-c/Sierra%252520Sunset.jpg\",\n            \"https://lh4.googleusercontent.com/-Z4zGiC5nWdc/URqvBdEwivI/AAAAAAAAAbs/ZRZR1VJ84QA/s240-c/Sin%252520Lights.jpg\",\n            \"https://lh4.googleusercontent.com/-_0cYiWW8ccY/URqvBz3iM4I/AAAAAAAAAbs/9N_Wq8MhLTY/s240-c/Starry%252520Lake.jpg\",\n            \"https://lh3.googleusercontent.com/-A9LMoRyuQUA/URqvCYx_JoI/AAAAAAAAAbs/s7sde1Bz9cI/s240-c/Starry%252520Night.jpg\",\n            \"https://lh3.googleusercontent.com/-KtLJ3k858eY/URqvC_2h_bI/AAAAAAAAAbs/zzEBImwDA_g/s240-c/Stream.jpg\",\n            \"https://lh5.googleusercontent.com/-dFB7Lad6RcA/URqvDUftwWI/AAAAAAAAAbs/BrhoUtXTN7o/s240-c/Strip%252520Sunset.jpg\",\n            \"https://lh5.googleusercontent.com/-at6apgFiN20/URqvDyffUZI/AAAAAAAAAbs/clABCx171bE/s240-c/Sunset%252520Hills.jpg\",\n            \"https://lh4.googleusercontent.com/-7-EHhtQthII/URqvEYTk4vI/AAAAAAAAAbs/QSJZoB3YjVg/s240-c/Tenaya%252520Lake%2525202.jpg\",\n            \"https://lh6.googleusercontent.com/-8MrjV_a-Pok/URqvFC5repI/AAAAAAAAAbs/9inKTg9fbCE/s240-c/Tenaya%252520Lake.jpg\",\n            \"https://lh5.googleusercontent.com/-B1HW-z4zwao/URqvFWYRwUI/AAAAAAAAAbs/8Peli53Bs8I/s240-c/The%252520Cave%252520BW.jpg\",\n            \"https://lh3.googleusercontent.com/-PO4E-xZKAnQ/URqvGRqjYkI/AAAAAAAAAbs/42nyADFsXag/s240-c/The%252520Fisherman.jpg\",\n            \"https://lh4.googleusercontent.com/-iLyZlzfdy7s/URqvG0YScdI/AAAAAAAAAbs/1J9eDKmkXtk/s240-c/The%252520Night%252520is%252520Coming.jpg\",\n            \"https://lh6.googleusercontent.com/-G-k7YkkUco0/URqvHhah6fI/AAAAAAAAAbs/_taQQG7t0vo/s240-c/The%252520Road.jpg\",\n            \"https://lh6.googleusercontent.com/-h-ALJt7kSus/URqvIThqYfI/AAAAAAAAAbs/ejiv35olWS8/s240-c/Tokyo%252520Heights.jpg\",\n            \"https://lh5.googleusercontent.com/-Hy9k-TbS7xg/URqvIjQMOxI/AAAAAAAAAbs/RSpmmOATSkg/s240-c/Tokyo%252520Highway.jpg\",\n            \"https://lh6.googleusercontent.com/-83oOvMb4OZs/URqvJL0T7lI/AAAAAAAAAbs/c5TECZ6RONM/s240-c/Tokyo%252520Smog.jpg\",\n            \"https://lh3.googleusercontent.com/-FB-jfgREEfI/URqvJI3EXAI/AAAAAAAAAbs/XfyweiRF4v8/s240-c/Tufa%252520at%252520Night.jpg\",\n            \"https://lh4.googleusercontent.com/-vngKD5Z1U8w/URqvJUCEgPI/AAAAAAAAAbs/ulxCMVcU6EU/s240-c/Valley%252520Sunset.jpg\",\n            \"https://lh6.googleusercontent.com/-DOz5I2E2oMQ/URqvKMND1kI/AAAAAAAAAbs/Iqf0IsInleo/s240-c/Windmill%252520Sunrise.jpg\",\n            \"https://lh5.googleusercontent.com/-biyiyWcJ9MU/URqvKculiAI/AAAAAAAAAbs/jyPsCplJOpE/s240-c/Windmill.jpg\",\n            \"https://lh4.googleusercontent.com/-PDT167_xRdA/URqvK36mLcI/AAAAAAAAAbs/oi2ik9QseMI/s240-c/Windmills.jpg\",\n            \"https://lh5.googleusercontent.com/-kI_QdYx7VlU/URqvLXCB6gI/AAAAAAAAAbs/N31vlZ6u89o/s240-c/Yet%252520Another%252520Rockaway%252520Sunset.jpg\",\n            \"https://lh4.googleusercontent.com/-e9NHZ5k5MSs/URqvMIBZjtI/AAAAAAAAAbs/1fV810rDNfQ/s240-c/Yosemite%252520Tree.jpg\",\n    };\n}\n\n"
  },
  {
    "path": "app/src/main/java/com/networking/utils/Utils.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.networking.utils;\n\nimport android.content.Context;\nimport android.os.Environment;\nimport android.support.v4.content.ContextCompat;\nimport android.util.Log;\n\nimport com.androidnetworking.error.ANError;\n\nimport java.io.File;\n\n/**\n * Created by amitshekhar on 04/04/16.\n */\npublic class Utils {\n\n    public static String getRootDirPath(Context context) {\n        if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {\n            File file = ContextCompat.getExternalFilesDirs(context.getApplicationContext(), null)[0];\n            return file.getAbsolutePath();\n        } else {\n            return context.getApplicationContext().getFilesDir().getAbsolutePath();\n        }\n    }\n\n    public static void logError(String TAG,ANError error) {\n        if (error.getErrorCode() != 0) {\n            // received ANError from server\n            // error.getErrorCode() - the ANError code from server\n            // error.getErrorBody() - the ANError body from server\n            // error.getErrorDetail() - just a ANError detail\n            Log.d(TAG, \"onError errorCode : \" + error.getErrorCode());\n            Log.d(TAG, \"onError errorBody : \" + error.getErrorBody());\n            Log.d(TAG, \"onError errorDetail : \" + error.getErrorDetail());\n        } else {\n            // error.getErrorDetail() : connectionError, parseError, requestCancelledError\n            Log.d(TAG, \"onError errorDetail : \" + error.getErrorDetail());\n        }\n    }\n\n}\n"
  },
  {
    "path": "app/src/main/res/drawable/photogrid_list_selector.xml",
    "content": "<!--\n  ~    Copyright (C) 2016 Amit Shekhar\n  ~    Copyright (C) 2011 Android Open Source Project\n  ~\n  ~    Licensed under the Apache License, Version 2.0 (the \"License\");\n  ~    you may not use this file except in compliance with the License.\n  ~    You may obtain a copy of the License at\n  ~\n  ~        http://www.apache.org/licenses/LICENSE-2.0\n  ~\n  ~    Unless required by applicable law or agreed to in writing, software\n  ~    distributed under the License is distributed on an \"AS IS\" BASIS,\n  ~    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  ~    See the License for the specific language governing permissions and\n  ~    limitations under the License.\n  -->\n\n<selector xmlns:android=\"http://schemas.android.com/apk/res/android\">\n\n    <item android:state_pressed=\"true\">\n        <shape>\n            <solid android:color=\"@color/grid_state_pressed\" />\n        </shape>\n    </item>\n\n    <item android:state_focused=\"true\">\n        <shape>\n            <solid android:color=\"@color/grid_state_focused\" />\n        </shape>\n    </item>\n\n    <item android:drawable=\"@android:color/transparent\" />\n\n</selector>\n"
  },
  {
    "path": "app/src/main/res/layout/activity_api_test.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?><!--\n  ~    Copyright (C) 2016 Amit Shekhar\n  ~    Copyright (C) 2011 Android Open Source Project\n  ~\n  ~    Licensed under the Apache License, Version 2.0 (the \"License\");\n  ~    you may not use this file except in compliance with the License.\n  ~    You may obtain a copy of the License at\n  ~\n  ~        http://www.apache.org/licenses/LICENSE-2.0\n  ~\n  ~    Unless required by applicable law or agreed to in writing, software\n  ~    distributed under the License is distributed on an \"AS IS\" BASIS,\n  ~    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  ~    See the License for the specific language governing permissions and\n  ~    limitations under the License.\n  -->\n\n<ScrollView xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\">\n\n    <LinearLayout\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"\n        android:orientation=\"vertical\"\n        android:paddingBottom=\"@dimen/activity_vertical_margin\"\n        android:paddingLeft=\"@dimen/activity_horizontal_margin\"\n        android:paddingRight=\"@dimen/activity_horizontal_margin\"\n        android:paddingTop=\"@dimen/activity_vertical_margin\">\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <Button\n            android:id=\"@+id/prefetch\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"prefetch\"\n            android:text=\"prefetch\" />\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <Button\n            android:id=\"@+id/prefetchDownload\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"prefetchDownload\"\n            android:text=\"prefetchDownload\" />\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <Button\n            android:id=\"@+id/getAllUsers\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"getAllUsers\"\n            android:text=\"/getAllUsers/{pageNumber}\" />\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <Button\n            android:id=\"@+id/getAnUser\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"getAnUser\"\n            android:text=\"/getAnUser/{userId}\" />\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <Button\n            android:id=\"@+id/checkForHeaderGet\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"checkForHeaderGet\"\n            android:text=\"GET : checkForHeader\" />\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <Button\n            android:id=\"@+id/checkForHeaderPost\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"checkForHeaderPost\"\n            android:text=\"POST : checkForHeader\" />\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <Button\n            android:id=\"@+id/createAnUser\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"createAnUser\"\n            android:text=\"/createAnUser\" />\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <Button\n            android:id=\"@+id/createAnUserJSONObject\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"createAnUserJSONObject\"\n            android:text=\"/createAnUserJSONObject\" />\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <Button\n            android:id=\"@+id/downloadFile\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"downloadFile\"\n            android:text=\"downloadFile\" />\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <Button\n            android:id=\"@+id/downloadImage\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"downloadImage\"\n            android:text=\"downloadImage\" />\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <Button\n            android:id=\"@+id/uploadImage\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"uploadImage\"\n            android:text=\"uploadImage\" />\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <Button\n            android:id=\"@+id/doNotCacheResponse\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"doNotCacheResponse\"\n            android:text=\"doNotCacheResponse\" />\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <Button\n            android:id=\"@+id/getResponseOnlyIfCached\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"getResponseOnlyIfCached\"\n            android:text=\"getResponseOnlyIfCached\" />\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <Button\n            android:id=\"@+id/getResponseOnlyFromNetwork\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"getResponseOnlyFromNetwork\"\n            android:text=\"getResponseOnlyFromNetwork\" />\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <Button\n            android:id=\"@+id/setMaxAgeCacheControl\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"setMaxAgeCacheControl\"\n            android:text=\"setMaxAgeCacheControl\" />\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <Button\n            android:id=\"@+id/setMaxStaleCacheControl\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"setMaxStaleCacheControl\"\n            android:text=\"setMaxStaleCacheControl\" />\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <Button\n            android:id=\"@+id/cleanupDestinationTest\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"cleanupDestinationTest\"\n            android:text=\"cleanupDestinationTest\" />\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <Button\n            android:id=\"@+id/disableGzipForCustomRequest\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"disableGzipForCustomRequest\"\n            android:text=\"disableGzipForCustomRequest\" />\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <Button\n            android:id=\"@+id/checkCacheForCustomClient\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"checkCacheForCustomClient\"\n            android:text=\"checkCacheForCustomClient\" />\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <Button\n            android:id=\"@+id/checkOkHttpResponse\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"checkOkHttpResponse\"\n            android:text=\"checkOkHttpResponse\" />\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <Button\n            android:id=\"@+id/checkSynchronousCall\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"checkSynchronousCall\"\n            android:text=\"checkSynchronousCall\" />\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <Button\n            android:id=\"@+id/checkOptionsRequest\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"checkOptionsRequest\"\n            android:text=\"checkOptionsRequest\" />\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <Button\n            android:id=\"@+id/getCurrentConnectionQuality\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"getCurrentConnectionQuality\"\n            android:text=\"getCurrentConnectionQuality\" />\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n    </LinearLayout>\n\n</ScrollView>\n"
  },
  {
    "path": "app/src/main/res/layout/activity_main.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?><!--\n  ~    Copyright (C) 2016 Amit Shekhar\n  ~    Copyright (C) 2011 Android Open Source Project\n  ~\n  ~    Licensed under the Apache License, Version 2.0 (the \"License\");\n  ~    you may not use this file except in compliance with the License.\n  ~    You may obtain a copy of the License at\n  ~\n  ~        http://www.apache.org/licenses/LICENSE-2.0\n  ~\n  ~    Unless required by applicable law or agreed to in writing, software\n  ~    distributed under the License is distributed on an \"AS IS\" BASIS,\n  ~    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  ~    See the License for the specific language governing permissions and\n  ~    limitations under the License.\n  -->\n\n<ScrollView xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\">\n\n    <LinearLayout\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"\n        android:orientation=\"vertical\"\n        android:paddingBottom=\"@dimen/activity_vertical_margin\"\n        android:paddingLeft=\"@dimen/activity_horizontal_margin\"\n        android:paddingRight=\"@dimen/activity_horizontal_margin\"\n        android:paddingTop=\"@dimen/activity_vertical_margin\">\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <Button\n            android:id=\"@+id/makeRequestButton\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"makeRequests\"\n            android:text=\"Make Some Requests\" />\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <Button\n            android:id=\"@+id/cancelButton\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"cancelAllRequests\"\n            android:text=\"Cancel All Request\" />\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <Button\n            android:id=\"@+id/loadImageButton\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"loadImageDirect\"\n            android:text=\"Load Image Direct\" />\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <Button\n            android:id=\"@+id/loadImageFromImageLoaderButton\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"loadImageFromImageLoader\"\n            android:text=\"Load Image From ImageLoader\" />\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <LinearLayout\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"100dp\"\n            android:gravity=\"center\"\n            android:orientation=\"horizontal\">\n\n            <ImageView\n                android:id=\"@+id/imageView\"\n                android:layout_width=\"100dp\"\n                android:layout_height=\"100dp\"\n                android:layout_gravity=\"center\"\n                android:layout_marginRight=\"8dp\" />\n\n            <com.androidnetworking.widget.ANImageView\n                android:id=\"@+id/greatImageView\"\n                android:layout_width=\"100dp\"\n                android:layout_height=\"100dp\"\n                android:layout_gravity=\"center\" />\n\n        </LinearLayout>\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <Button\n            android:id=\"@+id/startGridActivityButton\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"startGridActivity\"\n            android:text=\"StartGridActivity\" />\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <Button\n            android:id=\"@+id/startApiTestActivityButton\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"startApiTestActivity\"\n            android:text=\"StartApiTestActivity\" />\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <Button\n            android:id=\"@+id/startOkHttpResponseTestActivityButton\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"startOkHttpResponseTestActivity\"\n            android:text=\"StartOkHttpResponseTestActivity\" />\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <Button\n            android:id=\"@+id/startWebSocketActivityButton\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"startWebSocketActivity\"\n            android:text=\"StartWebSocketActivity\" />\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n\n    </LinearLayout>\n\n</ScrollView>\n"
  },
  {
    "path": "app/src/main/res/layout/activity_web_socket.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?><!--\n  ~ /*\n  ~  *    Copyright (C) 2016 Amit Shekhar\n  ~  *    Copyright (C) 2011 Android Open Source Project\n  ~  *\n  ~  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n  ~  *    you may not use this file except in compliance with the License.\n  ~  *    You may obtain a copy of the License at\n  ~  *\n  ~  *        http://www.apache.org/licenses/LICENSE-2.0\n  ~  *\n  ~  *    Unless required by applicable law or agreed to in writing, software\n  ~  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n  ~  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  ~  *    See the License for the specific language governing permissions and\n  ~  *    limitations under the License.\n  ~  */\n  -->\n\n<ScrollView xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\">\n\n    <TextView\n        android:id=\"@+id/textView\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"\n        android:textColor=\"@android:color/black\" />\n\n</ScrollView>\n\n"
  },
  {
    "path": "app/src/main/res/layout/image_grid_fragment.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n  ~    Copyright (C) 2016 Amit Shekhar\n  ~    Copyright (C) 2011 Android Open Source Project\n  ~\n  ~    Licensed under the Apache License, Version 2.0 (the \"License\");\n  ~    you may not use this file except in compliance with the License.\n  ~    You may obtain a copy of the License at\n  ~\n  ~        http://www.apache.org/licenses/LICENSE-2.0\n  ~\n  ~    Unless required by applicable law or agreed to in writing, software\n  ~    distributed under the License is distributed on an \"AS IS\" BASIS,\n  ~    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  ~    See the License for the specific language governing permissions and\n  ~    limitations under the License.\n  -->\n\n<GridView xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:id=\"@+id/gridView\"\n    style=\"@style/PhotoGridLayout\"\n    android:layout_width=\"fill_parent\"\n    android:layout_height=\"fill_parent\"\n    android:columnWidth=\"@dimen/image_thumbnail_size\"\n    android:horizontalSpacing=\"@dimen/image_thumbnail_spacing\"\n    android:numColumns=\"auto_fit\"\n    android:stretchMode=\"columnWidth\"\n    android:verticalSpacing=\"@dimen/image_thumbnail_spacing\" >\n\n</GridView>"
  },
  {
    "path": "app/src/main/res/values/colors.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n  ~    Copyright (C) 2016 Amit Shekhar\n  ~    Copyright (C) 2011 Android Open Source Project\n  ~\n  ~    Licensed under the Apache License, Version 2.0 (the \"License\");\n  ~    you may not use this file except in compliance with the License.\n  ~    You may obtain a copy of the License at\n  ~\n  ~        http://www.apache.org/licenses/LICENSE-2.0\n  ~\n  ~    Unless required by applicable law or agreed to in writing, software\n  ~    distributed under the License is distributed on an \"AS IS\" BASIS,\n  ~    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  ~    See the License for the specific language governing permissions and\n  ~    limitations under the License.\n  -->\n\n<resources>\n    <color name=\"colorPrimary\">#3F51B5</color>\n    <color name=\"colorPrimaryDark\">#303F9F</color>\n    <color name=\"colorAccent\">#FF4081</color>\n    <color name=\"grid_state_pressed\">#1Affffff</color>\n    <color name=\"grid_state_focused\">#80000000</color>\n</resources>\n"
  },
  {
    "path": "app/src/main/res/values/dimens.xml",
    "content": "<!--\n  ~    Copyright (C) 2016 Amit Shekhar\n  ~    Copyright (C) 2011 Android Open Source Project\n  ~\n  ~    Licensed under the Apache License, Version 2.0 (the \"License\");\n  ~    you may not use this file except in compliance with the License.\n  ~    You may obtain a copy of the License at\n  ~\n  ~        http://www.apache.org/licenses/LICENSE-2.0\n  ~\n  ~    Unless required by applicable law or agreed to in writing, software\n  ~    distributed under the License is distributed on an \"AS IS\" BASIS,\n  ~    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  ~    See the License for the specific language governing permissions and\n  ~    limitations under the License.\n  -->\n\n<resources>\n    <!-- Default screen margins, per the Android Design guidelines. -->\n    <dimen name=\"activity_horizontal_margin\">16dp</dimen>\n    <dimen name=\"activity_vertical_margin\">16dp</dimen>\n\n    <dimen name=\"image_thumbnail_size\">100dp</dimen>\n    <dimen name=\"image_thumbnail_spacing\">1dp</dimen>\n</resources>\n"
  },
  {
    "path": "app/src/main/res/values/strings.xml",
    "content": "<!--\n  ~    Copyright (C) 2016 Amit Shekhar\n  ~    Copyright (C) 2011 Android Open Source Project\n  ~\n  ~    Licensed under the Apache License, Version 2.0 (the \"License\");\n  ~    you may not use this file except in compliance with the License.\n  ~    You may obtain a copy of the License at\n  ~\n  ~        http://www.apache.org/licenses/LICENSE-2.0\n  ~\n  ~    Unless required by applicable law or agreed to in writing, software\n  ~    distributed under the License is distributed on an \"AS IS\" BASIS,\n  ~    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  ~    See the License for the specific language governing permissions and\n  ~    limitations under the License.\n  -->\n\n<resources>\n    <string name=\"app_name\">AndroidNetworking</string>\n</resources>\n"
  },
  {
    "path": "app/src/main/res/values/styles.xml",
    "content": "<!--\n  ~    Copyright (C) 2016 Amit Shekhar\n  ~    Copyright (C) 2011 Android Open Source Project\n  ~\n  ~    Licensed under the Apache License, Version 2.0 (the \"License\");\n  ~    you may not use this file except in compliance with the License.\n  ~    You may obtain a copy of the License at\n  ~\n  ~        http://www.apache.org/licenses/LICENSE-2.0\n  ~\n  ~    Unless required by applicable law or agreed to in writing, software\n  ~    distributed under the License is distributed on an \"AS IS\" BASIS,\n  ~    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  ~    See the License for the specific language governing permissions and\n  ~    limitations under the License.\n  -->\n\n<resources>\n\n    <!-- Base application theme. -->\n    <style name=\"AppTheme\" parent=\"Theme.AppCompat.Light.DarkActionBar\">\n        <!-- Customize your theme here. -->\n        <item name=\"colorPrimary\">@color/colorPrimary</item>\n        <item name=\"colorPrimaryDark\">@color/colorPrimaryDark</item>\n        <item name=\"colorAccent\">@color/colorAccent</item>\n    </style>\n\n    <style name=\"PhotoGridLayout\">\n        <item name=\"android:drawSelectorOnTop\">true</item>\n        <item name=\"android:listSelector\">@drawable/photogrid_list_selector</item>\n    </style>\n\n</resources>\n"
  },
  {
    "path": "app/src/main/res/values-w820dp/dimens.xml",
    "content": "<!--\n  ~    Copyright (C) 2016 Amit Shekhar\n  ~    Copyright (C) 2011 Android Open Source Project\n  ~\n  ~    Licensed under the Apache License, Version 2.0 (the \"License\");\n  ~    you may not use this file except in compliance with the License.\n  ~    You may obtain a copy of the License at\n  ~\n  ~        http://www.apache.org/licenses/LICENSE-2.0\n  ~\n  ~    Unless required by applicable law or agreed to in writing, software\n  ~    distributed under the License is distributed on an \"AS IS\" BASIS,\n  ~    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  ~    See the License for the specific language governing permissions and\n  ~    limitations under the License.\n  -->\n\n<resources>\n    <!-- Example customization of dimensions originally defined in res/values/dimens.xml\n         (such as screen margins) for screens with more than 820dp of available width. This\n         would include 7\" and 10\" devices in landscape (~960dp and ~1280dp respectively). -->\n    <dimen name=\"activity_horizontal_margin\">64dp</dimen>\n</resources>\n"
  },
  {
    "path": "app/src/test/java/com/androidnetworking/ExampleUnitTest.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.androidnetworking;\n\nimport org.junit.Test;\n\nimport static org.junit.Assert.*;\n\n/**\n * To work on unit tests, switch the Test Artifact in the Build Variants view.\n */\npublic class ExampleUnitTest {\n    @Test\n    public void addition_isCorrect() throws Exception {\n        assertEquals(4, 2 + 2);\n    }\n}"
  },
  {
    "path": "build.gradle",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\n// Top-level build file where you can add configuration options common to all sub-projects/modules.\n\nbuildscript {\n    repositories {\n        jcenter()\n        google()\n    }\n    dependencies {\n        classpath 'com.android.tools.build:gradle:7.0.4'\n        // NOTE: Do not place your application dependencies here; they belong\n        // in the individual module build.gradle files\n    }\n}\n\nallprojects {\n    repositories {\n        jcenter()\n        google()\n    }\n}\n\ntask clean(type: Delete) {\n    delete rootProject.buildDir\n}\n\next {\n    // App tools version\n    compileSdkVersion = 27\n    minSdkVersion = 14\n    targetSdkVersion = 27\n    buildToolsVersion = \"27.0.3\"\n\n    // App dependencies versions\n    okHttp3Version = \"3.10.0\"\n    gsonVersion = \"2.8.2\"\n    jacksonVersion = \"2.8.2\"\n    rxJavaVersion = \"1.3.8\"\n    rxJavaAndroidVersion = \"1.2.1\"\n    rxJava2Version = \"2.1.12\"\n    rxJava2AndroidVersion = \"2.0.2\"\n    jUnitVersion = \"4.12\"\n    mockWebServerVersion = \"3.10.0\"\n    supportAppCompatVersion = \"27.1.1\"\n}"
  },
  {
    "path": "gradle/wrapper/gradle-wrapper.properties",
    "content": "distributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\ndistributionUrl=https\\://services.gradle.org/distributions/gradle-7.2-bin.zip\nzipStoreBase=GRADLE_USER_HOME\nzipStorePath=wrapper/dists\n"
  },
  {
    "path": "gradle.properties",
    "content": "#\n#    Copyright (C) 2016 Amit Shekhar\n#    Copyright (C) 2011 Android Open Source Project\n#\n#    Licensed under the Apache License, Version 2.0 (the \"License\");\n#    you may not use this file except in compliance with the License.\n#    You may obtain a copy of the License at\n#\n#        http://www.apache.org/licenses/LICENSE-2.0\n#\n#    Unless required by applicable law or agreed to in writing, software\n#    distributed under the License is distributed on an \"AS IS\" BASIS,\n#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n#    See the License for the specific language governing permissions and\n#    limitations under the License.\n#\n\n# Project-wide Gradle settings.\n\n# IDE (e.g. Android Studio) users:\n# Gradle settings configured through the IDE *will override*\n# any settings specified in this file.\n\n# For more details on how to configure your build environment visit\n# http://www.gradle.org/docs/current/userguide/build_environment.html\n\n# Specifies the JVM arguments used for the daemon process.\n# The setting is particularly useful for tweaking memory settings.\n# Default value: -Xmx10248m -XX:MaxPermSize=256m\n# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8\n\n# When configured, Gradle will run in incubating parallel mode.\n# This option should only be used with decoupled projects. More details, visit\n# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects\n# org.gradle.parallel=true"
  },
  {
    "path": "gradlew",
    "content": "#!/usr/bin/env bash\n\n##############################################################################\n##\n##  Gradle start up script for UN*X\n##\n##############################################################################\n\n# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\nDEFAULT_JVM_OPTS=\"\"\n\nAPP_NAME=\"Gradle\"\nAPP_BASE_NAME=`basename \"$0\"`\n\n# Use the maximum available, or set MAX_FD != -1 to use that value.\nMAX_FD=\"maximum\"\n\nwarn ( ) {\n    echo \"$*\"\n}\n\ndie ( ) {\n    echo\n    echo \"$*\"\n    echo\n    exit 1\n}\n\n# OS specific support (must be 'true' or 'false').\ncygwin=false\nmsys=false\ndarwin=false\ncase \"`uname`\" in\n  CYGWIN* )\n    cygwin=true\n    ;;\n  Darwin* )\n    darwin=true\n    ;;\n  MINGW* )\n    msys=true\n    ;;\nesac\n\n# Attempt to set APP_HOME\n# Resolve links: $0 may be a link\nPRG=\"$0\"\n# Need this for relative symlinks.\nwhile [ -h \"$PRG\" ] ; do\n    ls=`ls -ld \"$PRG\"`\n    link=`expr \"$ls\" : '.*-> \\(.*\\)$'`\n    if expr \"$link\" : '/.*' > /dev/null; then\n        PRG=\"$link\"\n    else\n        PRG=`dirname \"$PRG\"`\"/$link\"\n    fi\ndone\nSAVED=\"`pwd`\"\ncd \"`dirname \\\"$PRG\\\"`/\" >/dev/null\nAPP_HOME=\"`pwd -P`\"\ncd \"$SAVED\" >/dev/null\n\nCLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar\n\n# Determine the Java command to use to start the JVM.\nif [ -n \"$JAVA_HOME\" ] ; then\n    if [ -x \"$JAVA_HOME/jre/sh/java\" ] ; then\n        # IBM's JDK on AIX uses strange locations for the executables\n        JAVACMD=\"$JAVA_HOME/jre/sh/java\"\n    else\n        JAVACMD=\"$JAVA_HOME/bin/java\"\n    fi\n    if [ ! -x \"$JAVACMD\" ] ; then\n        die \"ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME\n\nPlease set the JAVA_HOME variable in your environment to match the\nlocation of your Java installation.\"\n    fi\nelse\n    JAVACMD=\"java\"\n    which java >/dev/null 2>&1 || die \"ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.\n\nPlease set the JAVA_HOME variable in your environment to match the\nlocation of your Java installation.\"\nfi\n\n# Increase the maximum file descriptors if we can.\nif [ \"$cygwin\" = \"false\" -a \"$darwin\" = \"false\" ] ; then\n    MAX_FD_LIMIT=`ulimit -H -n`\n    if [ $? -eq 0 ] ; then\n        if [ \"$MAX_FD\" = \"maximum\" -o \"$MAX_FD\" = \"max\" ] ; then\n            MAX_FD=\"$MAX_FD_LIMIT\"\n        fi\n        ulimit -n $MAX_FD\n        if [ $? -ne 0 ] ; then\n            warn \"Could not set maximum file descriptor limit: $MAX_FD\"\n        fi\n    else\n        warn \"Could not query maximum file descriptor limit: $MAX_FD_LIMIT\"\n    fi\nfi\n\n# For Darwin, add options to specify how the application appears in the dock\nif $darwin; then\n    GRADLE_OPTS=\"$GRADLE_OPTS \\\"-Xdock:name=$APP_NAME\\\" \\\"-Xdock:icon=$APP_HOME/media/gradle.icns\\\"\"\nfi\n\n# For Cygwin, switch paths to Windows format before running java\nif $cygwin ; then\n    APP_HOME=`cygpath --path --mixed \"$APP_HOME\"`\n    CLASSPATH=`cygpath --path --mixed \"$CLASSPATH\"`\n    JAVACMD=`cygpath --unix \"$JAVACMD\"`\n\n    # We build the pattern for arguments to be converted via cygpath\n    ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`\n    SEP=\"\"\n    for dir in $ROOTDIRSRAW ; do\n        ROOTDIRS=\"$ROOTDIRS$SEP$dir\"\n        SEP=\"|\"\n    done\n    OURCYGPATTERN=\"(^($ROOTDIRS))\"\n    # Add a user-defined pattern to the cygpath arguments\n    if [ \"$GRADLE_CYGPATTERN\" != \"\" ] ; then\n        OURCYGPATTERN=\"$OURCYGPATTERN|($GRADLE_CYGPATTERN)\"\n    fi\n    # Now convert the arguments - kludge to limit ourselves to /bin/sh\n    i=0\n    for arg in \"$@\" ; do\n        CHECK=`echo \"$arg\"|egrep -c \"$OURCYGPATTERN\" -`\n        CHECK2=`echo \"$arg\"|egrep -c \"^-\"`                                 ### Determine if an option\n\n        if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then                    ### Added a condition\n            eval `echo args$i`=`cygpath --path --ignore --mixed \"$arg\"`\n        else\n            eval `echo args$i`=\"\\\"$arg\\\"\"\n        fi\n        i=$((i+1))\n    done\n    case $i in\n        (0) set -- ;;\n        (1) set -- \"$args0\" ;;\n        (2) set -- \"$args0\" \"$args1\" ;;\n        (3) set -- \"$args0\" \"$args1\" \"$args2\" ;;\n        (4) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" ;;\n        (5) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" ;;\n        (6) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" ;;\n        (7) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" ;;\n        (8) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" \"$args7\" ;;\n        (9) set -- \"$args0\" \"$args1\" \"$args2\" \"$args3\" \"$args4\" \"$args5\" \"$args6\" \"$args7\" \"$args8\" ;;\n    esac\nfi\n\n# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules\nfunction splitJvmOpts() {\n    JVM_OPTS=(\"$@\")\n}\neval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS\nJVM_OPTS[${#JVM_OPTS[*]}]=\"-Dorg.gradle.appname=$APP_BASE_NAME\"\n\nexec \"$JAVACMD\" \"${JVM_OPTS[@]}\" -classpath \"$CLASSPATH\" org.gradle.wrapper.GradleWrapperMain \"$@\"\n"
  },
  {
    "path": "gradlew.bat",
    "content": "@if \"%DEBUG%\" == \"\" @echo off\n@rem ##########################################################################\n@rem\n@rem  Gradle startup script for Windows\n@rem\n@rem ##########################################################################\n\n@rem Set local scope for the variables with windows NT shell\nif \"%OS%\"==\"Windows_NT\" setlocal\n\n@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.\nset DEFAULT_JVM_OPTS=\n\nset DIRNAME=%~dp0\nif \"%DIRNAME%\" == \"\" set DIRNAME=.\nset APP_BASE_NAME=%~n0\nset APP_HOME=%DIRNAME%\n\n@rem Find java.exe\nif defined JAVA_HOME goto findJavaFromJavaHome\n\nset JAVA_EXE=java.exe\n%JAVA_EXE% -version >NUL 2>&1\nif \"%ERRORLEVEL%\" == \"0\" goto init\n\necho.\necho ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.\necho.\necho Please set the JAVA_HOME variable in your environment to match the\necho location of your Java installation.\n\ngoto fail\n\n:findJavaFromJavaHome\nset JAVA_HOME=%JAVA_HOME:\"=%\nset JAVA_EXE=%JAVA_HOME%/bin/java.exe\n\nif exist \"%JAVA_EXE%\" goto init\n\necho.\necho ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%\necho.\necho Please set the JAVA_HOME variable in your environment to match the\necho location of your Java installation.\n\ngoto fail\n\n:init\n@rem Get command-line arguments, handling Windowz variants\n\nif not \"%OS%\" == \"Windows_NT\" goto win9xME_args\nif \"%@eval[2+2]\" == \"4\" goto 4NT_args\n\n:win9xME_args\n@rem Slurp the command line arguments.\nset CMD_LINE_ARGS=\nset _SKIP=2\n\n:win9xME_args_slurp\nif \"x%~1\" == \"x\" goto execute\n\nset CMD_LINE_ARGS=%*\ngoto execute\n\n:4NT_args\n@rem Get arguments from the 4NT Shell from JP Software\nset CMD_LINE_ARGS=%$\n\n:execute\n@rem Setup the command line\n\nset CLASSPATH=%APP_HOME%\\gradle\\wrapper\\gradle-wrapper.jar\n\n@rem Execute Gradle\n\"%JAVA_EXE%\" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% \"-Dorg.gradle.appname=%APP_BASE_NAME%\" -classpath \"%CLASSPATH%\" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%\n\n:end\n@rem End local scope for the variables with windows NT shell\nif \"%ERRORLEVEL%\"==\"0\" goto mainEnd\n\n:fail\nrem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of\nrem the _cmd.exe /c_ return code!\nif  not \"\" == \"%GRADLE_EXIT_CONSOLE%\" exit 1\nexit /b 1\n\n:mainEnd\nif \"%OS%\"==\"Windows_NT\" endlocal\n\n:omega\n"
  },
  {
    "path": "jackson-android-networking/.gitignore",
    "content": "/build\n"
  },
  {
    "path": "jackson-android-networking/build.gradle",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\napply plugin: 'com.android.library'\n\nandroid {\n    compileSdkVersion rootProject.ext.compileSdkVersion\n    buildToolsVersion rootProject.ext.buildToolsVersion\n\n    defaultConfig {\n        minSdkVersion rootProject.ext.minSdkVersion\n        targetSdkVersion rootProject.ext.targetSdkVersion\n        versionCode 1\n        versionName \"1.0\"\n    }\n    buildTypes {\n        release {\n            minifyEnabled false\n            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'\n        }\n    }\n    packagingOptions {\n        exclude 'META-INF/DEPENDENCIES.txt'\n        exclude 'META-INF/LICENSE.txt'\n        exclude 'META-INF/NOTICE.txt'\n        exclude 'META-INF/NOTICE'\n        exclude 'META-INF/LICENSE'\n        exclude 'META-INF/DEPENDENCIES'\n        exclude 'META-INF/notice.txt'\n        exclude 'META-INF/license.txt'\n        exclude 'META-INF/dependencies.txt'\n        exclude 'META-INF/LGPL2.1'\n    }\n}\n\ndependencies {\n    api fileTree(dir: 'libs', include: ['*.jar'])\n    testImplementation \"junit:junit:$rootProject.ext.jUnitVersion\"\n    androidTestImplementation \"com.squareup.okhttp3:mockwebserver:$rootProject.ext.mockWebServerVersion\"\n    api \"com.fasterxml.jackson.core:jackson-databind:$rootProject.ext.jacksonVersion\"\n    api project(':android-networking')\n}\n"
  },
  {
    "path": "jackson-android-networking/proguard-rules.pro",
    "content": "# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in /Users/amitshekhar/Library/Android/sdk/tools/proguard/proguard-android.txt\n# You can edit the include path and order by changing the proguardFiles\n# directive in build.gradle.\n#\n# For more details, see\n#   http://developer.android.com/guide/developing/tools/proguard.html\n\n# Add any project specific keep options here:\n\n# If your project uses WebView with JS, uncomment the following\n# and specify the fully qualified class name to the JavaScript interface\n# class:\n#-keepclassmembers class fqcn.of.javascript.interface.for.webview {\n#   public *;\n#}\n"
  },
  {
    "path": "jackson-android-networking/src/androidTest/AndroidManifest.xml",
    "content": "<!--\n  ~ /*\n  ~  *    Copyright (C) 2016 Amit Shekhar\n  ~  *    Copyright (C) 2011 Android Open Source Project\n  ~  *\n  ~  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n  ~  *    you may not use this file except in compliance with the License.\n  ~  *    You may obtain a copy of the License at\n  ~  *\n  ~  *        http://www.apache.org/licenses/LICENSE-2.0\n  ~  *\n  ~  *    Unless required by applicable law or agreed to in writing, software\n  ~  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n  ~  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  ~  *    See the License for the specific language governing permissions and\n  ~  *    limitations under the License.\n  ~  */\n  -->\n\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    package=\"com.jacksonandroidnetworking\">\n\n    <uses-permission android:name=\"android.permission.INTERNET\" />\n    <uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\"></uses-permission>\n\n</manifest>\n"
  },
  {
    "path": "jackson-android-networking/src/androidTest/java/com/jacksonandroidnetworking/JacksonGetObjectApiTest.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.jacksonandroidnetworking;\n\nimport android.app.Application;\nimport android.test.ApplicationTestCase;\n\nimport com.androidnetworking.AndroidNetworking;\nimport com.androidnetworking.common.ANConstants;\nimport com.androidnetworking.common.ANRequest;\nimport com.androidnetworking.common.ANResponse;\nimport com.androidnetworking.error.ANError;\nimport com.androidnetworking.interfaces.OkHttpResponseAndParsedRequestListener;\nimport com.androidnetworking.interfaces.ParsedRequestListener;\nimport com.jacksonandroidnetworking.model.User;\n\nimport org.json.JSONException;\nimport org.junit.Rule;\n\nimport java.util.List;\nimport java.util.concurrent.CountDownLatch;\nimport java.util.concurrent.Executors;\nimport java.util.concurrent.atomic.AtomicReference;\n\nimport okhttp3.Response;\nimport okhttp3.mockwebserver.MockResponse;\nimport okhttp3.mockwebserver.MockWebServer;\n\nimport static java.util.concurrent.TimeUnit.SECONDS;\n\n/**\n * Created by amitshekhar on 05/05/17.\n */\n\npublic class JacksonGetObjectApiTest extends ApplicationTestCase<Application> {\n\n    @Rule\n    public final MockWebServer server = new MockWebServer();\n\n    public JacksonGetObjectApiTest() {\n        super(Application.class);\n    }\n\n    @Override\n    public void setUp() throws Exception {\n        super.setUp();\n        createApplication();\n        AndroidNetworking.setParserFactory(new JacksonParserFactory());\n    }\n\n    public void testObjectGetRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.get(server.url(\"/\").toString())\n                .build()\n                .getAsObject(User.class, new ParsedRequestListener<User>() {\n                    @Override\n                    public void onResponse(User user) {\n                        firstNameRef.set(user.firstName);\n                        lastNameRef.set(user.lastName);\n                        latch.countDown();\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testObjectGetRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.get(server.url(\"/\").toString())\n                .build()\n                .getAsObject(User.class, new ParsedRequestListener<User>() {\n                    @Override\n                    public void onResponse(User user) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n\n    }\n\n    public void testObjectListGetRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"[{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}]\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.get(server.url(\"/\").toString())\n                .build()\n                .getAsObjectList(User.class, new ParsedRequestListener<List<User>>() {\n                    @Override\n                    public void onResponse(List<User> userList) {\n                        firstNameRef.set(userList.get(0).firstName);\n                        lastNameRef.set(userList.get(0).lastName);\n                        latch.countDown();\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testObjectListGetRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.get(server.url(\"/\").toString())\n                .build()\n                .getAsObjectList(User.class, new ParsedRequestListener<List<User>>() {\n                    @Override\n                    public void onResponse(List<User> userList) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public void testSynchronousObjectGetRequest() throws InterruptedException, JSONException {\n\n        server.enqueue(new MockResponse().setBody(\"{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}\"));\n\n        ANRequest request = AndroidNetworking.get(server.url(\"/\").toString()).build();\n\n        ANResponse<User> response = request.executeForObject(User.class);\n\n        assertEquals(\"Amit\", response.getResult().firstName);\n\n        assertEquals(\"Shekhar\", response.getResult().lastName);\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public void testSynchronousObjectGetRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        ANRequest request = AndroidNetworking.get(server.url(\"/\").toString()).build();\n\n        ANResponse<User> response = request.executeForObject(User.class);\n\n        ANError error = response.getError();\n\n        assertEquals(\"data\", error.getErrorBody());\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, error.getErrorDetail());\n\n        assertEquals(404, error.getErrorCode());\n\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public void testSynchronousObjectListGetRequest() throws InterruptedException, JSONException {\n\n        server.enqueue(new MockResponse().setBody(\"[{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}]\"));\n\n        ANRequest request = AndroidNetworking.get(server.url(\"/\").toString()).build();\n\n        ANResponse<List<User>> response = request.executeForObjectList(User.class);\n\n        User user = response.getResult().get(0);\n\n        assertEquals(\"Amit\", user.firstName);\n\n        assertEquals(\"Shekhar\", user.lastName);\n\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public void testSynchronousObjectListGetRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        ANRequest request = AndroidNetworking.get(server.url(\"/\").toString()).build();\n\n        ANResponse<List<User>> response = request.executeForObjectList(User.class);\n\n        ANError error = response.getError();\n\n        assertEquals(\"data\", error.getErrorBody());\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, error.getErrorDetail());\n\n        assertEquals(404, error.getErrorCode());\n\n    }\n\n    public void testResponseBodyAndObjectGet() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final AtomicReference<Boolean> responseBodySuccess = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.get(server.url(\"/\").toString())\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponseAndObject(User.class,\n                        new OkHttpResponseAndParsedRequestListener<User>() {\n                            @Override\n                            public void onResponse(Response okHttpResponse, User user) {\n                                firstNameRef.set(user.firstName);\n                                lastNameRef.set(user.lastName);\n                                responseBodySuccess.set(okHttpResponse.isSuccessful());\n                                latch.countDown();\n                            }\n\n                            @Override\n                            public void onError(ANError anError) {\n                                assertTrue(false);\n                            }\n                        });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(responseBodySuccess.get());\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testResponseBodyAndObjectGet404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.get(server.url(\"/\").toString())\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponseAndObject(User.class,\n                        new OkHttpResponseAndParsedRequestListener<User>() {\n                            @Override\n                            public void onResponse(Response okHttpResponse, User user) {\n                                assertTrue(false);\n                            }\n\n                            @Override\n                            public void onError(ANError anError) {\n                                errorBodyRef.set(anError.getErrorBody());\n                                errorDetailRef.set(anError.getErrorDetail());\n                                errorCodeRef.set(anError.getErrorCode());\n                                latch.countDown();\n                            }\n                        });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n    }\n\n    public void testResponseBodyAndObjectListGet() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"[{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}]\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final AtomicReference<Boolean> responseBodySuccess = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.get(server.url(\"/\").toString())\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponseAndObjectList(User.class,\n                        new OkHttpResponseAndParsedRequestListener<List<User>>() {\n                            @Override\n                            public void onResponse(Response okHttpResponse, List<User> userList) {\n                                firstNameRef.set(userList.get(0).firstName);\n                                lastNameRef.set(userList.get(0).lastName);\n                                responseBodySuccess.set(okHttpResponse.isSuccessful());\n                                latch.countDown();\n                            }\n\n                            @Override\n                            public void onError(ANError anError) {\n                                assertTrue(false);\n                            }\n                        });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(responseBodySuccess.get());\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testResponseBodyAndObjectListGet404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.get(server.url(\"/\").toString())\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponseAndObjectList(User.class,\n                        new OkHttpResponseAndParsedRequestListener<List<User>>() {\n                            @Override\n                            public void onResponse(Response okHttpResponse, List<User> userList) {\n                                assertTrue(false);\n                            }\n\n                            @Override\n                            public void onError(ANError anError) {\n                                errorBodyRef.set(anError.getErrorBody());\n                                errorDetailRef.set(anError.getErrorDetail());\n                                errorCodeRef.set(anError.getErrorCode());\n                                latch.countDown();\n                            }\n                        });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n    }\n\n    public void testHeaderGetRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final AtomicReference<String> headerRef = new AtomicReference<>();\n        final AtomicReference<Boolean> responseBodySuccess = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.get(server.url(\"/\").toString())\n                .addHeaders(\"headerKey\", \"headerValue\")\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponseAndObject(User.class,\n                        new OkHttpResponseAndParsedRequestListener<User>() {\n                            @Override\n                            public void onResponse(Response okHttpResponse, User user) {\n                                firstNameRef.set(user.firstName);\n                                lastNameRef.set(user.lastName);\n                                responseBodySuccess.set(okHttpResponse.isSuccessful());\n                                headerRef.set(okHttpResponse.request().header(\"headerKey\"));\n                                latch.countDown();\n                            }\n\n                            @Override\n                            public void onError(ANError anError) {\n                                assertTrue(false);\n                            }\n                        });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(responseBodySuccess.get());\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n        assertEquals(\"headerValue\", headerRef.get());\n    }\n\n\n}\n"
  },
  {
    "path": "jackson-android-networking/src/androidTest/java/com/jacksonandroidnetworking/JacksonPostObjectApiTest.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.jacksonandroidnetworking;\n\nimport android.app.Application;\nimport android.test.ApplicationTestCase;\n\nimport com.androidnetworking.AndroidNetworking;\nimport com.androidnetworking.common.ANConstants;\nimport com.androidnetworking.common.ANRequest;\nimport com.androidnetworking.common.ANResponse;\nimport com.androidnetworking.error.ANError;\nimport com.androidnetworking.interfaces.OkHttpResponseAndParsedRequestListener;\nimport com.androidnetworking.interfaces.ParsedRequestListener;\nimport com.jacksonandroidnetworking.model.User;\n\nimport org.json.JSONException;\nimport org.junit.Rule;\n\nimport java.util.List;\nimport java.util.concurrent.CountDownLatch;\nimport java.util.concurrent.Executors;\nimport java.util.concurrent.atomic.AtomicReference;\n\nimport okhttp3.Response;\nimport okhttp3.mockwebserver.MockResponse;\nimport okhttp3.mockwebserver.MockWebServer;\n\nimport static java.util.concurrent.TimeUnit.SECONDS;\n\n/**\n * Created by amitshekhar on 13/05/17.\n */\n\npublic class JacksonPostObjectApiTest extends ApplicationTestCase<Application> {\n\n    @Rule\n    public final MockWebServer server = new MockWebServer();\n\n    public JacksonPostObjectApiTest() {\n        super(Application.class);\n    }\n\n    @Override\n    public void setUp() throws Exception {\n        super.setUp();\n        createApplication();\n        AndroidNetworking.setParserFactory(new JacksonParserFactory());\n    }\n\n\n    public void testObjectPostRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .build()\n                .getAsObject(User.class, new ParsedRequestListener<User>() {\n                    @Override\n                    public void onResponse(User user) {\n                        firstNameRef.set(user.firstName);\n                        lastNameRef.set(user.lastName);\n                        latch.countDown();\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testObjectPostRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .build()\n                .getAsObject(User.class, new ParsedRequestListener<User>() {\n                    @Override\n                    public void onResponse(User user) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n\n    }\n\n    public void testObjectListPostRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"[{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}]\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .build()\n                .getAsObjectList(User.class, new ParsedRequestListener<List<User>>() {\n                    @Override\n                    public void onResponse(List<User> userList) {\n                        firstNameRef.set(userList.get(0).firstName);\n                        lastNameRef.set(userList.get(0).lastName);\n                        latch.countDown();\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testObjectListPostRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .build()\n                .getAsObjectList(User.class, new ParsedRequestListener<List<User>>() {\n                    @Override\n                    public void onResponse(List<User> userList) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(ANError anError) {\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public void testSynchronousObjectPostRequest() throws InterruptedException, JSONException {\n\n        server.enqueue(new MockResponse().setBody(\"{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}\"));\n\n        ANRequest request = AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .build();\n\n        ANResponse<User> response = request.executeForObject(User.class);\n\n        assertEquals(\"Amit\", response.getResult().firstName);\n\n        assertEquals(\"Shekhar\", response.getResult().lastName);\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public void testSynchronousObjectPostRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        ANRequest request = AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .build();\n\n        ANResponse<User> response = request.executeForObject(User.class);\n\n        ANError error = response.getError();\n\n        assertEquals(\"data\", error.getErrorBody());\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, error.getErrorDetail());\n\n        assertEquals(404, error.getErrorCode());\n\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public void testSynchronousObjectListPostRequest() throws InterruptedException, JSONException {\n\n        server.enqueue(new MockResponse().setBody(\"[{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}]\"));\n\n        ANRequest request = AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .build();\n\n        ANResponse<List<User>> response = request.executeForObjectList(User.class);\n\n        User user = response.getResult().get(0);\n\n        assertEquals(\"Amit\", user.firstName);\n\n        assertEquals(\"Shekhar\", user.lastName);\n\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    public void testSynchronousObjectListPostRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        ANRequest request = AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .build();\n\n        ANResponse<List<User>> response = request.executeForObjectList(User.class);\n\n        ANError error = response.getError();\n\n        assertEquals(\"data\", error.getErrorBody());\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, error.getErrorDetail());\n\n        assertEquals(404, error.getErrorCode());\n\n    }\n\n    public void testResponseBodyAndObjectPost() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final AtomicReference<Boolean> responseBodySuccess = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponseAndObject(User.class,\n                        new OkHttpResponseAndParsedRequestListener<User>() {\n                            @Override\n                            public void onResponse(Response okHttpResponse, User user) {\n                                firstNameRef.set(user.firstName);\n                                lastNameRef.set(user.lastName);\n                                responseBodySuccess.set(okHttpResponse.isSuccessful());\n                                latch.countDown();\n                            }\n\n                            @Override\n                            public void onError(ANError anError) {\n                                assertTrue(false);\n                            }\n                        });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(responseBodySuccess.get());\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testResponseBodyAndObjectPost404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponseAndObject(User.class,\n                        new OkHttpResponseAndParsedRequestListener<User>() {\n                            @Override\n                            public void onResponse(Response okHttpResponse, User user) {\n                                assertTrue(false);\n                            }\n\n                            @Override\n                            public void onError(ANError anError) {\n                                errorBodyRef.set(anError.getErrorBody());\n                                errorDetailRef.set(anError.getErrorDetail());\n                                errorCodeRef.set(anError.getErrorCode());\n                                latch.countDown();\n                            }\n                        });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n    }\n\n    public void testResponseBodyAndObjectListPost() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"[{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}]\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final AtomicReference<Boolean> responseBodySuccess = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponseAndObjectList(User.class,\n                        new OkHttpResponseAndParsedRequestListener<List<User>>() {\n                            @Override\n                            public void onResponse(Response okHttpResponse, List<User> userList) {\n                                firstNameRef.set(userList.get(0).firstName);\n                                lastNameRef.set(userList.get(0).lastName);\n                                responseBodySuccess.set(okHttpResponse.isSuccessful());\n                                latch.countDown();\n                            }\n\n                            @Override\n                            public void onError(ANError anError) {\n                                assertTrue(false);\n                            }\n                        });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(responseBodySuccess.get());\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testResponseBodyAndObjectListPost404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponseAndObjectList(User.class,\n                        new OkHttpResponseAndParsedRequestListener<List<User>>() {\n                            @Override\n                            public void onResponse(Response okHttpResponse, List<User> userList) {\n                                assertTrue(false);\n                            }\n\n                            @Override\n                            public void onError(ANError anError) {\n                                errorBodyRef.set(anError.getErrorBody());\n                                errorDetailRef.set(anError.getErrorDetail());\n                                errorCodeRef.set(anError.getErrorCode());\n                                latch.countDown();\n                            }\n                        });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n    }\n\n    public void testHeaderPostRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final AtomicReference<String> headerRef = new AtomicReference<>();\n        final AtomicReference<Boolean> responseBodySuccess = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        AndroidNetworking.post(server.url(\"/\").toString())\n                .addHeaders(\"headerKey\", \"headerValue\")\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .setExecutor(Executors.newSingleThreadExecutor())\n                .build()\n                .getAsOkHttpResponseAndObject(User.class,\n                        new OkHttpResponseAndParsedRequestListener<User>() {\n                            @Override\n                            public void onResponse(Response okHttpResponse, User user) {\n                                firstNameRef.set(user.firstName);\n                                lastNameRef.set(user.lastName);\n                                responseBodySuccess.set(okHttpResponse.isSuccessful());\n                                headerRef.set(okHttpResponse.request().header(\"headerKey\"));\n                                latch.countDown();\n                            }\n\n                            @Override\n                            public void onError(ANError anError) {\n                                assertTrue(false);\n                            }\n                        });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(responseBodySuccess.get());\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n        assertEquals(\"headerValue\", headerRef.get());\n    }\n\n\n}\n"
  },
  {
    "path": "jackson-android-networking/src/androidTest/java/com/jacksonandroidnetworking/model/User.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.jacksonandroidnetworking.model;\n\n/**\n * Created by amitshekhar on 05/05/17.\n */\n\npublic class User {\n\n    public String firstName;\n    public String lastName;\n\n}\n"
  },
  {
    "path": "jackson-android-networking/src/main/AndroidManifest.xml",
    "content": "<!--\n  ~ /*\n  ~  *    Copyright (C) 2016 Amit Shekhar\n  ~  *    Copyright (C) 2011 Android Open Source Project\n  ~  *\n  ~  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n  ~  *    you may not use this file except in compliance with the License.\n  ~  *    You may obtain a copy of the License at\n  ~  *\n  ~  *        http://www.apache.org/licenses/LICENSE-2.0\n  ~  *\n  ~  *    Unless required by applicable law or agreed to in writing, software\n  ~  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n  ~  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  ~  *    See the License for the specific language governing permissions and\n  ~  *    limitations under the License.\n  ~  */\n  -->\n\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    package=\"com.jacksonandroidnetworking\">\n</manifest>\n"
  },
  {
    "path": "jackson-android-networking/src/main/java/com/jacksonandroidnetworking/JacksonParserFactory.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.jacksonandroidnetworking;\n\nimport com.androidnetworking.interfaces.Parser;\nimport com.fasterxml.jackson.core.type.TypeReference;\nimport com.fasterxml.jackson.databind.JavaType;\nimport com.fasterxml.jackson.databind.ObjectMapper;\nimport com.fasterxml.jackson.databind.ObjectReader;\nimport com.fasterxml.jackson.databind.ObjectWriter;\n\nimport java.lang.reflect.Type;\nimport java.util.HashMap;\n\nimport okhttp3.RequestBody;\nimport okhttp3.ResponseBody;\n\n/**\n * Created by amitshekhar on 15/09/16.\n */\npublic final class JacksonParserFactory extends Parser.Factory {\n\n    private final ObjectMapper mapper;\n\n    public JacksonParserFactory() {\n        this.mapper = new ObjectMapper();\n    }\n\n    public JacksonParserFactory(ObjectMapper mapper) {\n        this.mapper = mapper;\n    }\n\n    @Override\n    public Parser<ResponseBody, ?> responseBodyParser(Type type) {\n        JavaType javaType = mapper.getTypeFactory().constructType(type);\n        ObjectReader reader = mapper.readerFor(javaType);\n        return new JacksonResponseBodyParser<>(reader);\n    }\n\n    @Override\n    public Parser<?, RequestBody> requestBodyParser(Type type) {\n        JavaType javaType = mapper.getTypeFactory().constructType(type);\n        ObjectWriter writer = mapper.writerFor(javaType);\n        return new JacksonRequestBodyParser<>(writer);\n    }\n\n    @Override\n    public Object getObject(String string, Type type) {\n        try {\n            JavaType javaType = mapper.getTypeFactory().constructType(type);\n            ObjectReader objectReader = mapper.readerFor(javaType);\n            return objectReader.readValue(string);\n        } catch (Exception e) {\n            e.printStackTrace();\n        }\n        return null;\n    }\n\n    @Override\n    public String getString(Object object) {\n        try {\n            ObjectWriter objectWriter = mapper.writerFor(object.getClass());\n            return objectWriter.writeValueAsString(object);\n        } catch (Exception e) {\n            e.printStackTrace();\n        }\n        return \"\";\n    }\n\n    @Override\n    public HashMap<String, String> getStringMap(Object object) {\n        try {\n            TypeReference<HashMap<String, String>> typeRef\n                    = new TypeReference<HashMap<String, String>>() {\n            };\n            ObjectWriter objectWriter = mapper.writerFor(object.getClass());\n            return mapper.readValue(objectWriter.writeValueAsString(object), typeRef);\n        } catch (Exception e) {\n            e.printStackTrace();\n        }\n        return new HashMap<>();\n    }\n}\n"
  },
  {
    "path": "jackson-android-networking/src/main/java/com/jacksonandroidnetworking/JacksonRequestBodyParser.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.jacksonandroidnetworking;\n\nimport com.androidnetworking.interfaces.Parser;\nimport com.fasterxml.jackson.databind.ObjectWriter;\n\nimport java.io.IOException;\n\nimport okhttp3.MediaType;\nimport okhttp3.RequestBody;\n\n/**\n * Created by amitshekhar on 15/09/16.\n */\nfinal class JacksonRequestBodyParser<T> implements Parser<T, RequestBody> {\n\n    private static final MediaType MEDIA_TYPE = MediaType.parse(\"application/json; charset=UTF-8\");\n\n    private final ObjectWriter adapter;\n\n    JacksonRequestBodyParser(ObjectWriter adapter) {\n        this.adapter = adapter;\n    }\n\n    @Override\n    public RequestBody convert(T value) throws IOException {\n        byte[] bytes = adapter.writeValueAsBytes(value);\n        return RequestBody.create(MEDIA_TYPE, bytes);\n    }\n}\n"
  },
  {
    "path": "jackson-android-networking/src/main/java/com/jacksonandroidnetworking/JacksonResponseBodyParser.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.jacksonandroidnetworking;\n\nimport com.androidnetworking.interfaces.Parser;\nimport com.fasterxml.jackson.databind.ObjectReader;\n\nimport java.io.IOException;\n\nimport okhttp3.ResponseBody;\n\n/**\n * Created by amitshekhar on 15/09/16.\n */\nfinal class JacksonResponseBodyParser<T> implements Parser<ResponseBody, T> {\n\n    private final ObjectReader adapter;\n\n    JacksonResponseBodyParser(ObjectReader adapter) {\n        this.adapter = adapter;\n    }\n\n    @Override\n    public T convert(ResponseBody value) throws IOException {\n        try {\n            return adapter.readValue(value.charStream());\n        } finally {\n            value.close();\n        }\n    }\n\n}"
  },
  {
    "path": "jackson-android-networking/src/main/res/values/strings.xml",
    "content": "<!--\n  ~ /*\n  ~  *    Copyright (C) 2016 Amit Shekhar\n  ~  *    Copyright (C) 2011 Android Open Source Project\n  ~  *\n  ~  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n  ~  *    you may not use this file except in compliance with the License.\n  ~  *    You may obtain a copy of the License at\n  ~  *\n  ~  *        http://www.apache.org/licenses/LICENSE-2.0\n  ~  *\n  ~  *    Unless required by applicable law or agreed to in writing, software\n  ~  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n  ~  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  ~  *    See the License for the specific language governing permissions and\n  ~  *    limitations under the License.\n  ~  */\n  -->\n\n<resources>\n    <string name=\"app_name\">JacksonAndroidNetworking</string>\n</resources>\n"
  },
  {
    "path": "jackson-android-networking/src/test/java/com/jacksonandroidnetworking/ExampleUnitTest.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.jacksonandroidnetworking;\n\nimport org.junit.Test;\n\nimport static org.junit.Assert.*;\n\n/**\n * To work on unit tests, switch the Test Artifact in the Build Variants view.\n */\npublic class ExampleUnitTest {\n    @Test\n    public void addition_isCorrect() throws Exception {\n        assertEquals(4, 2 + 2);\n    }\n}"
  },
  {
    "path": "rx-android-networking/.gitignore",
    "content": "/build\n"
  },
  {
    "path": "rx-android-networking/build.gradle",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\napply plugin: 'com.android.library'\n\nandroid {\n    compileSdkVersion rootProject.ext.compileSdkVersion\n    buildToolsVersion rootProject.ext.buildToolsVersion\n\n    defaultConfig {\n        minSdkVersion rootProject.ext.minSdkVersion\n        targetSdkVersion rootProject.ext.targetSdkVersion\n        versionCode 1\n        versionName \"1.0\"\n    }\n    buildTypes {\n        release {\n            minifyEnabled false\n            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'\n        }\n    }\n}\n\ndependencies {\n    api fileTree(dir: 'libs', include: ['*.jar'])\n    testImplementation \"junit:junit:$rootProject.ext.jUnitVersion\"\n    api \"io.reactivex:rxandroid:$rootProject.ext.rxJavaAndroidVersion\"\n    api \"io.reactivex:rxjava:$rootProject.ext.rxJavaVersion\"\n    api project(':android-networking')\n}\n"
  },
  {
    "path": "rx-android-networking/proguard-rules.pro",
    "content": "# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in /Users/amitshekhar/Library/Android/sdk/tools/proguard/proguard-android.txt\n# You can edit the include path and order by changing the proguardFiles\n# directive in build.gradle.\n#\n# For more details, see\n#   http://developer.android.com/guide/developing/tools/proguard.html\n\n# Add any project specific keep options here:\n\n# If your project uses WebView with JS, uncomment the following\n# and specify the fully qualified class name to the JavaScript interface\n# class:\n#-keepclassmembers class fqcn.of.javascript.interface.for.webview {\n#   public *;\n#}\n"
  },
  {
    "path": "rx-android-networking/src/androidTest/java/com/rxandroidnetworking/ApplicationTest.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.rxandroidnetworking;\n\nimport android.app.Application;\nimport android.test.ApplicationTestCase;\n\n/**\n * <a href=\"http://d.android.com/tools/testing/testing_android.html\">Testing Fundamentals</a>\n */\npublic class ApplicationTest extends ApplicationTestCase<Application> {\n    public ApplicationTest() {\n        super(Application.class);\n    }\n}"
  },
  {
    "path": "rx-android-networking/src/main/AndroidManifest.xml",
    "content": "<!--\n  ~    Copyright (C) 2016 Amit Shekhar\n  ~    Copyright (C) 2011 Android Open Source Project\n  ~\n  ~    Licensed under the Apache License, Version 2.0 (the \"License\");\n  ~    you may not use this file except in compliance with the License.\n  ~    You may obtain a copy of the License at\n  ~\n  ~        http://www.apache.org/licenses/LICENSE-2.0\n  ~\n  ~    Unless required by applicable law or agreed to in writing, software\n  ~    distributed under the License is distributed on an \"AS IS\" BASIS,\n  ~    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  ~    See the License for the specific language governing permissions and\n  ~    limitations under the License.\n  -->\n\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    package=\"com.rxandroidnetworking\">\n</manifest>\n"
  },
  {
    "path": "rx-android-networking/src/main/java/com/rxandroidnetworking/RxANRequest.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.rxandroidnetworking;\n\nimport android.graphics.Bitmap;\n\nimport com.androidnetworking.common.ANRequest;\nimport com.androidnetworking.common.Method;\nimport com.androidnetworking.common.RequestType;\nimport com.androidnetworking.common.ResponseType;\nimport com.google.gson.internal.$Gson$Types;\nimport com.google.gson.reflect.TypeToken;\n\nimport org.json.JSONArray;\nimport org.json.JSONObject;\n\nimport java.util.List;\n\nimport rx.Completable;\nimport rx.Observable;\nimport rx.Single;\n\n/**\n * Created by amitshekhar on 10/06/16.\n */\n@SuppressWarnings({\"unchecked\", \"unused\"})\npublic class RxANRequest extends ANRequest<RxANRequest> {\n\n    public RxANRequest(GetRequestBuilder builder) {\n        super(builder);\n    }\n\n    public RxANRequest(PostRequestBuilder builder) {\n        super(builder);\n    }\n\n    public RxANRequest(DownloadBuilder builder) {\n        super(builder);\n    }\n\n    public RxANRequest(MultiPartBuilder builder) {\n        super(builder);\n    }\n\n    public Observable<JSONObject> getJSONObjectObservable() {\n        this.setResponseAs(ResponseType.JSON_OBJECT);\n        if (this.getRequestType() == RequestType.SIMPLE) {\n            return RxInternalNetworking.generateSimpleObservable(this);\n        } else if (this.getRequestType() == RequestType.MULTIPART) {\n            return RxInternalNetworking.generateMultipartObservable(this);\n        } else {\n            return null;\n        }\n    }\n\n    public Single<JSONObject> getJSONObjectSingle() {\n        return getJSONObjectObservable().toSingle();\n    }\n\n    public Completable getJSONObjectCompletable() {\n        return getJSONObjectObservable().toCompletable();\n    }\n\n    public Observable<JSONArray> getJSONArrayObservable() {\n        this.setResponseAs(ResponseType.JSON_ARRAY);\n        if (this.getRequestType() == RequestType.SIMPLE) {\n            return RxInternalNetworking.generateSimpleObservable(this);\n        } else if (this.getRequestType() == RequestType.MULTIPART) {\n            return RxInternalNetworking.generateMultipartObservable(this);\n        } else {\n            return null;\n        }\n    }\n\n    public Single<JSONArray> getJSONArraySingle() {\n        return getJSONArrayObservable().toSingle();\n    }\n\n    public Completable getJSONArrayCompletable() {\n        return getJSONArrayObservable().toCompletable();\n    }\n\n    public Observable<Bitmap> getBitmapObservable() {\n        this.setResponseAs(ResponseType.BITMAP);\n        if (this.getRequestType() == RequestType.SIMPLE) {\n            return RxInternalNetworking.generateSimpleObservable(this);\n        } else if (this.getRequestType() == RequestType.MULTIPART) {\n            return RxInternalNetworking.generateMultipartObservable(this);\n        } else {\n            return null;\n        }\n    }\n\n    public Single<Bitmap> getBitmapSingle() {\n        return getBitmapObservable().toSingle();\n    }\n\n    public Completable getBitmapCompletable() {\n        return getBitmapObservable().toCompletable();\n    }\n\n    public Observable<String> getStringObservable() {\n        this.setResponseAs(ResponseType.STRING);\n        if (this.getRequestType() == RequestType.SIMPLE) {\n            return RxInternalNetworking.generateSimpleObservable(this);\n        } else if (this.getRequestType() == RequestType.MULTIPART) {\n            return RxInternalNetworking.generateMultipartObservable(this);\n        } else {\n            return null;\n        }\n    }\n\n    public Single<String> getStringSingle() {\n        return getStringObservable().toSingle();\n    }\n\n    public Completable getStringCompletable() {\n        return getStringObservable().toCompletable();\n    }\n\n    public Observable<String> getDownloadObservable() {\n        return RxInternalNetworking.generateDownloadObservable(this);\n    }\n\n    public Single<String> getDownloadSingle() {\n        return getDownloadObservable().toSingle();\n    }\n\n    public Completable getDownloadCompletable() {\n        return getDownloadObservable().toCompletable();\n    }\n\n    public <T> Observable<T> getParseObservable(TypeToken<T> typeToken) {\n        this.setType(typeToken.getType());\n        this.setResponseAs(ResponseType.PARSED);\n        if (this.getRequestType() == RequestType.SIMPLE) {\n            return RxInternalNetworking.generateSimpleObservable(this);\n        } else if (this.getRequestType() == RequestType.MULTIPART) {\n            return RxInternalNetworking.generateMultipartObservable(this);\n        } else {\n            return null;\n        }\n    }\n\n    public <T> Single<T> getParseSingle(TypeToken<T> typeToken) {\n        return getParseObservable(typeToken).toSingle();\n    }\n\n    public <T> Completable getParseCompletable(TypeToken<T> typeToken) {\n        return getParseObservable(typeToken).toCompletable();\n    }\n\n    public <T> Observable<T> getObjectObservable(Class<T> objectClass) {\n        this.setType(objectClass);\n        this.setResponseAs(ResponseType.PARSED);\n        if (this.getRequestType() == RequestType.SIMPLE) {\n            return RxInternalNetworking.generateSimpleObservable(this);\n        } else if (this.getRequestType() == RequestType.MULTIPART) {\n            return RxInternalNetworking.generateMultipartObservable(this);\n        } else {\n            return null;\n        }\n    }\n\n    public <T> Single<T> getObjectSingle(Class<T> objectClass) {\n        return getObjectObservable(objectClass).toSingle();\n    }\n\n    public <T> Completable getObjectCompletable(Class<T> objectClass) {\n        return getObjectObservable(objectClass).toCompletable();\n    }\n\n    public <T> Observable<List<T>> getObjectListObservable(Class<T> objectClass) {\n        this.setType($Gson$Types.newParameterizedTypeWithOwner(null, List.class, objectClass));\n        this.setResponseAs(ResponseType.PARSED);\n        if (this.getRequestType() == RequestType.SIMPLE) {\n            return RxInternalNetworking.generateSimpleObservable(this);\n        } else if (this.getRequestType() == RequestType.MULTIPART) {\n            return RxInternalNetworking.generateMultipartObservable(this);\n        } else {\n            return null;\n        }\n    }\n\n    public <T> Single<List<T>> getObjectListSingle(Class<T> objectClass) {\n        return getObjectListObservable(objectClass).toSingle();\n    }\n\n    public <T> Completable getObjectListCompletable(Class<T> objectClass) {\n        return getObjectListObservable(objectClass).toCompletable();\n    }\n\n    public static class GetRequestBuilder extends ANRequest.GetRequestBuilder<GetRequestBuilder> {\n\n        public GetRequestBuilder(String url) {\n            super(url);\n        }\n\n        private GetRequestBuilder(String url, int method) {\n            super(url, method);\n        }\n\n        public RxANRequest build() {\n            return new RxANRequest(this);\n        }\n    }\n\n    public static class HeadRequestBuilder extends GetRequestBuilder {\n\n        public HeadRequestBuilder(String url) {\n            super(url, Method.HEAD);\n        }\n    }\n\n    public static class OptionsRequestBuilder extends GetRequestBuilder {\n\n        public OptionsRequestBuilder(String url) {\n            super(url, Method.OPTIONS);\n        }\n    }\n\n    public static class PostRequestBuilder extends ANRequest.PostRequestBuilder<PostRequestBuilder> {\n\n        public PostRequestBuilder(String url) {\n            super(url);\n        }\n\n        private PostRequestBuilder(String url, int method) {\n            super(url, method);\n        }\n\n        public RxANRequest build() {\n            return new RxANRequest(this);\n        }\n    }\n\n    public static class PutRequestBuilder extends PostRequestBuilder {\n\n        public PutRequestBuilder(String url) {\n            super(url, Method.PUT);\n        }\n    }\n\n    public static class DeleteRequestBuilder extends PostRequestBuilder {\n\n        public DeleteRequestBuilder(String url) {\n            super(url, Method.DELETE);\n        }\n    }\n\n    public static class PatchRequestBuilder extends PostRequestBuilder {\n\n        public PatchRequestBuilder(String url) {\n            super(url, Method.PATCH);\n        }\n    }\n\n    public static class DynamicRequestBuilder extends PostRequestBuilder {\n\n        public DynamicRequestBuilder(String url, int method) {\n            super(url, method);\n        }\n    }\n\n    public static class DownloadBuilder extends ANRequest.DownloadBuilder<DownloadBuilder> {\n\n        public DownloadBuilder(String url, String dirPath, String fileName) {\n            super(url, dirPath, fileName);\n        }\n\n        public RxANRequest build() {\n            return new RxANRequest(this);\n        }\n    }\n\n    public static class MultiPartBuilder extends ANRequest.MultiPartBuilder<MultiPartBuilder> {\n\n        public MultiPartBuilder(String url) {\n            super(url);\n        }\n\n        public RxANRequest build() {\n            return new RxANRequest(this);\n        }\n    }\n}\n"
  },
  {
    "path": "rx-android-networking/src/main/java/com/rxandroidnetworking/RxAndroidNetworking.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.rxandroidnetworking;\n\n/**\n * Created by amitshekhar on 10/06/16.\n */\n\n/**\n * RxAndroidNetworking entry point.\n * You must initialize this class before use. The simplest way is to just do\n * {#code AndroidNetworking.initialize(context)}.\n */\npublic class RxAndroidNetworking {\n\n    /**\n     * private constructor to prevent instantiation of this class\n     */\n    private RxAndroidNetworking() {\n    }\n\n    /**\n     * Method to make GET request\n     *\n     * @param url The url on which request is to be made\n     * @return The GetRequestBuilder\n     */\n    public static RxANRequest.GetRequestBuilder get(String url) {\n        return new RxANRequest.GetRequestBuilder(url);\n    }\n\n    /**\n     * Method to make HEAD request\n     *\n     * @param url The url on which request is to be made\n     * @return The HeadRequestBuilder\n     */\n    public static RxANRequest.HeadRequestBuilder head(String url) {\n        return new RxANRequest.HeadRequestBuilder(url);\n    }\n\n    /**\n     * Method to make OPTIONS request\n     *\n     * @param url The url on which request is to be made\n     * @return The OptionsRequestBuilder\n     */\n    public static RxANRequest.OptionsRequestBuilder options(String url) {\n        return new RxANRequest.OptionsRequestBuilder(url);\n    }\n\n    /**\n     * Method to make POST request\n     *\n     * @param url The url on which request is to be made\n     * @return The PostRequestBuilder\n     */\n    public static RxANRequest.PostRequestBuilder post(String url) {\n        return new RxANRequest.PostRequestBuilder(url);\n    }\n\n    /**\n     * Method to make PUT request\n     *\n     * @param url The url on which request is to be made\n     * @return The PutRequestBuilder\n     */\n    public static RxANRequest.PutRequestBuilder put(String url) {\n        return new RxANRequest.PutRequestBuilder(url);\n    }\n\n    /**\n     * Method to make DELETE request\n     *\n     * @param url The url on which request is to be made\n     * @return The DeleteRequestBuilder\n     */\n    public static RxANRequest.DeleteRequestBuilder delete(String url) {\n        return new RxANRequest.DeleteRequestBuilder(url);\n    }\n\n    /**\n     * Method to make PATCH request\n     *\n     * @param url The url on which request is to be made\n     * @return The PatchRequestBuilder\n     */\n    public static RxANRequest.PatchRequestBuilder patch(String url) {\n        return new RxANRequest.PatchRequestBuilder(url);\n    }\n\n    /**\n     * Method to make download request\n     *\n     * @param url      The url on which request is to be made\n     * @param dirPath  The directory path on which file is to be saved\n     * @param fileName The file name with which file is to be saved\n     * @return The DownloadBuilder\n     */\n    public static RxANRequest.DownloadBuilder download(String url, String dirPath, String fileName) {\n        return new RxANRequest.DownloadBuilder(url, dirPath, fileName);\n    }\n\n    /**\n     * Method to make upload request\n     *\n     * @param url The url on which request is to be made\n     * @return The MultiPartBuilder\n     */\n    public static RxANRequest.MultiPartBuilder upload(String url) {\n        return new RxANRequest.MultiPartBuilder(url);\n    }\n\n    /**\n     * Method to make Dynamic request\n     *\n     * @param url    The url on which request is to be made\n     * @param method The HTTP METHOD for the request\n     * @return The DynamicRequestBuilder\n     */\n    public static RxANRequest.DynamicRequestBuilder request(String url, int method) {\n        return new RxANRequest.DynamicRequestBuilder(url, method);\n    }\n}\n"
  },
  {
    "path": "rx-android-networking/src/main/java/com/rxandroidnetworking/RxInternalNetworking.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\npackage com.rxandroidnetworking;\n\nimport android.net.TrafficStats;\n\nimport com.androidnetworking.common.ANConstants;\nimport com.androidnetworking.common.ANResponse;\nimport com.androidnetworking.common.ConnectionClassManager;\nimport com.androidnetworking.common.RequestType;\nimport com.androidnetworking.error.ANError;\nimport com.androidnetworking.internal.InternalNetworking;\nimport com.androidnetworking.internal.RequestProgressBody;\nimport com.androidnetworking.internal.ResponseProgressBody;\nimport com.androidnetworking.utils.SourceCloseUtil;\nimport com.androidnetworking.utils.Utils;\n\nimport java.io.File;\nimport java.io.IOException;\nimport java.util.concurrent.atomic.AtomicBoolean;\n\nimport okhttp3.Call;\nimport okhttp3.Interceptor;\nimport okhttp3.OkHttpClient;\nimport okhttp3.Request;\nimport okhttp3.RequestBody;\nimport okhttp3.Response;\nimport rx.Observable;\nimport rx.Producer;\nimport rx.Subscriber;\nimport rx.Subscription;\nimport rx.exceptions.Exceptions;\n\nimport static com.androidnetworking.common.Method.DELETE;\nimport static com.androidnetworking.common.Method.GET;\nimport static com.androidnetworking.common.Method.HEAD;\nimport static com.androidnetworking.common.Method.OPTIONS;\nimport static com.androidnetworking.common.Method.PATCH;\nimport static com.androidnetworking.common.Method.POST;\nimport static com.androidnetworking.common.Method.PUT;\n\n/**\n * Created by Prashant Gupta on 25-07-2016.\n */\n@SuppressWarnings(\"unchecked\")\npublic class RxInternalNetworking {\n\n    public static <T> Observable<T> generateSimpleObservable(RxANRequest request) {\n        Request okHttpRequest;\n        Request.Builder builder = new Request.Builder().url(request.getUrl());\n        InternalNetworking.addHeadersToRequestBuilder(builder, request);\n        RequestBody requestBody;\n        switch (request.getMethod()) {\n            case GET: {\n                builder = builder.get();\n                break;\n            }\n            case POST: {\n                requestBody = request.getRequestBody();\n                builder = builder.post(requestBody);\n                break;\n            }\n            case PUT: {\n                requestBody = request.getRequestBody();\n                builder = builder.put(requestBody);\n                break;\n            }\n            case DELETE: {\n                requestBody = request.getRequestBody();\n                builder = builder.delete(requestBody);\n                break;\n            }\n            case HEAD: {\n                builder = builder.head();\n                break;\n            }\n            case OPTIONS: {\n                builder = builder.method(ANConstants.OPTIONS, null);\n                break;\n            }\n            case PATCH: {\n                requestBody = request.getRequestBody();\n                builder = builder.patch(requestBody);\n                break;\n            }\n        }\n        if (request.getCacheControl() != null) {\n            builder.cacheControl(request.getCacheControl());\n        }\n        okHttpRequest = builder.build();\n        if (request.getOkHttpClient() != null) {\n            request.setCall(request\n                    .getOkHttpClient()\n                    .newBuilder()\n                    .cache(InternalNetworking.sHttpClient.cache())\n                    .build()\n                    .newCall(okHttpRequest));\n        } else {\n            request.setCall(InternalNetworking.sHttpClient.newCall(okHttpRequest));\n        }\n        return Observable.create(new ANOnSubscribe<T>(request));\n    }\n\n    public static <T> Observable<T> generateDownloadObservable(final RxANRequest request) {\n        Request okHttpRequest;\n        Request.Builder builder = new Request.Builder().url(request.getUrl());\n        InternalNetworking.addHeadersToRequestBuilder(builder, request);\n        builder = builder.get();\n        if (request.getCacheControl() != null) {\n            builder.cacheControl(request.getCacheControl());\n        }\n        okHttpRequest = builder.build();\n\n        OkHttpClient okHttpClient;\n\n        if (request.getOkHttpClient() != null) {\n            okHttpClient = request\n                    .getOkHttpClient()\n                    .newBuilder()\n                    .cache(InternalNetworking.sHttpClient.cache())\n                    .addNetworkInterceptor(new Interceptor() {\n                        @Override\n                        public Response intercept(Chain chain) throws IOException {\n                            Response originalResponse = chain.proceed(chain.request());\n                            return originalResponse.newBuilder()\n                                    .body(new ResponseProgressBody(originalResponse.body(),\n                                            request.getDownloadProgressListener()))\n                                    .build();\n                        }\n                    }).build();\n        } else {\n            okHttpClient = InternalNetworking.sHttpClient.newBuilder()\n                    .addNetworkInterceptor(new Interceptor() {\n                        @Override\n                        public Response intercept(Chain chain) throws IOException {\n                            Response originalResponse = chain.proceed(chain.request());\n                            return originalResponse.newBuilder()\n                                    .body(new ResponseProgressBody(originalResponse.body(),\n                                            request.getDownloadProgressListener()))\n                                    .build();\n                        }\n                    }).build();\n        }\n        request.setCall(okHttpClient.newCall(okHttpRequest));\n        return Observable.create(new ANOnSubscribe<T>(request));\n    }\n\n    public static <T> Observable<T> generateMultipartObservable(final RxANRequest request) {\n        return Observable.create(new ANOnSubscribe<T>(request));\n    }\n\n    static final class ANOnSubscribe<T> implements Observable.OnSubscribe<T> {\n\n        private final RxANRequest request;\n\n        public ANOnSubscribe(RxANRequest request) {\n            this.request = request;\n        }\n\n        @Override\n        public void call(Subscriber<? super T> subscriber) {\n            switch (request.getRequestType()) {\n                case RequestType.SIMPLE:\n                    ANResolver<T> anResolver = new ANResolver<>(request, subscriber);\n                    subscriber.add(anResolver);\n                    subscriber.setProducer(anResolver);\n                    break;\n                case RequestType.DOWNLOAD:\n                    DownloadANResolver<T> downloadANResolver = new DownloadANResolver<>(request,\n                            subscriber);\n                    subscriber.add(downloadANResolver);\n                    subscriber.setProducer(downloadANResolver);\n                    break;\n                case RequestType.MULTIPART:\n                    MultipartANResolver<T> multipartANResolver = new MultipartANResolver<>(request,\n                            subscriber);\n                    subscriber.add(multipartANResolver);\n                    subscriber.setProducer(multipartANResolver);\n                    break;\n            }\n        }\n    }\n\n    static final class ANResolver<T> extends AtomicBoolean implements Subscription, Producer {\n        private final Call call;\n        private final RxANRequest request;\n        private final Subscriber<? super T> subscriber;\n\n        ANResolver(RxANRequest request, Subscriber<? super T> subscriber) {\n            this.request = request;\n            this.call = request.getCall();\n            this.subscriber = subscriber;\n        }\n\n        @Override\n        public void request(long n) {\n            if (n < 0) throw new IllegalArgumentException(\"n < 0: \" + n);\n            if (n == 0) return; // Nothing to do when requesting 0.\n            if (!compareAndSet(false, true)) return; // Request was already triggered.\n            Response okHttpResponse = null;\n            try {\n                final long startTime = System.currentTimeMillis();\n                final long startBytes = TrafficStats.getTotalRxBytes();\n                okHttpResponse = call.execute();\n                final long timeTaken = System.currentTimeMillis() - startTime;\n                if (okHttpResponse.cacheResponse() == null) {\n                    final long finalBytes = TrafficStats.getTotalRxBytes();\n                    final long diffBytes;\n                    if (startBytes == TrafficStats.UNSUPPORTED || finalBytes == TrafficStats.UNSUPPORTED) {\n                        diffBytes = okHttpResponse.body().contentLength();\n                    } else {\n                        diffBytes = finalBytes - startBytes;\n                    }\n                    ConnectionClassManager.getInstance().updateBandwidth(diffBytes, timeTaken);\n                    Utils.sendAnalytics(request.getAnalyticsListener(), timeTaken,\n                            (request.getRequestBody() != null &&\n                                    request.getRequestBody().contentLength() != 0) ?\n                                    request.getRequestBody().contentLength() : -1,\n                            okHttpResponse.body().contentLength(), false);\n                } else if (request.getAnalyticsListener() != null) {\n                    if (okHttpResponse.networkResponse() == null) {\n                        Utils.sendAnalytics(request.getAnalyticsListener(), timeTaken, 0, 0, true);\n                    } else {\n                        Utils.sendAnalytics(request.getAnalyticsListener(), timeTaken,\n                                (request.getRequestBody() != null && request.getRequestBody().contentLength() != 0) ?\n                                        request.getRequestBody().contentLength() : -1, 0, true);\n                    }\n                }\n                if (okHttpResponse.code() >= 400) {\n                    if (!subscriber.isUnsubscribed()) {\n                        subscriber.onError(Utils.getErrorForServerResponse(new ANError(okHttpResponse),\n                                request, okHttpResponse.code()));\n                    }\n                } else {\n                    ANResponse<T> response = request.parseResponse(okHttpResponse);\n                    if (!response.isSuccess()) {\n                        if (!subscriber.isUnsubscribed()) {\n                            subscriber.onError(response.getError());\n                        }\n                    } else {\n                        if (!subscriber.isUnsubscribed()) {\n                            subscriber.onNext(response.getResult());\n                        }\n                        if (!subscriber.isUnsubscribed()) {\n                            subscriber.onCompleted();\n                        }\n                    }\n                }\n            } catch (IOException ioe) {\n                if (!subscriber.isUnsubscribed()) {\n                    subscriber.onError(Utils.getErrorForConnection(new ANError(ioe)));\n                }\n            } catch (Exception e) {\n                Exceptions.throwIfFatal(e);\n                if (!subscriber.isUnsubscribed()) {\n                    subscriber.onError(Utils.getErrorForConnection(new ANError(e)));\n                }\n            } finally {\n                SourceCloseUtil.close(okHttpResponse, request);\n            }\n        }\n\n        @Override\n        public void unsubscribe() {\n            call.cancel();\n        }\n\n        @Override\n        public boolean isUnsubscribed() {\n            return call.isCanceled();\n        }\n    }\n\n    static final class DownloadANResolver<T> extends AtomicBoolean implements Subscription, Producer {\n        private final Call call;\n        private final RxANRequest request;\n        private final Subscriber<? super T> subscriber;\n\n        DownloadANResolver(RxANRequest request, Subscriber<? super T> subscriber) {\n            this.request = request;\n            this.call = request.getCall();\n            this.subscriber = subscriber;\n        }\n\n        @Override\n        public void request(long n) {\n            if (n < 0) throw new IllegalArgumentException(\"n < 0: \" + n);\n            if (n == 0) return; // Nothing to do when requesting 0.\n            if (!compareAndSet(false, true)) return; // Request was already triggered.\n            Response okHttpResponse;\n            try {\n                final long startTime = System.currentTimeMillis();\n                final long startBytes = TrafficStats.getTotalRxBytes();\n                okHttpResponse = request.getCall().execute();\n                Utils.saveFile(okHttpResponse, request.getDirPath(), request.getFileName());\n                final long timeTaken = System.currentTimeMillis() - startTime;\n                if (okHttpResponse.cacheResponse() == null) {\n                    final long finalBytes = TrafficStats.getTotalRxBytes();\n                    final long diffBytes;\n                    if (startBytes == TrafficStats.UNSUPPORTED ||\n                            finalBytes == TrafficStats.UNSUPPORTED) {\n                        diffBytes = okHttpResponse.body().contentLength();\n                    } else {\n                        diffBytes = finalBytes - startBytes;\n                    }\n                    ConnectionClassManager.getInstance().updateBandwidth(diffBytes, timeTaken);\n                    Utils.sendAnalytics(request.getAnalyticsListener(),\n                            timeTaken, -1, okHttpResponse.body().contentLength(), false);\n                } else if (request.getAnalyticsListener() != null) {\n                    Utils.sendAnalytics(request.getAnalyticsListener(), timeTaken, -1, 0, true);\n                }\n                if (okHttpResponse.code() >= 400) {\n                    if (!subscriber.isUnsubscribed()) {\n                        subscriber.onError(Utils.getErrorForServerResponse(new ANError(okHttpResponse),\n                                request, okHttpResponse.code()));\n                    }\n                } else {\n                    if (!subscriber.isUnsubscribed()) {\n                        ANResponse<T> response = (ANResponse<T>) ANResponse.success(ANConstants.SUCCESS);\n                        subscriber.onNext(response.getResult());\n                    }\n                    if (!subscriber.isUnsubscribed()) {\n                        subscriber.onCompleted();\n                    }\n                }\n            } catch (IOException ioe) {\n                try {\n                    File destinationFile = new File(request.getDirPath() + File.separator + request.getFileName());\n                    if (destinationFile.exists()) {\n                        destinationFile.delete();\n                    }\n                } catch (Exception e) {\n                    e.printStackTrace();\n                }\n                if (!subscriber.isUnsubscribed()) {\n                    subscriber.onError(Utils.getErrorForConnection(new ANError(ioe)));\n                }\n            } catch (Exception e) {\n                Exceptions.throwIfFatal(e);\n                if (!subscriber.isUnsubscribed()) {\n                    subscriber.onError(Utils.getErrorForConnection(new ANError(e)));\n                }\n            }\n        }\n\n        @Override\n        public void unsubscribe() {\n            call.cancel();\n        }\n\n        @Override\n        public boolean isUnsubscribed() {\n            return call.isCanceled();\n        }\n    }\n\n    static final class MultipartANResolver<T> extends AtomicBoolean implements Subscription, Producer {\n        private final RxANRequest request;\n        private final Subscriber<? super T> subscriber;\n\n        MultipartANResolver(RxANRequest request, Subscriber<? super T> subscriber) {\n            this.request = request;\n            this.subscriber = subscriber;\n        }\n\n        @Override\n        public void request(long n) {\n            if (n < 0) throw new IllegalArgumentException(\"n < 0: \" + n);\n            if (n == 0) return; // Nothing to do when requesting 0.\n            if (!compareAndSet(false, true)) return; // Request was already triggered.\n            Response okHttpResponse = null;\n            Request okHttpRequest;\n            try {\n                Request.Builder builder = new Request.Builder().url(request.getUrl());\n                InternalNetworking.addHeadersToRequestBuilder(builder, request);\n                final RequestBody requestBody = request.getMultiPartRequestBody();\n                final long requestBodyLength = requestBody.contentLength();\n                builder = builder.post(new RequestProgressBody(requestBody, request.getUploadProgressListener()));\n                if (request.getCacheControl() != null) {\n                    builder.cacheControl(request.getCacheControl());\n                }\n                okHttpRequest = builder.build();\n                if (request.getOkHttpClient() != null) {\n                    request.setCall(request\n                            .getOkHttpClient()\n                            .newBuilder()\n                            .cache(InternalNetworking.sHttpClient.cache())\n                            .build()\n                            .newCall(okHttpRequest));\n                } else {\n                    request.setCall(InternalNetworking.sHttpClient.newCall(okHttpRequest));\n                }\n                final long startTime = System.currentTimeMillis();\n                okHttpResponse = request.getCall().execute();\n                final long timeTaken = System.currentTimeMillis() - startTime;\n                if (request.getAnalyticsListener() != null) {\n                    if (okHttpResponse.cacheResponse() == null) {\n                        Utils.sendAnalytics(request.getAnalyticsListener(), timeTaken,\n                                requestBodyLength, okHttpResponse.body().contentLength(), false);\n                    } else {\n                        if (okHttpResponse.networkResponse() == null) {\n                            Utils.sendAnalytics(request.getAnalyticsListener(), timeTaken, 0, 0, true);\n                        } else {\n                            Utils.sendAnalytics(request.getAnalyticsListener(), timeTaken,\n                                    requestBodyLength != 0 ? requestBodyLength : -1, 0, true);\n                        }\n                    }\n                }\n                if (okHttpResponse.code() >= 400) {\n                    if (!subscriber.isUnsubscribed()) {\n                        subscriber.onError(Utils.getErrorForServerResponse(new ANError(okHttpResponse),\n                                request, okHttpResponse.code()));\n                    }\n                } else {\n                    ANResponse<T> response = request.parseResponse(okHttpResponse);\n                    if (!response.isSuccess()) {\n                        if (!subscriber.isUnsubscribed()) {\n                            subscriber.onError(response.getError());\n                        }\n                    } else {\n                        if (!subscriber.isUnsubscribed()) {\n                            subscriber.onNext(response.getResult());\n                        }\n                        if (!subscriber.isUnsubscribed()) {\n                            subscriber.onCompleted();\n                        }\n                    }\n                }\n            } catch (IOException ioe) {\n                if (!subscriber.isUnsubscribed()) {\n                    subscriber.onError(Utils.getErrorForConnection(new ANError(ioe)));\n                }\n            } catch (Exception e) {\n                Exceptions.throwIfFatal(e);\n                if (!subscriber.isUnsubscribed()) {\n                    subscriber.onError(Utils.getErrorForConnection(new ANError(e)));\n                }\n            } finally {\n                SourceCloseUtil.close(okHttpResponse, request);\n            }\n        }\n\n        @Override\n        public void unsubscribe() {\n            if (request.getCall() != null) {\n                request.getCall().cancel();\n            }\n        }\n\n        @Override\n        public boolean isUnsubscribed() {\n            return request.getCall() != null && request.getCall().isCanceled();\n        }\n    }\n\n\n}\n"
  },
  {
    "path": "rx-android-networking/src/main/res/values/strings.xml",
    "content": "<!--\n  ~    Copyright (C) 2016 Amit Shekhar\n  ~    Copyright (C) 2011 Android Open Source Project\n  ~\n  ~    Licensed under the Apache License, Version 2.0 (the \"License\");\n  ~    you may not use this file except in compliance with the License.\n  ~    You may obtain a copy of the License at\n  ~\n  ~        http://www.apache.org/licenses/LICENSE-2.0\n  ~\n  ~    Unless required by applicable law or agreed to in writing, software\n  ~    distributed under the License is distributed on an \"AS IS\" BASIS,\n  ~    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  ~    See the License for the specific language governing permissions and\n  ~    limitations under the License.\n  -->\n\n<resources>\n    <string name=\"app_name\">rxandroidnetworking</string>\n</resources>\n"
  },
  {
    "path": "rx-android-networking/src/test/java/com/rxandroidnetworking/ExampleUnitTest.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.rxandroidnetworking;\n\nimport org.junit.Test;\n\nimport static org.junit.Assert.*;\n\n/**\n * To work on unit tests, switch the Test Artifact in the Build Variants view.\n */\npublic class ExampleUnitTest {\n    @Test\n    public void addition_isCorrect() throws Exception {\n        assertEquals(4, 2 + 2);\n    }\n}"
  },
  {
    "path": "rx2-android-networking/.gitignore",
    "content": "/build\n"
  },
  {
    "path": "rx2-android-networking/build.gradle",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\napply plugin: 'com.android.library'\n\nandroid {\n    compileSdkVersion rootProject.ext.compileSdkVersion\n    buildToolsVersion rootProject.ext.buildToolsVersion\n\n    defaultConfig {\n        minSdkVersion rootProject.ext.minSdkVersion\n        targetSdkVersion rootProject.ext.targetSdkVersion\n        versionCode 1\n        versionName \"1.0\"\n    }\n    buildTypes {\n        release {\n            minifyEnabled false\n            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'\n        }\n    }\n}\n\ndependencies {\n    api fileTree(dir: 'libs', include: ['*.jar'])\n    testImplementation \"junit:junit:$rootProject.ext.jUnitVersion\"\n    androidTestImplementation \"com.squareup.okhttp3:mockwebserver:$rootProject.ext.mockWebServerVersion\"\n    api \"io.reactivex.rxjava2:rxandroid:$rootProject.ext.rxJava2AndroidVersion\"\n    api \"io.reactivex.rxjava2:rxjava:$rootProject.ext.rxJava2Version\"\n    api project(':android-networking')\n}"
  },
  {
    "path": "rx2-android-networking/proguard-rules.pro",
    "content": "# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in /Users/amitshekhar/Library/Android/sdk/tools/proguard/proguard-android.txt\n# You can edit the include path and order by changing the proguardFiles\n# directive in build.gradle.\n#\n# For more details, see\n#   http://developer.android.com/guide/developing/tools/proguard.html\n\n# Add any project specific keep options here:\n\n# If your project uses WebView with JS, uncomment the following\n# and specify the fully qualified class name to the JavaScript interface\n# class:\n#-keepclassmembers class fqcn.of.javascript.interface.for.webview {\n#   public *;\n#}\n"
  },
  {
    "path": "rx2-android-networking/src/androidTest/AndroidManifest.xml",
    "content": "<!--\n  ~ /*\n  ~  *    Copyright (C) 2016 Amit Shekhar\n  ~  *    Copyright (C) 2011 Android Open Source Project\n  ~  *\n  ~  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n  ~  *    you may not use this file except in compliance with the License.\n  ~  *    You may obtain a copy of the License at\n  ~  *\n  ~  *        http://www.apache.org/licenses/LICENSE-2.0\n  ~  *\n  ~  *    Unless required by applicable law or agreed to in writing, software\n  ~  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n  ~  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  ~  *    See the License for the specific language governing permissions and\n  ~  *    limitations under the License.\n  ~  */\n  -->\n\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    package=\"com.rx2androidnetworking\">\n\n    <uses-permission android:name=\"android.permission.INTERNET\" />\n    <uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\"></uses-permission>\n\n</manifest>\n"
  },
  {
    "path": "rx2-android-networking/src/androidTest/java/com/rx2androidnetworking/Rx2GetJSONApiTest.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.rx2androidnetworking;\n\nimport android.app.Application;\nimport android.test.ApplicationTestCase;\n\nimport com.androidnetworking.common.ANConstants;\nimport com.androidnetworking.error.ANError;\n\nimport org.json.JSONArray;\nimport org.json.JSONException;\nimport org.json.JSONObject;\nimport org.junit.Rule;\n\nimport java.util.concurrent.CountDownLatch;\nimport java.util.concurrent.atomic.AtomicReference;\n\nimport io.reactivex.Observer;\nimport io.reactivex.SingleObserver;\nimport io.reactivex.android.schedulers.AndroidSchedulers;\nimport io.reactivex.annotations.NonNull;\nimport io.reactivex.disposables.Disposable;\nimport io.reactivex.schedulers.Schedulers;\nimport okhttp3.mockwebserver.MockResponse;\nimport okhttp3.mockwebserver.MockWebServer;\n\nimport static java.util.concurrent.TimeUnit.SECONDS;\n\n/**\n * Created by amitshekhar on 30/04/17.\n */\n\npublic class Rx2GetJSONApiTest extends ApplicationTestCase<Application> {\n\n    @Rule\n    public final MockWebServer server = new MockWebServer();\n\n    public Rx2GetJSONApiTest() {\n        super(Application.class);\n    }\n\n    @Override\n    public void setUp() throws Exception {\n        super.setUp();\n        createApplication();\n    }\n\n    public void testJSONObjectGetRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isCompletedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(2);\n\n        Rx2AndroidNetworking.get(server.url(\"/\").toString())\n                .build()\n                .getJSONObjectObservable()\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new Observer<JSONObject>() {\n                    @Override\n                    public void onSubscribe(Disposable d) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onNext(JSONObject response) {\n                        try {\n                            firstNameRef.set(response.getString(\"firstName\"));\n                            lastNameRef.set(response.getString(\"lastName\"));\n                            latch.countDown();\n                        } catch (JSONException e) {\n                            assertTrue(false);\n                        }\n                    }\n\n                    @Override\n                    public void onError(Throwable e) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onComplete() {\n                        isCompletedRef.set(true);\n                        latch.countDown();\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n        assertTrue(isCompletedRef.get());\n\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testJSONObjectSingleGetRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        Rx2AndroidNetworking.get(server.url(\"/\").toString())\n                .build()\n                .getJSONObjectSingle()\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new SingleObserver<JSONObject>() {\n                    @Override\n                    public void onSubscribe(@NonNull Disposable disposable) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onSuccess(@NonNull JSONObject response) {\n                        try {\n                            firstNameRef.set(response.getString(\"firstName\"));\n                            lastNameRef.set(response.getString(\"lastName\"));\n                            latch.countDown();\n                        } catch (JSONException e) {\n                            assertTrue(false);\n                        }\n                    }\n\n                    @Override\n                    public void onError(@NonNull Throwable throwable) {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testJSONObjectGetRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        Rx2AndroidNetworking.get(server.url(\"/\").toString())\n                .build()\n                .getJSONObjectObservable()\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new Observer<JSONObject>() {\n                    @Override\n                    public void onSubscribe(Disposable d) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onNext(JSONObject response) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(Throwable e) {\n                        ANError anError = (ANError) e;\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n\n                    @Override\n                    public void onComplete() {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n\n    }\n\n    public void testJSONObjectSingleGetRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        Rx2AndroidNetworking.get(server.url(\"/\").toString())\n                .build()\n                .getJSONObjectSingle()\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new SingleObserver<JSONObject>() {\n                    @Override\n                    public void onSubscribe(@NonNull Disposable disposable) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onSuccess(@NonNull JSONObject response) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(@NonNull Throwable e) {\n                        ANError anError = (ANError) e;\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n\n    }\n\n    public void testJSONArrayGetRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"[{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}]\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isCompletedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(2);\n\n        Rx2AndroidNetworking.get(server.url(\"/\").toString())\n                .build()\n                .getJSONArrayObservable()\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new Observer<JSONArray>() {\n                    @Override\n                    public void onSubscribe(Disposable d) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onNext(JSONArray response) {\n                        try {\n                            JSONObject jsonObject = response.getJSONObject(0);\n                            firstNameRef.set(jsonObject.getString(\"firstName\"));\n                            lastNameRef.set(jsonObject.getString(\"lastName\"));\n                            latch.countDown();\n                        } catch (JSONException e) {\n                            assertTrue(false);\n                        }\n                    }\n\n                    @Override\n                    public void onError(Throwable e) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onComplete() {\n                        isCompletedRef.set(true);\n                        latch.countDown();\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n        assertTrue(isCompletedRef.get());\n\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testJSONArraySingleGetRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"[{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}]\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        Rx2AndroidNetworking.get(server.url(\"/\").toString())\n                .build()\n                .getJSONArraySingle()\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new SingleObserver<JSONArray>() {\n                    @Override\n                    public void onSubscribe(@NonNull Disposable disposable) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onSuccess(@NonNull JSONArray response) {\n                        try {\n                            JSONObject jsonObject = response.getJSONObject(0);\n                            firstNameRef.set(jsonObject.getString(\"firstName\"));\n                            lastNameRef.set(jsonObject.getString(\"lastName\"));\n                            latch.countDown();\n                        } catch (JSONException e) {\n                            assertTrue(false);\n                        }\n                    }\n\n                    @Override\n                    public void onError(@NonNull Throwable throwable) {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testJSONArrayGetRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        Rx2AndroidNetworking.get(server.url(\"/\").toString())\n                .build()\n                .getJSONArrayObservable()\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new Observer<JSONArray>() {\n                    @Override\n                    public void onSubscribe(Disposable d) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onNext(JSONArray response) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(Throwable e) {\n                        ANError anError = (ANError) e;\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n\n                    @Override\n                    public void onComplete() {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n\n    }\n\n    public void testJSONArraySingleGetRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        Rx2AndroidNetworking.get(server.url(\"/\").toString())\n                .build()\n                .getJSONArraySingle()\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new SingleObserver<JSONArray>() {\n                    @Override\n                    public void onSubscribe(@NonNull Disposable disposable) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onSuccess(@NonNull JSONArray response) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(@NonNull Throwable e) {\n                        ANError anError = (ANError) e;\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n\n    }\n\n}\n"
  },
  {
    "path": "rx2-android-networking/src/androidTest/java/com/rx2androidnetworking/Rx2GetObjectApiTest.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.rx2androidnetworking;\n\nimport android.app.Application;\nimport android.test.ApplicationTestCase;\n\nimport com.androidnetworking.common.ANConstants;\nimport com.androidnetworking.error.ANError;\nimport com.rx2androidnetworking.model.User;\n\nimport org.junit.Rule;\n\nimport java.util.List;\nimport java.util.concurrent.CountDownLatch;\nimport java.util.concurrent.atomic.AtomicReference;\n\nimport io.reactivex.Observer;\nimport io.reactivex.SingleObserver;\nimport io.reactivex.android.schedulers.AndroidSchedulers;\nimport io.reactivex.annotations.NonNull;\nimport io.reactivex.disposables.Disposable;\nimport io.reactivex.schedulers.Schedulers;\nimport okhttp3.mockwebserver.MockResponse;\nimport okhttp3.mockwebserver.MockWebServer;\n\nimport static java.util.concurrent.TimeUnit.SECONDS;\n\n/**\n * Created by amitshekhar on 26/04/17.\n */\n\npublic class Rx2GetObjectApiTest extends ApplicationTestCase<Application> {\n\n    @Rule\n    public final MockWebServer server = new MockWebServer();\n\n    public Rx2GetObjectApiTest() {\n        super(Application.class);\n    }\n\n    @Override\n    public void setUp() throws Exception {\n        super.setUp();\n        createApplication();\n    }\n\n    public void testObjectGetRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isCompletedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(2);\n\n        Rx2AndroidNetworking.get(server.url(\"/\").toString())\n                .build()\n                .getObjectObservable(User.class)\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new Observer<User>() {\n                    @Override\n                    public void onSubscribe(Disposable d) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onNext(User user) {\n                        firstNameRef.set(user.firstName);\n                        lastNameRef.set(user.lastName);\n                        latch.countDown();\n                    }\n\n                    @Override\n                    public void onError(Throwable e) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onComplete() {\n                        isCompletedRef.set(true);\n                        latch.countDown();\n                    }\n                });\n\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n        assertTrue(isCompletedRef.get());\n\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testObjectSingleGetRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        Rx2AndroidNetworking.get(server.url(\"/\").toString())\n                .build()\n                .getObjectSingle(User.class)\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new SingleObserver<User>() {\n                    @Override\n                    public void onSubscribe(@NonNull Disposable disposable) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onSuccess(@NonNull User user) {\n                        firstNameRef.set(user.firstName);\n                        lastNameRef.set(user.lastName);\n                        latch.countDown();\n                    }\n\n                    @Override\n                    public void onError(@NonNull Throwable throwable) {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testObjectGetRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        Rx2AndroidNetworking.get(server.url(\"/\").toString())\n                .build()\n                .getObjectObservable(User.class)\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new Observer<User>() {\n                    @Override\n                    public void onSubscribe(Disposable d) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onNext(User user) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(Throwable e) {\n                        ANError anError = (ANError) e;\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n\n                    @Override\n                    public void onComplete() {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n\n    }\n\n    public void testObjectSingleGetRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        Rx2AndroidNetworking.get(server.url(\"/\").toString())\n                .build()\n                .getObjectSingle(User.class)\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new SingleObserver<User>() {\n                    @Override\n                    public void onSubscribe(@NonNull Disposable disposable) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onSuccess(@NonNull User user) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(@NonNull Throwable e) {\n                        ANError anError = (ANError) e;\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n\n    }\n\n    public void testObjectListGetRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"[{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}]\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isCompletedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(2);\n\n        Rx2AndroidNetworking.get(server.url(\"/\").toString())\n                .build()\n                .getObjectListObservable(User.class)\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new Observer<List<User>>() {\n                    @Override\n                    public void onSubscribe(Disposable d) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onNext(List<User> userList) {\n                        firstNameRef.set(userList.get(0).firstName);\n                        lastNameRef.set(userList.get(0).lastName);\n                        latch.countDown();\n                    }\n\n                    @Override\n                    public void onError(Throwable e) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onComplete() {\n                        isCompletedRef.set(true);\n                        latch.countDown();\n                    }\n                });\n\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n        assertTrue(isCompletedRef.get());\n\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testObjectListSingleGetRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"[{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}]\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        Rx2AndroidNetworking.get(server.url(\"/\").toString())\n                .build()\n                .getObjectListSingle(User.class)\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new SingleObserver<List<User>>() {\n                    @Override\n                    public void onSubscribe(@NonNull Disposable disposable) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onSuccess(@NonNull List<User> users) {\n                        firstNameRef.set(users.get(0).firstName);\n                        lastNameRef.set(users.get(0).lastName);\n                        latch.countDown();\n                    }\n\n                    @Override\n                    public void onError(@NonNull Throwable throwable) {\n                        assertTrue(false);\n                    }\n                });\n\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testObjectListGetRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        Rx2AndroidNetworking.get(server.url(\"/\").toString())\n                .build()\n                .getObjectListObservable(User.class)\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new Observer<List<User>>() {\n                    @Override\n                    public void onSubscribe(Disposable d) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onNext(List<User> userList) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(Throwable e) {\n                        ANError anError = (ANError) e;\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n\n                    @Override\n                    public void onComplete() {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n\n    }\n\n    public void testObjectListSingleGetRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        Rx2AndroidNetworking.get(server.url(\"/\").toString())\n                .build()\n                .getObjectListSingle(User.class)\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new SingleObserver<List<User>>() {\n                    @Override\n                    public void onSubscribe(@NonNull Disposable disposable) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onSuccess(@NonNull List<User> users) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(@NonNull Throwable e) {\n                        ANError anError = (ANError) e;\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n\n    }\n}\n"
  },
  {
    "path": "rx2-android-networking/src/androidTest/java/com/rx2androidnetworking/Rx2GetStringApiTest.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.rx2androidnetworking;\n\nimport android.app.Application;\nimport android.test.ApplicationTestCase;\n\nimport com.androidnetworking.common.ANConstants;\nimport com.androidnetworking.error.ANError;\n\nimport org.junit.Rule;\n\nimport java.util.concurrent.CountDownLatch;\nimport java.util.concurrent.atomic.AtomicReference;\n\nimport io.reactivex.Observer;\nimport io.reactivex.SingleObserver;\nimport io.reactivex.android.schedulers.AndroidSchedulers;\nimport io.reactivex.annotations.NonNull;\nimport io.reactivex.disposables.Disposable;\nimport io.reactivex.schedulers.Schedulers;\nimport okhttp3.mockwebserver.MockResponse;\nimport okhttp3.mockwebserver.MockWebServer;\n\nimport static java.util.concurrent.TimeUnit.SECONDS;\n\n/**\n * Created by amitshekhar on 22/04/17.\n */\n\npublic class Rx2GetStringApiTest extends ApplicationTestCase<Application> {\n\n    @Rule\n    public final MockWebServer server = new MockWebServer();\n\n    public Rx2GetStringApiTest() {\n        super(Application.class);\n    }\n\n    @Override\n    public void setUp() throws Exception {\n        super.setUp();\n        createApplication();\n    }\n\n    public void testStringGetRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"data\"));\n\n        final AtomicReference<String> responseRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isCompletedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(2);\n\n        Rx2AndroidNetworking.get(server.url(\"/\").toString())\n                .build()\n                .getStringObservable()\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new Observer<String>() {\n                    @Override\n                    public void onSubscribe(Disposable d) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onNext(String response) {\n                        responseRef.set(response);\n                        latch.countDown();\n                    }\n\n                    @Override\n                    public void onError(Throwable e) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onComplete() {\n                        isCompletedRef.set(true);\n                        latch.countDown();\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n        assertTrue(isCompletedRef.get());\n\n        assertEquals(\"data\", responseRef.get());\n    }\n\n    public void testStringSingleGetRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"data\"));\n\n        final AtomicReference<String> responseRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        Rx2AndroidNetworking.get(server.url(\"/\").toString())\n                .build()\n                .getStringSingle()\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new SingleObserver<String>() {\n                    @Override\n                    public void onSubscribe(@NonNull Disposable disposable) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onSuccess(@NonNull String response) {\n                        responseRef.set(response);\n                        latch.countDown();\n                    }\n\n                    @Override\n                    public void onError(@NonNull Throwable throwable) {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n\n        assertEquals(\"data\", responseRef.get());\n    }\n\n    public void testStringGetRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        Rx2AndroidNetworking.get(server.url(\"/\").toString())\n                .build()\n                .getStringObservable()\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new Observer<String>() {\n                    @Override\n                    public void onSubscribe(Disposable d) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onNext(String response) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(Throwable e) {\n                        ANError anError = (ANError) e;\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n\n                    @Override\n                    public void onComplete() {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n\n    }\n\n    public void testStringGetSingleRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        Rx2AndroidNetworking.get(server.url(\"/\").toString())\n                .build()\n                .getStringSingle()\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new SingleObserver<String>() {\n                    @Override\n                    public void onSubscribe(@NonNull Disposable disposable) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onSuccess(@NonNull String s) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(@NonNull Throwable e) {\n                        ANError anError = (ANError) e;\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n\n    }\n\n}\n"
  },
  {
    "path": "rx2-android-networking/src/androidTest/java/com/rx2androidnetworking/Rx2MultipartJSONApiTest.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.rx2androidnetworking;\n\nimport android.app.Application;\nimport android.test.ApplicationTestCase;\n\nimport com.androidnetworking.common.ANConstants;\nimport com.androidnetworking.error.ANError;\n\nimport org.json.JSONArray;\nimport org.json.JSONException;\nimport org.json.JSONObject;\nimport org.junit.Rule;\n\nimport java.util.concurrent.CountDownLatch;\nimport java.util.concurrent.atomic.AtomicReference;\n\nimport io.reactivex.Observer;\nimport io.reactivex.SingleObserver;\nimport io.reactivex.android.schedulers.AndroidSchedulers;\nimport io.reactivex.annotations.NonNull;\nimport io.reactivex.disposables.Disposable;\nimport io.reactivex.schedulers.Schedulers;\nimport okhttp3.mockwebserver.MockResponse;\nimport okhttp3.mockwebserver.MockWebServer;\n\nimport static java.util.concurrent.TimeUnit.SECONDS;\n\n/**\n * Created by amitshekhar on 03/05/17.\n */\n\npublic class Rx2MultipartJSONApiTest extends ApplicationTestCase<Application> {\n\n    @Rule\n    public final MockWebServer server = new MockWebServer();\n\n    public Rx2MultipartJSONApiTest() {\n        super(Application.class);\n    }\n\n    @Override\n    public void setUp() throws Exception {\n        super.setUp();\n        createApplication();\n    }\n\n    public void testJSONObjectMultipartRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isCompletedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(2);\n\n        Rx2AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .build()\n                .getJSONObjectObservable()\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new Observer<JSONObject>() {\n                    @Override\n                    public void onSubscribe(Disposable d) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onNext(JSONObject response) {\n                        try {\n                            firstNameRef.set(response.getString(\"firstName\"));\n                            lastNameRef.set(response.getString(\"lastName\"));\n                            latch.countDown();\n                        } catch (JSONException e) {\n                            assertTrue(false);\n                        }\n                    }\n\n                    @Override\n                    public void onError(Throwable e) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onComplete() {\n                        isCompletedRef.set(true);\n                        latch.countDown();\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n        assertTrue(isCompletedRef.get());\n\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testJSONObjectSingleMultipartRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        Rx2AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .build()\n                .getJSONObjectSingle()\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new SingleObserver<JSONObject>() {\n                    @Override\n                    public void onSubscribe(@NonNull Disposable disposable) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onSuccess(@NonNull JSONObject response) {\n                        try {\n                            firstNameRef.set(response.getString(\"firstName\"));\n                            lastNameRef.set(response.getString(\"lastName\"));\n                            latch.countDown();\n                        } catch (JSONException e) {\n                            assertTrue(false);\n                        }\n                    }\n\n                    @Override\n                    public void onError(@NonNull Throwable throwable) {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testJSONObjectMultipartRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        Rx2AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .build()\n                .getJSONObjectObservable()\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new Observer<JSONObject>() {\n                    @Override\n                    public void onSubscribe(Disposable d) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onNext(JSONObject response) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(Throwable e) {\n                        ANError anError = (ANError) e;\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n\n                    @Override\n                    public void onComplete() {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n\n    }\n\n    public void testJSONObjectSingleMultipartRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        Rx2AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .build()\n                .getJSONObjectSingle()\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new SingleObserver<JSONObject>() {\n                    @Override\n                    public void onSubscribe(@NonNull Disposable disposable) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onSuccess(@NonNull JSONObject jsonObject) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(@NonNull Throwable e) {\n                        ANError anError = (ANError) e;\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n\n    }\n\n    public void testJSONArrayMultipartRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"[{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}]\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isCompletedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(2);\n\n        Rx2AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .build()\n                .getJSONArrayObservable()\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new Observer<JSONArray>() {\n                    @Override\n                    public void onSubscribe(Disposable d) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onNext(JSONArray response) {\n                        try {\n                            JSONObject jsonObject = response.getJSONObject(0);\n                            firstNameRef.set(jsonObject.getString(\"firstName\"));\n                            lastNameRef.set(jsonObject.getString(\"lastName\"));\n                            latch.countDown();\n                        } catch (JSONException e) {\n                            assertTrue(false);\n                        }\n                    }\n\n                    @Override\n                    public void onError(Throwable e) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onComplete() {\n                        isCompletedRef.set(true);\n                        latch.countDown();\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n        assertTrue(isCompletedRef.get());\n\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testJSONArraySingleMultipartRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"[{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}]\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        Rx2AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .build()\n                .getJSONArraySingle()\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new SingleObserver<JSONArray>() {\n                    @Override\n                    public void onSubscribe(@NonNull Disposable disposable) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onSuccess(@NonNull JSONArray response) {\n                        try {\n                            JSONObject jsonObject = response.getJSONObject(0);\n                            firstNameRef.set(jsonObject.getString(\"firstName\"));\n                            lastNameRef.set(jsonObject.getString(\"lastName\"));\n                            latch.countDown();\n                        } catch (JSONException e) {\n                            assertTrue(false);\n                        }\n                    }\n\n                    @Override\n                    public void onError(@NonNull Throwable throwable) {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testJSONArrayMultipartRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        Rx2AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .build()\n                .getJSONArrayObservable()\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new Observer<JSONArray>() {\n                    @Override\n                    public void onSubscribe(Disposable d) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onNext(JSONArray response) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(Throwable e) {\n                        ANError anError = (ANError) e;\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n\n                    @Override\n                    public void onComplete() {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n\n    }\n\n    public void testJSONArraySingleMultipartRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        Rx2AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .build()\n                .getJSONArraySingle()\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new SingleObserver<JSONArray>() {\n                    @Override\n                    public void onSubscribe(@NonNull Disposable disposable) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onSuccess(@NonNull JSONArray jsonArray) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(@NonNull Throwable e) {\n                        ANError anError = (ANError) e;\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n\n    }\n\n}\n"
  },
  {
    "path": "rx2-android-networking/src/androidTest/java/com/rx2androidnetworking/Rx2MultipartObjectApiTest.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.rx2androidnetworking;\n\nimport android.app.Application;\nimport android.test.ApplicationTestCase;\n\nimport com.androidnetworking.common.ANConstants;\nimport com.androidnetworking.error.ANError;\nimport com.rx2androidnetworking.model.User;\n\nimport org.junit.Rule;\n\nimport java.util.List;\nimport java.util.concurrent.CountDownLatch;\nimport java.util.concurrent.atomic.AtomicReference;\n\nimport io.reactivex.Observer;\nimport io.reactivex.SingleObserver;\nimport io.reactivex.android.schedulers.AndroidSchedulers;\nimport io.reactivex.annotations.NonNull;\nimport io.reactivex.disposables.Disposable;\nimport io.reactivex.schedulers.Schedulers;\nimport okhttp3.mockwebserver.MockResponse;\nimport okhttp3.mockwebserver.MockWebServer;\n\nimport static java.util.concurrent.TimeUnit.SECONDS;\n\n/**\n * Created by amitshekhar on 29/04/17.\n */\n\npublic class Rx2MultipartObjectApiTest extends ApplicationTestCase<Application> {\n\n    @Rule\n    public final MockWebServer server = new MockWebServer();\n\n    public Rx2MultipartObjectApiTest() {\n        super(Application.class);\n    }\n\n    @Override\n    public void setUp() throws Exception {\n        super.setUp();\n        createApplication();\n    }\n\n    public void testObjectMultipartRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isCompletedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(2);\n\n        Rx2AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .build()\n                .getObjectObservable(User.class)\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new Observer<User>() {\n                    @Override\n                    public void onSubscribe(Disposable d) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onNext(User user) {\n                        firstNameRef.set(user.firstName);\n                        lastNameRef.set(user.lastName);\n                        latch.countDown();\n                    }\n\n                    @Override\n                    public void onError(Throwable e) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onComplete() {\n                        isCompletedRef.set(true);\n                        latch.countDown();\n                    }\n                });\n\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n        assertTrue(isCompletedRef.get());\n\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testObjectSingleMultipartRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        Rx2AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .build()\n                .getObjectSingle(User.class)\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new SingleObserver<User>() {\n                    @Override\n                    public void onSubscribe(@NonNull Disposable disposable) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onSuccess(@NonNull User user) {\n                        firstNameRef.set(user.firstName);\n                        lastNameRef.set(user.lastName);\n                        latch.countDown();\n                    }\n\n                    @Override\n                    public void onError(@NonNull Throwable throwable) {\n                        assertTrue(false);\n                    }\n                });\n\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testObjectMultipartRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        Rx2AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .build()\n                .getObjectObservable(User.class)\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new Observer<User>() {\n                    @Override\n                    public void onSubscribe(Disposable d) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onNext(User user) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(Throwable e) {\n                        ANError anError = (ANError) e;\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n\n                    @Override\n                    public void onComplete() {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n\n    }\n\n    public void testObjectSingleMultipartRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        Rx2AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .build()\n                .getObjectSingle(User.class)\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new SingleObserver<User>() {\n                    @Override\n                    public void onSubscribe(@NonNull Disposable disposable) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onSuccess(@NonNull User user) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(@NonNull Throwable e) {\n                        ANError anError = (ANError) e;\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n\n    }\n\n    public void testObjectListMultipartRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"[{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}]\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isCompletedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(2);\n\n        Rx2AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .build()\n                .getObjectListObservable(User.class)\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new Observer<List<User>>() {\n                    @Override\n                    public void onSubscribe(Disposable d) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onNext(List<User> userList) {\n                        firstNameRef.set(userList.get(0).firstName);\n                        lastNameRef.set(userList.get(0).lastName);\n                        latch.countDown();\n                    }\n\n                    @Override\n                    public void onError(Throwable e) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onComplete() {\n                        isCompletedRef.set(true);\n                        latch.countDown();\n                    }\n                });\n\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n        assertTrue(isCompletedRef.get());\n\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testObjectListSingleMultipartRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"[{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}]\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        Rx2AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .build()\n                .getObjectListSingle(User.class)\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new SingleObserver<List<User>>() {\n                    @Override\n                    public void onSubscribe(@NonNull Disposable disposable) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onSuccess(@NonNull List<User> userList) {\n                        firstNameRef.set(userList.get(0).firstName);\n                        lastNameRef.set(userList.get(0).lastName);\n                        latch.countDown();\n                    }\n\n                    @Override\n                    public void onError(@NonNull Throwable throwable) {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testObjectListMultipartRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        Rx2AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .build()\n                .getObjectListObservable(User.class)\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new Observer<List<User>>() {\n                    @Override\n                    public void onSubscribe(Disposable d) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onNext(List<User> userList) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(Throwable e) {\n                        ANError anError = (ANError) e;\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n\n                    @Override\n                    public void onComplete() {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n\n    }\n\n    public void testObjectListSingleMultipartRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        Rx2AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .build()\n                .getObjectListSingle(User.class)\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new SingleObserver<List<User>>() {\n                    @Override\n                    public void onSubscribe(@NonNull Disposable disposable) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onSuccess(@NonNull List<User> users) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(@NonNull Throwable e) {\n                        ANError anError = (ANError) e;\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n\n    }\n}\n"
  },
  {
    "path": "rx2-android-networking/src/androidTest/java/com/rx2androidnetworking/Rx2MultipartStringApiTest.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.rx2androidnetworking;\n\nimport android.app.Application;\nimport android.test.ApplicationTestCase;\n\nimport com.androidnetworking.common.ANConstants;\nimport com.androidnetworking.error.ANError;\n\nimport org.junit.Rule;\n\nimport java.util.concurrent.CountDownLatch;\nimport java.util.concurrent.atomic.AtomicReference;\n\nimport io.reactivex.Observer;\nimport io.reactivex.SingleObserver;\nimport io.reactivex.android.schedulers.AndroidSchedulers;\nimport io.reactivex.annotations.NonNull;\nimport io.reactivex.disposables.Disposable;\nimport io.reactivex.schedulers.Schedulers;\nimport okhttp3.mockwebserver.MockResponse;\nimport okhttp3.mockwebserver.MockWebServer;\n\nimport static java.util.concurrent.TimeUnit.SECONDS;\n\n/**\n * Created by amitshekhar on 25/04/17.\n */\n\npublic class Rx2MultipartStringApiTest extends ApplicationTestCase<Application> {\n\n    @Rule\n    public final MockWebServer server = new MockWebServer();\n\n    public Rx2MultipartStringApiTest() {\n        super(Application.class);\n    }\n\n    @Override\n    public void setUp() throws Exception {\n        super.setUp();\n        createApplication();\n    }\n\n    public void testStringMultipartRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"data\"));\n\n        final AtomicReference<String> responseRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isCompletedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(2);\n\n        Rx2AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .build()\n                .getStringObservable()\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new Observer<String>() {\n                    @Override\n                    public void onSubscribe(Disposable d) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onNext(String response) {\n                        responseRef.set(response);\n                        latch.countDown();\n                    }\n\n                    @Override\n                    public void onError(Throwable e) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onComplete() {\n                        isCompletedRef.set(true);\n                        latch.countDown();\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n        assertTrue(isCompletedRef.get());\n\n        assertEquals(\"data\", responseRef.get());\n    }\n\n    public void testStringSingleMultipartRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"data\"));\n\n        final AtomicReference<String> responseRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        Rx2AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .build()\n                .getStringSingle()\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new SingleObserver<String>() {\n                    @Override\n                    public void onSubscribe(@NonNull Disposable disposable) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onSuccess(@NonNull String response) {\n                        responseRef.set(response);\n                        latch.countDown();\n                    }\n\n                    @Override\n                    public void onError(@NonNull Throwable throwable) {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n\n        assertEquals(\"data\", responseRef.get());\n    }\n\n    public void testStringMultipartRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        Rx2AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .build()\n                .getStringObservable()\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new Observer<String>() {\n                    @Override\n                    public void onSubscribe(Disposable d) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onNext(String response) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(Throwable e) {\n                        ANError anError = (ANError) e;\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n\n                    @Override\n                    public void onComplete() {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n\n    }\n\n    public void testStringSingleMultipartRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        Rx2AndroidNetworking.upload(server.url(\"/\").toString())\n                .addMultipartParameter(\"key\", \"value\")\n                .build()\n                .getStringSingle()\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new SingleObserver<String>() {\n                    @Override\n                    public void onSubscribe(@NonNull Disposable disposable) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onSuccess(@NonNull String s) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(@NonNull Throwable e) {\n                        ANError anError = (ANError) e;\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n\n    }\n\n}"
  },
  {
    "path": "rx2-android-networking/src/androidTest/java/com/rx2androidnetworking/Rx2PostJSONApiTest.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.rx2androidnetworking;\n\nimport android.app.Application;\nimport android.test.ApplicationTestCase;\n\nimport com.androidnetworking.common.ANConstants;\nimport com.androidnetworking.error.ANError;\n\nimport org.json.JSONArray;\nimport org.json.JSONException;\nimport org.json.JSONObject;\nimport org.junit.Rule;\n\nimport java.util.concurrent.CountDownLatch;\nimport java.util.concurrent.atomic.AtomicReference;\n\nimport io.reactivex.Observer;\nimport io.reactivex.SingleObserver;\nimport io.reactivex.android.schedulers.AndroidSchedulers;\nimport io.reactivex.annotations.NonNull;\nimport io.reactivex.disposables.Disposable;\nimport io.reactivex.schedulers.Schedulers;\nimport okhttp3.mockwebserver.MockResponse;\nimport okhttp3.mockwebserver.MockWebServer;\n\nimport static java.util.concurrent.TimeUnit.SECONDS;\n\n/**\n * Created by amitshekhar on 02/05/17.\n */\n\npublic class Rx2PostJSONApiTest extends ApplicationTestCase<Application> {\n\n    @Rule\n    public final MockWebServer server = new MockWebServer();\n\n    public Rx2PostJSONApiTest() {\n        super(Application.class);\n    }\n\n    @Override\n    public void setUp() throws Exception {\n        super.setUp();\n        createApplication();\n    }\n\n    public void testJSONObjectPostRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isCompletedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(2);\n\n        Rx2AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .build()\n                .getJSONObjectObservable()\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new Observer<JSONObject>() {\n                    @Override\n                    public void onSubscribe(Disposable d) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onNext(JSONObject response) {\n                        try {\n                            firstNameRef.set(response.getString(\"firstName\"));\n                            lastNameRef.set(response.getString(\"lastName\"));\n                            latch.countDown();\n                        } catch (JSONException e) {\n                            assertTrue(false);\n                        }\n                    }\n\n                    @Override\n                    public void onError(Throwable e) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onComplete() {\n                        isCompletedRef.set(true);\n                        latch.countDown();\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n        assertTrue(isCompletedRef.get());\n\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testJSONObjectSinglePostRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        Rx2AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .build()\n                .getJSONObjectSingle()\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new SingleObserver<JSONObject>() {\n                    @Override\n                    public void onSubscribe(@NonNull Disposable disposable) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onSuccess(@NonNull JSONObject response) {\n                        try {\n                            firstNameRef.set(response.getString(\"firstName\"));\n                            lastNameRef.set(response.getString(\"lastName\"));\n                            latch.countDown();\n                        } catch (JSONException e) {\n                            assertTrue(false);\n                        }\n                    }\n\n                    @Override\n                    public void onError(@NonNull Throwable throwable) {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testJSONObjectPostRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        Rx2AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .build()\n                .getJSONObjectObservable()\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new Observer<JSONObject>() {\n                    @Override\n                    public void onSubscribe(Disposable d) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onNext(JSONObject response) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(Throwable e) {\n                        ANError anError = (ANError) e;\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n\n                    @Override\n                    public void onComplete() {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n\n    }\n\n    public void testJSONObjectSinglePostRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        Rx2AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .build()\n                .getJSONObjectSingle()\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new SingleObserver<JSONObject>() {\n                    @Override\n                    public void onSubscribe(@NonNull Disposable disposable) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onSuccess(@NonNull JSONObject jsonObject) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(@NonNull Throwable e) {\n                        ANError anError = (ANError) e;\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n\n    }\n\n    public void testJSONArrayPostRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"[{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}]\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isCompletedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(2);\n\n        Rx2AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .build()\n                .getJSONArrayObservable()\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new Observer<JSONArray>() {\n                    @Override\n                    public void onSubscribe(Disposable d) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onNext(JSONArray response) {\n                        try {\n                            JSONObject jsonObject = response.getJSONObject(0);\n                            firstNameRef.set(jsonObject.getString(\"firstName\"));\n                            lastNameRef.set(jsonObject.getString(\"lastName\"));\n                            latch.countDown();\n                        } catch (JSONException e) {\n                            assertTrue(false);\n                        }\n                    }\n\n                    @Override\n                    public void onError(Throwable e) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onComplete() {\n                        isCompletedRef.set(true);\n                        latch.countDown();\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n        assertTrue(isCompletedRef.get());\n\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testJSONArraySinglePostRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"[{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}]\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        Rx2AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .build()\n                .getJSONArraySingle()\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new SingleObserver<JSONArray>() {\n                    @Override\n                    public void onSubscribe(@NonNull Disposable disposable) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onSuccess(@NonNull JSONArray response) {\n                        try {\n                            JSONObject jsonObject = response.getJSONObject(0);\n                            firstNameRef.set(jsonObject.getString(\"firstName\"));\n                            lastNameRef.set(jsonObject.getString(\"lastName\"));\n                            latch.countDown();\n                        } catch (JSONException e) {\n                            assertTrue(false);\n                        }\n                    }\n\n                    @Override\n                    public void onError(@NonNull Throwable throwable) {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testJSONArrayPostRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        Rx2AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .build()\n                .getJSONArrayObservable()\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new Observer<JSONArray>() {\n                    @Override\n                    public void onSubscribe(Disposable d) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onNext(JSONArray response) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(Throwable e) {\n                        ANError anError = (ANError) e;\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n\n                    @Override\n                    public void onComplete() {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n\n    }\n\n    public void testJSONArraySinglePostRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        Rx2AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .build()\n                .getJSONArraySingle()\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new SingleObserver<JSONArray>() {\n                    @Override\n                    public void onSubscribe(@NonNull Disposable disposable) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onSuccess(@NonNull JSONArray jsonArray) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(@NonNull Throwable e) {\n                        ANError anError = (ANError) e;\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n\n    }\n\n}\n"
  },
  {
    "path": "rx2-android-networking/src/androidTest/java/com/rx2androidnetworking/Rx2PostObjectApiTest.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.rx2androidnetworking;\n\nimport android.app.Application;\nimport android.test.ApplicationTestCase;\n\nimport com.androidnetworking.common.ANConstants;\nimport com.androidnetworking.error.ANError;\nimport com.rx2androidnetworking.model.User;\n\nimport org.junit.Rule;\n\nimport java.util.List;\nimport java.util.concurrent.CountDownLatch;\nimport java.util.concurrent.atomic.AtomicReference;\n\nimport io.reactivex.Observer;\nimport io.reactivex.SingleObserver;\nimport io.reactivex.android.schedulers.AndroidSchedulers;\nimport io.reactivex.annotations.NonNull;\nimport io.reactivex.disposables.Disposable;\nimport io.reactivex.schedulers.Schedulers;\nimport okhttp3.mockwebserver.MockResponse;\nimport okhttp3.mockwebserver.MockWebServer;\n\nimport static java.util.concurrent.TimeUnit.SECONDS;\n\n/**\n * Created by amitshekhar on 28/04/17.\n */\n\npublic class Rx2PostObjectApiTest extends ApplicationTestCase<Application> {\n\n    @Rule\n    public final MockWebServer server = new MockWebServer();\n\n    public Rx2PostObjectApiTest() {\n        super(Application.class);\n    }\n\n    @Override\n    public void setUp() throws Exception {\n        super.setUp();\n        createApplication();\n    }\n\n    public void testObjectPostRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isCompletedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(2);\n\n        Rx2AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .build()\n                .getObjectObservable(User.class)\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new Observer<User>() {\n                    @Override\n                    public void onSubscribe(Disposable d) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onNext(User user) {\n                        firstNameRef.set(user.firstName);\n                        lastNameRef.set(user.lastName);\n                        latch.countDown();\n                    }\n\n                    @Override\n                    public void onError(Throwable e) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onComplete() {\n                        isCompletedRef.set(true);\n                        latch.countDown();\n                    }\n                });\n\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n        assertTrue(isCompletedRef.get());\n\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testObjectSinglePostRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        Rx2AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .build()\n                .getObjectSingle(User.class)\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new SingleObserver<User>() {\n                    @Override\n                    public void onSubscribe(@NonNull Disposable disposable) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onSuccess(@NonNull User user) {\n                        firstNameRef.set(user.firstName);\n                        lastNameRef.set(user.lastName);\n                        latch.countDown();\n                    }\n\n                    @Override\n                    public void onError(@NonNull Throwable throwable) {\n                        assertTrue(false);\n                    }\n                });\n\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testObjectPostRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        Rx2AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .build()\n                .getObjectObservable(User.class)\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new Observer<User>() {\n                    @Override\n                    public void onSubscribe(Disposable d) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onNext(User user) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(Throwable e) {\n                        ANError anError = (ANError) e;\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n\n                    @Override\n                    public void onComplete() {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n\n    }\n\n    public void testObjectSinglePostRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        Rx2AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .build()\n                .getObjectSingle(User.class)\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new SingleObserver<User>() {\n                    @Override\n                    public void onSubscribe(@NonNull Disposable disposable) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onSuccess(@NonNull User user) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(@NonNull Throwable e) {\n                        ANError anError = (ANError) e;\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n\n    }\n\n    public void testObjectListPostRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"[{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}]\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isCompletedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(2);\n\n        Rx2AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .build()\n                .getObjectListObservable(User.class)\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new Observer<List<User>>() {\n                    @Override\n                    public void onSubscribe(Disposable d) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onNext(List<User> userList) {\n                        firstNameRef.set(userList.get(0).firstName);\n                        lastNameRef.set(userList.get(0).lastName);\n                        latch.countDown();\n                    }\n\n                    @Override\n                    public void onError(Throwable e) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onComplete() {\n                        isCompletedRef.set(true);\n                        latch.countDown();\n                    }\n                });\n\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n        assertTrue(isCompletedRef.get());\n\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testObjectListSinglePostRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"[{\\\"firstName\\\":\\\"Amit\\\", \\\"lastName\\\":\\\"Shekhar\\\"}]\"));\n\n        final AtomicReference<String> firstNameRef = new AtomicReference<>();\n        final AtomicReference<String> lastNameRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        Rx2AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .build()\n                .getObjectListSingle(User.class)\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new SingleObserver<List<User>>() {\n                    @Override\n                    public void onSubscribe(@NonNull Disposable disposable) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onSuccess(@NonNull List<User> userList) {\n                        firstNameRef.set(userList.get(0).firstName);\n                        lastNameRef.set(userList.get(0).lastName);\n                        latch.countDown();\n                    }\n\n                    @Override\n                    public void onError(@NonNull Throwable throwable) {\n                        assertTrue(false);\n                    }\n                });\n\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n\n        assertEquals(\"Amit\", firstNameRef.get());\n        assertEquals(\"Shekhar\", lastNameRef.get());\n    }\n\n    public void testObjectListPostRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        Rx2AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .build()\n                .getObjectListObservable(User.class)\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new Observer<List<User>>() {\n                    @Override\n                    public void onSubscribe(Disposable d) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onNext(List<User> userList) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(Throwable e) {\n                        ANError anError = (ANError) e;\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n\n                    @Override\n                    public void onComplete() {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n\n    }\n\n    public void testObjectListSinglePostRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        Rx2AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .build()\n                .getObjectListSingle(User.class)\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new SingleObserver<List<User>>() {\n                    @Override\n                    public void onSubscribe(@NonNull Disposable disposable) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onSuccess(@NonNull List<User> users) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(@NonNull Throwable e) {\n                        ANError anError = (ANError) e;\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n\n    }\n}\n"
  },
  {
    "path": "rx2-android-networking/src/androidTest/java/com/rx2androidnetworking/Rx2PostStringApiTest.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.rx2androidnetworking;\n\nimport android.app.Application;\nimport android.test.ApplicationTestCase;\n\nimport com.androidnetworking.common.ANConstants;\nimport com.androidnetworking.error.ANError;\n\nimport org.junit.Rule;\n\nimport java.util.concurrent.CountDownLatch;\nimport java.util.concurrent.atomic.AtomicReference;\n\nimport io.reactivex.Observer;\nimport io.reactivex.SingleObserver;\nimport io.reactivex.android.schedulers.AndroidSchedulers;\nimport io.reactivex.annotations.NonNull;\nimport io.reactivex.disposables.Disposable;\nimport io.reactivex.schedulers.Schedulers;\nimport okhttp3.mockwebserver.MockResponse;\nimport okhttp3.mockwebserver.MockWebServer;\n\nimport static java.util.concurrent.TimeUnit.SECONDS;\n\n/**\n * Created by amitshekhar on 24/04/17.\n */\n\npublic class Rx2PostStringApiTest extends ApplicationTestCase<Application> {\n\n    @Rule\n    public final MockWebServer server = new MockWebServer();\n\n    public Rx2PostStringApiTest() {\n        super(Application.class);\n    }\n\n    @Override\n    public void setUp() throws Exception {\n        super.setUp();\n        createApplication();\n    }\n\n    public void testStringPostRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"data\"));\n\n        final AtomicReference<String> responseRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isCompletedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(2);\n\n        Rx2AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .build()\n                .getStringObservable()\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new Observer<String>() {\n                    @Override\n                    public void onSubscribe(Disposable d) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onNext(String response) {\n                        responseRef.set(response);\n                        latch.countDown();\n                    }\n\n                    @Override\n                    public void onError(Throwable e) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onComplete() {\n                        isCompletedRef.set(true);\n                        latch.countDown();\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n        assertTrue(isCompletedRef.get());\n\n        assertEquals(\"data\", responseRef.get());\n    }\n\n    public void testStringSinglePostRequest() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setBody(\"data\"));\n\n        final AtomicReference<String> responseRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        Rx2AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .build()\n                .getStringSingle()\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new SingleObserver<String>() {\n                    @Override\n                    public void onSubscribe(@NonNull Disposable disposable) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onSuccess(@NonNull String response) {\n                        responseRef.set(response);\n                        latch.countDown();\n                    }\n\n                    @Override\n                    public void onError(@NonNull Throwable throwable) {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n\n        assertEquals(\"data\", responseRef.get());\n    }\n\n    public void testStringPostRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        Rx2AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .build()\n                .getStringObservable()\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new Observer<String>() {\n                    @Override\n                    public void onSubscribe(Disposable d) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onNext(String response) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(Throwable e) {\n                        ANError anError = (ANError) e;\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n\n                    @Override\n                    public void onComplete() {\n                        assertTrue(false);\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n\n    }\n\n    public void testStringSinglePostRequest404() throws InterruptedException {\n\n        server.enqueue(new MockResponse().setResponseCode(404).setBody(\"data\"));\n\n        final AtomicReference<String> errorDetailRef = new AtomicReference<>();\n        final AtomicReference<String> errorBodyRef = new AtomicReference<>();\n        final AtomicReference<Integer> errorCodeRef = new AtomicReference<>();\n        final AtomicReference<Boolean> isSubscribedRef = new AtomicReference<>();\n        final CountDownLatch latch = new CountDownLatch(1);\n\n        Rx2AndroidNetworking.post(server.url(\"/\").toString())\n                .addBodyParameter(\"fistName\", \"Amit\")\n                .addBodyParameter(\"lastName\", \"Shekhar\")\n                .build()\n                .getStringSingle()\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new SingleObserver<String>() {\n                    @Override\n                    public void onSubscribe(@NonNull Disposable disposable) {\n                        isSubscribedRef.set(true);\n                    }\n\n                    @Override\n                    public void onSuccess(@NonNull String s) {\n                        assertTrue(false);\n                    }\n\n                    @Override\n                    public void onError(@NonNull Throwable e) {\n                        ANError anError = (ANError) e;\n                        errorBodyRef.set(anError.getErrorBody());\n                        errorDetailRef.set(anError.getErrorDetail());\n                        errorCodeRef.set(anError.getErrorCode());\n                        latch.countDown();\n                    }\n                });\n\n        assertTrue(latch.await(2, SECONDS));\n\n        assertTrue(isSubscribedRef.get());\n\n        assertEquals(ANConstants.RESPONSE_FROM_SERVER_ERROR, errorDetailRef.get());\n\n        assertEquals(\"data\", errorBodyRef.get());\n\n        assertEquals(404, errorCodeRef.get().intValue());\n\n    }\n\n}"
  },
  {
    "path": "rx2-android-networking/src/androidTest/java/com/rx2androidnetworking/model/User.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.rx2androidnetworking.model;\n\n/**\n * Created by amitshekhar on 26/04/17.\n */\n\npublic class User {\n\n    public String firstName;\n    public String lastName;\n\n}\n"
  },
  {
    "path": "rx2-android-networking/src/main/AndroidManifest.xml",
    "content": "<!--\n  ~ /*\n  ~  *    Copyright (C) 2016 Amit Shekhar\n  ~  *    Copyright (C) 2011 Android Open Source Project\n  ~  *\n  ~  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n  ~  *    you may not use this file except in compliance with the License.\n  ~  *    You may obtain a copy of the License at\n  ~  *\n  ~  *        http://www.apache.org/licenses/LICENSE-2.0\n  ~  *\n  ~  *    Unless required by applicable law or agreed to in writing, software\n  ~  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n  ~  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  ~  *    See the License for the specific language governing permissions and\n  ~  *    limitations under the License.\n  ~  */\n  -->\n\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    package=\"com.rx2androidnetworking\">\n</manifest>\n"
  },
  {
    "path": "rx2-android-networking/src/main/java/com/rx2androidnetworking/Rx2ANRequest.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.rx2androidnetworking;\n\nimport android.graphics.Bitmap;\n\nimport com.androidnetworking.common.ANRequest;\nimport com.androidnetworking.common.Method;\nimport com.androidnetworking.common.RequestType;\nimport com.androidnetworking.common.ResponseType;\nimport com.google.gson.internal.$Gson$Types;\nimport com.google.gson.reflect.TypeToken;\n\nimport org.json.JSONArray;\nimport org.json.JSONObject;\n\nimport java.util.List;\n\nimport io.reactivex.BackpressureStrategy;\nimport io.reactivex.Completable;\nimport io.reactivex.Flowable;\nimport io.reactivex.Maybe;\nimport io.reactivex.Observable;\nimport io.reactivex.Single;\n\n/**\n * Created by Prashant Gupta on 30-01-2017.\n */\n@SuppressWarnings({\"unchecked\", \"unused\"})\npublic class Rx2ANRequest extends ANRequest<Rx2ANRequest> {\n\n    public Rx2ANRequest(GetRequestBuilder builder) {\n        super(builder);\n    }\n\n    public Rx2ANRequest(PostRequestBuilder builder) {\n        super(builder);\n    }\n\n    public Rx2ANRequest(DownloadBuilder builder) {\n        super(builder);\n    }\n\n    public Rx2ANRequest(MultiPartBuilder builder) {\n        super(builder);\n    }\n\n    public Observable<JSONObject> getJSONObjectObservable() {\n        this.setResponseAs(ResponseType.JSON_OBJECT);\n        if (this.getRequestType() == RequestType.SIMPLE) {\n            return Rx2InternalNetworking.generateSimpleObservable(this);\n        } else if (this.getRequestType() == RequestType.MULTIPART) {\n            return Rx2InternalNetworking.generateMultipartObservable(this);\n        } else {\n            return null;\n        }\n    }\n\n    public Flowable<JSONObject> getJSONObjectFlowable() {\n        return getJSONObjectObservable().toFlowable(BackpressureStrategy.LATEST);\n    }\n\n    public Single<JSONObject> getJSONObjectSingle() {\n        return getJSONObjectObservable().singleOrError();\n    }\n\n    public Maybe<JSONObject> getJSONObjectMaybe() {\n        return getJSONObjectObservable().singleElement();\n    }\n\n    public Completable getJSONObjectCompletable() {\n        return getJSONObjectObservable().ignoreElements();\n    }\n\n    public Observable<JSONArray> getJSONArrayObservable() {\n        this.setResponseAs(ResponseType.JSON_ARRAY);\n        if (this.getRequestType() == RequestType.SIMPLE) {\n            return Rx2InternalNetworking.generateSimpleObservable(this);\n        } else if (this.getRequestType() == RequestType.MULTIPART) {\n            return Rx2InternalNetworking.generateMultipartObservable(this);\n        } else {\n            return null;\n        }\n    }\n\n    public Flowable<JSONArray> getJSONArrayFlowable() {\n        return getJSONArrayObservable().toFlowable(BackpressureStrategy.LATEST);\n    }\n\n    public Single<JSONArray> getJSONArraySingle() {\n        return getJSONArrayObservable().singleOrError();\n    }\n\n    public Maybe<JSONArray> getJSONArrayMaybe() {\n        return getJSONArrayObservable().singleElement();\n    }\n\n    public Completable getJSONArrayCompletable() {\n        return getJSONArrayObservable().ignoreElements();\n    }\n\n    public Observable<Bitmap> getBitmapObservable() {\n        this.setResponseAs(ResponseType.BITMAP);\n        if (this.getRequestType() == RequestType.SIMPLE) {\n            return Rx2InternalNetworking.generateSimpleObservable(this);\n        } else if (this.getRequestType() == RequestType.MULTIPART) {\n            return Rx2InternalNetworking.generateMultipartObservable(this);\n        } else {\n            return null;\n        }\n    }\n\n    public Flowable<Bitmap> getBitmapFlowable() {\n        return getBitmapObservable().toFlowable(BackpressureStrategy.LATEST);\n    }\n\n    public Single<Bitmap> getBitmapSingle() {\n        return getBitmapObservable().singleOrError();\n    }\n\n    public Maybe<Bitmap> getBitmapMaybe() {\n        return getBitmapObservable().singleElement();\n    }\n\n    public Completable getBitmapCompletable() {\n        return getBitmapObservable().ignoreElements();\n    }\n\n    public Observable<String> getStringObservable() {\n        this.setResponseAs(ResponseType.STRING);\n        if (this.getRequestType() == RequestType.SIMPLE) {\n            return Rx2InternalNetworking.generateSimpleObservable(this);\n        } else if (this.getRequestType() == RequestType.MULTIPART) {\n            return Rx2InternalNetworking.generateMultipartObservable(this);\n        } else {\n            return null;\n        }\n    }\n\n    public Flowable<String> getStringFlowable() {\n        return getStringObservable().toFlowable(BackpressureStrategy.LATEST);\n    }\n\n    public Single<String> getStringSingle() {\n        return getStringObservable().singleOrError();\n    }\n\n    public Maybe<String> getStringMaybe() {\n        return getStringObservable().singleElement();\n    }\n\n    public Completable getStringCompletable() {\n        return getStringObservable().ignoreElements();\n    }\n\n    public Observable<String> getDownloadObservable() {\n        return Rx2InternalNetworking.generateDownloadObservable(this);\n    }\n\n    public Flowable<String> getDownloadFlowable() {\n        return getDownloadObservable().toFlowable(BackpressureStrategy.LATEST);\n    }\n\n    public Single<String> getDownloadSingle() {\n        return getDownloadObservable().singleOrError();\n    }\n\n    public Maybe<String> getDownloadMaybe() {\n        return getDownloadObservable().singleElement();\n    }\n\n    public Completable getDownloadCompletable() {\n        return getDownloadObservable().ignoreElements();\n    }\n\n    public <T> Observable<T> getParseObservable(TypeToken<T> typeToken) {\n        this.setType(typeToken.getType());\n        this.setResponseAs(ResponseType.PARSED);\n        if (this.getRequestType() == RequestType.SIMPLE) {\n            return Rx2InternalNetworking.generateSimpleObservable(this);\n        } else if (this.getRequestType() == RequestType.MULTIPART) {\n            return Rx2InternalNetworking.generateMultipartObservable(this);\n        } else {\n            return null;\n        }\n    }\n\n    public <T> Flowable<T> getParseFlowable(TypeToken<T> typeToken) {\n        return getParseObservable(typeToken).toFlowable(BackpressureStrategy.LATEST);\n    }\n\n    public <T> Single<T> getParseSingle(TypeToken<T> typeToken) {\n        return getParseObservable(typeToken).singleOrError();\n    }\n\n    public <T> Maybe<T> getParseMaybe(TypeToken<T> typeToken) {\n        return getParseObservable(typeToken).singleElement();\n    }\n\n    public <T> Completable getParseCompletable(TypeToken<T> typeToken) {\n        return getParseObservable(typeToken).ignoreElements();\n    }\n\n    public <T> Observable<T> getObjectObservable(Class<T> objectClass) {\n        this.setType(objectClass);\n        this.setResponseAs(ResponseType.PARSED);\n        if (this.getRequestType() == RequestType.SIMPLE) {\n            return Rx2InternalNetworking.generateSimpleObservable(this);\n        } else if (this.getRequestType() == RequestType.MULTIPART) {\n            return Rx2InternalNetworking.generateMultipartObservable(this);\n        } else {\n            return null;\n        }\n    }\n\n    public <T> Flowable<T> getObjectFlowable(Class<T> objectClass) {\n        return getObjectObservable(objectClass).toFlowable(BackpressureStrategy.LATEST);\n    }\n\n    public <T> Single<T> getObjectSingle(Class<T> objectClass) {\n        return getObjectObservable(objectClass).singleOrError();\n    }\n\n    public <T> Maybe<T> getObjectMaybe(Class<T> objectClass) {\n        return getObjectObservable(objectClass).singleElement();\n    }\n\n    public <T> Completable getObjectCompletable(Class<T> objectClass) {\n        return getObjectObservable(objectClass).ignoreElements();\n    }\n\n    public <T> Observable<List<T>> getObjectListObservable(Class<T> objectClass) {\n        this.setType($Gson$Types.newParameterizedTypeWithOwner(null, List.class, objectClass));\n        this.setResponseAs(ResponseType.PARSED);\n        if (this.getRequestType() == RequestType.SIMPLE) {\n            return Rx2InternalNetworking.generateSimpleObservable(this);\n        } else if (this.getRequestType() == RequestType.MULTIPART) {\n            return Rx2InternalNetworking.generateMultipartObservable(this);\n        } else {\n            return null;\n        }\n    }\n\n    public <T> Flowable<List<T>> getObjectListFlowable(Class<T> objectClass) {\n        return getObjectListObservable(objectClass).toFlowable(BackpressureStrategy.LATEST);\n    }\n\n    public <T> Single<List<T>> getObjectListSingle(Class<T> objectClass) {\n        return getObjectListObservable(objectClass).singleOrError();\n    }\n\n    public <T> Maybe<List<T>> getObjectListMaybe(Class<T> objectClass) {\n        return getObjectListObservable(objectClass).singleElement();\n    }\n\n    public <T> Completable getObjectListCompletable(Class<T> objectClass) {\n        return getObjectListObservable(objectClass).ignoreElements();\n    }\n\n    public static class GetRequestBuilder extends ANRequest.GetRequestBuilder<GetRequestBuilder> {\n\n        public GetRequestBuilder(String url) {\n            super(url);\n        }\n\n        private GetRequestBuilder(String url, int method) {\n            super(url, method);\n        }\n\n        public Rx2ANRequest build() {\n            return new Rx2ANRequest(this);\n        }\n    }\n\n    public static class HeadRequestBuilder extends GetRequestBuilder {\n\n        public HeadRequestBuilder(String url) {\n            super(url, Method.HEAD);\n        }\n    }\n\n    public static class OptionsRequestBuilder extends GetRequestBuilder {\n\n        public OptionsRequestBuilder(String url) {\n            super(url, Method.OPTIONS);\n        }\n    }\n\n    public static class PostRequestBuilder extends ANRequest.PostRequestBuilder<PostRequestBuilder> {\n\n        public PostRequestBuilder(String url) {\n            super(url);\n        }\n\n        private PostRequestBuilder(String url, int method) {\n            super(url, method);\n        }\n\n        public Rx2ANRequest build() {\n            return new Rx2ANRequest(this);\n        }\n    }\n\n    public static class PutRequestBuilder extends PostRequestBuilder {\n\n        public PutRequestBuilder(String url) {\n            super(url, Method.PUT);\n        }\n    }\n\n    public static class DeleteRequestBuilder extends PostRequestBuilder {\n\n        public DeleteRequestBuilder(String url) {\n            super(url, Method.DELETE);\n        }\n    }\n\n    public static class PatchRequestBuilder extends PostRequestBuilder {\n\n        public PatchRequestBuilder(String url) {\n            super(url, Method.PATCH);\n        }\n    }\n\n    public static class DynamicRequestBuilder extends PostRequestBuilder {\n\n        public DynamicRequestBuilder(String url, int method) {\n            super(url, method);\n        }\n    }\n\n    public static class DownloadBuilder extends ANRequest.DownloadBuilder<DownloadBuilder> {\n\n        public DownloadBuilder(String url, String dirPath, String fileName) {\n            super(url, dirPath, fileName);\n        }\n\n        public Rx2ANRequest build() {\n            return new Rx2ANRequest(this);\n        }\n    }\n\n    public static class MultiPartBuilder extends ANRequest.MultiPartBuilder<MultiPartBuilder> {\n\n        public MultiPartBuilder(String url) {\n            super(url);\n        }\n\n        public Rx2ANRequest build() {\n            return new Rx2ANRequest(this);\n        }\n    }\n}\n"
  },
  {
    "path": "rx2-android-networking/src/main/java/com/rx2androidnetworking/Rx2AndroidNetworking.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.rx2androidnetworking;\n\n/**\n * Created by amitshekhar on 30/01/17.\n */\n\n/**\n * Rx2AndroidNetworking entry point.\n * You must initialize this class before use. The simplest way is to just do\n * {#code AndroidNetworking.initialize(context)}.\n */\npublic class Rx2AndroidNetworking {\n\n    /**\n     * private constructor to prevent instantiation of this class\n     */\n    private Rx2AndroidNetworking() {\n    }\n\n    /**\n     * Method to make GET request\n     *\n     * @param url The url on which request is to be made\n     * @return The GetRequestBuilder\n     */\n    public static Rx2ANRequest.GetRequestBuilder get(String url) {\n        return new Rx2ANRequest.GetRequestBuilder(url);\n    }\n\n    /**\n     * Method to make HEAD request\n     *\n     * @param url The url on which request is to be made\n     * @return The HeadRequestBuilder\n     */\n    public static Rx2ANRequest.HeadRequestBuilder head(String url) {\n        return new Rx2ANRequest.HeadRequestBuilder(url);\n    }\n\n    /**\n     * Method to make OPTIONS request\n     *\n     * @param url The url on which request is to be made\n     * @return The OptionsRequestBuilder\n     */\n    public static Rx2ANRequest.OptionsRequestBuilder options(String url) {\n        return new Rx2ANRequest.OptionsRequestBuilder(url);\n    }\n\n    /**\n     * Method to make POST request\n     *\n     * @param url The url on which request is to be made\n     * @return The PostRequestBuilder\n     */\n    public static Rx2ANRequest.PostRequestBuilder post(String url) {\n        return new Rx2ANRequest.PostRequestBuilder(url);\n    }\n\n    /**\n     * Method to make PUT request\n     *\n     * @param url The url on which request is to be made\n     * @return The PutRequestBuilder\n     */\n    public static Rx2ANRequest.PutRequestBuilder put(String url) {\n        return new Rx2ANRequest.PutRequestBuilder(url);\n    }\n\n    /**\n     * Method to make DELETE request\n     *\n     * @param url The url on which request is to be made\n     * @return The DeleteRequestBuilder\n     */\n    public static Rx2ANRequest.DeleteRequestBuilder delete(String url) {\n        return new Rx2ANRequest.DeleteRequestBuilder(url);\n    }\n\n    /**\n     * Method to make PATCH request\n     *\n     * @param url The url on which request is to be made\n     * @return The PatchRequestBuilder\n     */\n    public static Rx2ANRequest.PatchRequestBuilder patch(String url) {\n        return new Rx2ANRequest.PatchRequestBuilder(url);\n    }\n\n    /**\n     * Method to make download request\n     *\n     * @param url      The url on which request is to be made\n     * @param dirPath  The directory path on which file is to be saved\n     * @param fileName The file name with which file is to be saved\n     * @return The DownloadBuilder\n     */\n    public static Rx2ANRequest.DownloadBuilder download(String url, String dirPath, String fileName) {\n        return new Rx2ANRequest.DownloadBuilder(url, dirPath, fileName);\n    }\n\n    /**\n     * Method to make upload request\n     *\n     * @param url The url on which request is to be made\n     * @return The MultiPartBuilder\n     */\n    public static Rx2ANRequest.MultiPartBuilder upload(String url) {\n        return new Rx2ANRequest.MultiPartBuilder(url);\n    }\n\n    /**\n     * Method to make Dynamic request\n     *\n     * @param url    The url on which request is to be made\n     * @param method The HTTP METHOD for the request\n     * @return The DynamicRequestBuilder\n     */\n    public static Rx2ANRequest.DynamicRequestBuilder request(String url, int method) {\n        return new Rx2ANRequest.DynamicRequestBuilder(url, method);\n    }\n}\n"
  },
  {
    "path": "rx2-android-networking/src/main/java/com/rx2androidnetworking/Rx2InternalNetworking.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.rx2androidnetworking;\n\nimport android.net.TrafficStats;\n\nimport com.androidnetworking.common.ANConstants;\nimport com.androidnetworking.common.ANResponse;\nimport com.androidnetworking.common.ConnectionClassManager;\nimport com.androidnetworking.error.ANError;\nimport com.androidnetworking.internal.InternalNetworking;\nimport com.androidnetworking.internal.RequestProgressBody;\nimport com.androidnetworking.internal.ResponseProgressBody;\nimport com.androidnetworking.utils.SourceCloseUtil;\nimport com.androidnetworking.utils.Utils;\n\nimport java.io.File;\nimport java.io.IOException;\n\nimport io.reactivex.Observable;\nimport io.reactivex.Observer;\nimport io.reactivex.disposables.Disposable;\nimport io.reactivex.exceptions.CompositeException;\nimport io.reactivex.exceptions.Exceptions;\nimport io.reactivex.plugins.RxJavaPlugins;\nimport okhttp3.Call;\nimport okhttp3.Interceptor;\nimport okhttp3.OkHttpClient;\nimport okhttp3.Request;\nimport okhttp3.RequestBody;\nimport okhttp3.Response;\n\nimport static com.androidnetworking.common.Method.DELETE;\nimport static com.androidnetworking.common.Method.GET;\nimport static com.androidnetworking.common.Method.HEAD;\nimport static com.androidnetworking.common.Method.OPTIONS;\nimport static com.androidnetworking.common.Method.PATCH;\nimport static com.androidnetworking.common.Method.POST;\nimport static com.androidnetworking.common.Method.PUT;\n\n/**\n * Created by Prashant Gupta on 30-01-2017.\n */\n@SuppressWarnings(\"unchecked\")\npublic class Rx2InternalNetworking {\n\n    public static <T> Observable<T> generateSimpleObservable(Rx2ANRequest request) {\n        Request okHttpRequest;\n        Request.Builder builder = new Request.Builder().url(request.getUrl());\n        InternalNetworking.addHeadersToRequestBuilder(builder, request);\n        RequestBody requestBody;\n        switch (request.getMethod()) {\n            case GET: {\n                builder = builder.get();\n                break;\n            }\n            case POST: {\n                requestBody = request.getRequestBody();\n                builder = builder.post(requestBody);\n                break;\n            }\n            case PUT: {\n                requestBody = request.getRequestBody();\n                builder = builder.put(requestBody);\n                break;\n            }\n            case DELETE: {\n                requestBody = request.getRequestBody();\n                builder = builder.delete(requestBody);\n                break;\n            }\n            case HEAD: {\n                builder = builder.head();\n                break;\n            }\n            case OPTIONS: {\n                builder = builder.method(ANConstants.OPTIONS, null);\n                break;\n            }\n            case PATCH: {\n                requestBody = request.getRequestBody();\n                builder = builder.patch(requestBody);\n                break;\n            }\n        }\n        if (request.getCacheControl() != null) {\n            builder.cacheControl(request.getCacheControl());\n        }\n        okHttpRequest = builder.build();\n        if (request.getOkHttpClient() != null) {\n            request.setCall(request\n                    .getOkHttpClient()\n                    .newBuilder()\n                    .cache(InternalNetworking.sHttpClient.cache())\n                    .build()\n                    .newCall(okHttpRequest));\n        } else {\n            request.setCall(InternalNetworking.sHttpClient.newCall(okHttpRequest));\n        }\n        return new SimpleANObservable<>(request);\n    }\n\n    public static <T> Observable<T> generateDownloadObservable(final Rx2ANRequest request) {\n        Request okHttpRequest;\n        Request.Builder builder = new Request.Builder().url(request.getUrl());\n        InternalNetworking.addHeadersToRequestBuilder(builder, request);\n        builder = builder.get();\n        if (request.getCacheControl() != null) {\n            builder.cacheControl(request.getCacheControl());\n        }\n        okHttpRequest = builder.build();\n\n        OkHttpClient okHttpClient;\n\n        if (request.getOkHttpClient() != null) {\n            okHttpClient = request\n                    .getOkHttpClient()\n                    .newBuilder()\n                    .cache(InternalNetworking.sHttpClient.cache())\n                    .addNetworkInterceptor(new Interceptor() {\n                        @Override\n                        public Response intercept(Chain chain) throws IOException {\n                            Response originalResponse = chain.proceed(chain.request());\n                            return originalResponse.newBuilder()\n                                    .body(new ResponseProgressBody(originalResponse.body(),\n                                            request.getDownloadProgressListener()))\n                                    .build();\n                        }\n                    }).build();\n        } else {\n            okHttpClient = InternalNetworking.sHttpClient.newBuilder()\n                    .addNetworkInterceptor(new Interceptor() {\n                        @Override\n                        public Response intercept(Chain chain) throws IOException {\n                            Response originalResponse = chain.proceed(chain.request());\n                            return originalResponse.newBuilder()\n                                    .body(new ResponseProgressBody(originalResponse.body(),\n                                            request.getDownloadProgressListener()))\n                                    .build();\n                        }\n                    }).build();\n        }\n        request.setCall(okHttpClient.newCall(okHttpRequest));\n        return new DownloadANObservable<>(request);\n    }\n\n    public static <T> Observable<T> generateMultipartObservable(final Rx2ANRequest request) {\n        return new MultipartANObservable<>(request);\n    }\n\n    static final class SimpleANObservable<T> extends Observable<T> {\n\n        private Rx2ANRequest request;\n        private final Call originalCall;\n\n        SimpleANObservable(Rx2ANRequest request) {\n            this.request = request;\n            this.originalCall = request.getCall();\n        }\n\n        @Override\n        protected void subscribeActual(Observer<? super T> observer) {\n            Call call = originalCall.clone();\n            observer.onSubscribe(new ANDisposable(call));\n            boolean doNotSwallowError = false;\n            Response okHttpResponse = null;\n            try {\n                final long startTime = System.currentTimeMillis();\n                final long startBytes = TrafficStats.getTotalRxBytes();\n                okHttpResponse = call.execute();\n                final long timeTaken = System.currentTimeMillis() - startTime;\n                if (okHttpResponse.cacheResponse() == null) {\n                    final long finalBytes = TrafficStats.getTotalRxBytes();\n                    final long diffBytes;\n                    if (startBytes == TrafficStats.UNSUPPORTED || finalBytes == TrafficStats.UNSUPPORTED) {\n                        diffBytes = okHttpResponse.body().contentLength();\n                    } else {\n                        diffBytes = finalBytes - startBytes;\n                    }\n                    ConnectionClassManager.getInstance().updateBandwidth(diffBytes, timeTaken);\n                    Utils.sendAnalytics(request.getAnalyticsListener(), timeTaken,\n                            (request.getRequestBody() != null &&\n                                    request.getRequestBody().contentLength() != 0) ?\n                                    request.getRequestBody().contentLength() : -1,\n                            okHttpResponse.body().contentLength(), false);\n                } else if (request.getAnalyticsListener() != null) {\n                    if (okHttpResponse.networkResponse() == null) {\n                        Utils.sendAnalytics(request.getAnalyticsListener(), timeTaken, 0, 0, true);\n                    } else {\n                        Utils.sendAnalytics(request.getAnalyticsListener(), timeTaken,\n                                (request.getRequestBody() != null && request.getRequestBody().contentLength() != 0) ?\n                                        request.getRequestBody().contentLength() : -1, 0, true);\n                    }\n                }\n                if (okHttpResponse.code() >= 400) {\n                    if (!call.isCanceled()) {\n                        observer.onError(Utils.getErrorForServerResponse(new ANError(okHttpResponse),\n                                request, okHttpResponse.code()));\n                    }\n                } else {\n                    ANResponse<T> response = request.parseResponse(okHttpResponse);\n                    if (!response.isSuccess()) {\n                        if (!call.isCanceled()) {\n                            observer.onError(response.getError());\n                        }\n                    } else {\n                        if (!call.isCanceled()) {\n                            observer.onNext(response.getResult());\n                        }\n                        if (!call.isCanceled()) {\n                            doNotSwallowError = true;\n                            observer.onComplete();\n                        }\n                    }\n                }\n            } catch (IOException ioe) {\n                if (!call.isCanceled()) {\n                    observer.onError(Utils.getErrorForConnection(new ANError(ioe)));\n                }\n            } catch (Exception e) {\n                Exceptions.throwIfFatal(e);\n                if (doNotSwallowError) {\n                    RxJavaPlugins.onError(e);\n                } else if (!call.isCanceled()) {\n                    try {\n                        observer.onError(Utils.getErrorForConnection(new ANError(e)));\n                    } catch (Exception e1) {\n                        Exceptions.throwIfFatal(e1);\n                        RxJavaPlugins.onError(new CompositeException(e, e1));\n                    }\n                }\n            } finally {\n                SourceCloseUtil.close(okHttpResponse, request);\n            }\n        }\n    }\n\n    static final class DownloadANObservable<T> extends Observable<T> {\n\n        private final Rx2ANRequest request;\n        private final Call originalCall;\n\n        DownloadANObservable(Rx2ANRequest request) {\n            this.request = request;\n            this.originalCall = request.getCall();\n        }\n\n        @Override\n        protected void subscribeActual(Observer<? super T> observer) {\n            Call call = originalCall.clone();\n            observer.onSubscribe(new ANDisposable(call));\n            boolean doNotSwallowError = false;\n            Response okHttpResponse;\n            try {\n                final long startTime = System.currentTimeMillis();\n                final long startBytes = TrafficStats.getTotalRxBytes();\n                okHttpResponse = request.getCall().execute();\n                Utils.saveFile(okHttpResponse, request.getDirPath(), request.getFileName());\n                final long timeTaken = System.currentTimeMillis() - startTime;\n                if (okHttpResponse.cacheResponse() == null) {\n                    final long finalBytes = TrafficStats.getTotalRxBytes();\n                    final long diffBytes;\n                    if (startBytes == TrafficStats.UNSUPPORTED ||\n                            finalBytes == TrafficStats.UNSUPPORTED) {\n                        diffBytes = okHttpResponse.body().contentLength();\n                    } else {\n                        diffBytes = finalBytes - startBytes;\n                    }\n                    ConnectionClassManager.getInstance().updateBandwidth(diffBytes, timeTaken);\n                    Utils.sendAnalytics(request.getAnalyticsListener(),\n                            timeTaken, -1, okHttpResponse.body().contentLength(), false);\n                } else if (request.getAnalyticsListener() != null) {\n                    Utils.sendAnalytics(request.getAnalyticsListener(), timeTaken, -1, 0, true);\n                }\n                if (okHttpResponse.code() >= 400) {\n                    if (!call.isCanceled()) {\n                        observer.onError(Utils.getErrorForServerResponse(new ANError(okHttpResponse),\n                                request, okHttpResponse.code()));\n                    }\n                } else {\n                    if (!call.isCanceled()) {\n                        ANResponse<T> response = (ANResponse<T>) ANResponse.success(ANConstants.SUCCESS);\n                        observer.onNext(response.getResult());\n                    }\n                    if (!call.isCanceled()) {\n                        doNotSwallowError = true;\n                        observer.onComplete();\n                    }\n                }\n            } catch (IOException ioe) {\n                try {\n                    File destinationFile = new File(request.getDirPath() + File.separator + request.getFileName());\n                    if (destinationFile.exists()) {\n                        destinationFile.delete();\n                    }\n                } catch (Exception e) {\n                    e.printStackTrace();\n                }\n                if (!call.isCanceled()) {\n                    observer.onError(Utils.getErrorForConnection(new ANError(ioe)));\n                }\n            } catch (Exception e) {\n                Exceptions.throwIfFatal(e);\n                if (doNotSwallowError) {\n                    RxJavaPlugins.onError(e);\n                } else if (!call.isCanceled()) {\n                    try {\n                        observer.onError(Utils.getErrorForConnection(new ANError(e)));\n                    } catch (Exception e1) {\n                        Exceptions.throwIfFatal(e1);\n                        RxJavaPlugins.onError(new CompositeException(e, e1));\n                    }\n                }\n            }\n        }\n    }\n\n    static final class MultipartANObservable<T> extends Observable<T> {\n\n        private final Rx2ANRequest request;\n\n        MultipartANObservable(Rx2ANRequest request) {\n            this.request = request;\n        }\n\n        @Override\n        protected void subscribeActual(Observer<? super T> observer) {\n            boolean doNotSwallowError = false;\n            Response okHttpResponse = null;\n            Request okHttpRequest;\n            try {\n                Request.Builder builder = new Request.Builder().url(request.getUrl());\n                InternalNetworking.addHeadersToRequestBuilder(builder, request);\n                final RequestBody requestBody = request.getMultiPartRequestBody();\n                final long requestBodyLength = requestBody.contentLength();\n                builder = builder.post(new RequestProgressBody(requestBody, request.getUploadProgressListener()));\n                if (request.getCacheControl() != null) {\n                    builder.cacheControl(request.getCacheControl());\n                }\n                okHttpRequest = builder.build();\n                if (request.getOkHttpClient() != null) {\n                    request.setCall(request\n                            .getOkHttpClient()\n                            .newBuilder()\n                            .cache(InternalNetworking.sHttpClient.cache())\n                            .build()\n                            .newCall(okHttpRequest));\n                } else {\n                    request.setCall(InternalNetworking.sHttpClient.newCall(okHttpRequest));\n                }\n                observer.onSubscribe(new ANDisposable(request.getCall()));\n                final long startTime = System.currentTimeMillis();\n                okHttpResponse = request.getCall().execute();\n                final long timeTaken = System.currentTimeMillis() - startTime;\n                if (request.getAnalyticsListener() != null) {\n                    if (okHttpResponse.cacheResponse() == null) {\n                        Utils.sendAnalytics(request.getAnalyticsListener(), timeTaken,\n                                requestBodyLength, okHttpResponse.body().contentLength(), false);\n                    } else {\n                        if (okHttpResponse.networkResponse() == null) {\n                            Utils.sendAnalytics(request.getAnalyticsListener(), timeTaken, 0, 0, true);\n                        } else {\n                            Utils.sendAnalytics(request.getAnalyticsListener(), timeTaken,\n                                    requestBodyLength != 0 ? requestBodyLength : -1, 0, true);\n                        }\n                    }\n                }\n                if (okHttpResponse.code() >= 400) {\n                    if (!request.getCall().isCanceled()) {\n                        observer.onError(Utils.getErrorForServerResponse(new ANError(okHttpResponse),\n                                request, okHttpResponse.code()));\n                    }\n                } else {\n                    ANResponse<T> response = request.parseResponse(okHttpResponse);\n                    if (!response.isSuccess()) {\n                        if (!request.getCall().isCanceled()) {\n                            observer.onError(response.getError());\n                        }\n                    } else {\n                        if (!request.getCall().isCanceled()) {\n                            observer.onNext(response.getResult());\n                        }\n                        if (!request.getCall().isCanceled()) {\n                            doNotSwallowError = true;\n                            observer.onComplete();\n                        }\n                    }\n                }\n            } catch (IOException ioe) {\n                if (!request.getCall().isCanceled()) {\n                    observer.onError(Utils.getErrorForConnection(new ANError(ioe)));\n                }\n            } catch (Exception e) {\n                Exceptions.throwIfFatal(e);\n                if (doNotSwallowError) {\n                    RxJavaPlugins.onError(e);\n                } else if (!request.getCall().isCanceled()) {\n                    try {\n                        observer.onError(Utils.getErrorForConnection(new ANError(e)));\n                    } catch (Exception e1) {\n                        Exceptions.throwIfFatal(e1);\n                        RxJavaPlugins.onError(new CompositeException(e, e1));\n                    }\n                }\n            } finally {\n                SourceCloseUtil.close(okHttpResponse, request);\n            }\n        }\n    }\n\n    private static final class ANDisposable implements Disposable {\n\n        private final Call call;\n\n        private ANDisposable(Call call) {\n            this.call = call;\n        }\n\n        @Override\n        public void dispose() {\n            this.call.cancel();\n        }\n\n        @Override\n        public boolean isDisposed() {\n            return this.call.isCanceled();\n        }\n    }\n}\n"
  },
  {
    "path": "rx2-android-networking/src/main/res/values/strings.xml",
    "content": "<!--\n  ~ /*\n  ~  *    Copyright (C) 2016 Amit Shekhar\n  ~  *    Copyright (C) 2011 Android Open Source Project\n  ~  *\n  ~  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n  ~  *    you may not use this file except in compliance with the License.\n  ~  *    You may obtain a copy of the License at\n  ~  *\n  ~  *        http://www.apache.org/licenses/LICENSE-2.0\n  ~  *\n  ~  *    Unless required by applicable law or agreed to in writing, software\n  ~  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n  ~  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  ~  *    See the License for the specific language governing permissions and\n  ~  *    limitations under the License.\n  ~  */\n  -->\n\n<resources>\n    <string name=\"app_name\">Rx2AndroidNetworking</string>\n</resources>\n"
  },
  {
    "path": "rx2-android-networking/src/test/java/com/rx2androidnetworking/ExampleUnitTest.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.rx2androidnetworking;\n\nimport org.junit.Test;\n\nimport static org.junit.Assert.*;\n\n/**\n * Example local unit test, which will execute on the development machine (host).\n *\n * @see <a href=\"http://d.android.com/tools/testing\">Testing documentation</a>\n */\npublic class ExampleUnitTest {\n    @Test\n    public void addition_isCorrect() throws Exception {\n        assertEquals(4, 2 + 2);\n    }\n}"
  },
  {
    "path": "rx2sampleapp/.gitignore",
    "content": "/build\n"
  },
  {
    "path": "rx2sampleapp/build.gradle",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\napply plugin: 'com.android.application'\n\nandroid {\n    compileSdkVersion rootProject.ext.compileSdkVersion\n    buildToolsVersion rootProject.ext.buildToolsVersion\n\n    defaultConfig {\n        applicationId \"com.rx2sampleapp\"\n        minSdkVersion rootProject.ext.minSdkVersion\n        targetSdkVersion rootProject.ext.targetSdkVersion\n        versionCode 1\n        versionName \"1.0\"\n\n        testInstrumentationRunner \"android.support.test.runner.AndroidJUnitRunner\"\n\n    }\n    buildTypes {\n        release {\n            minifyEnabled false\n            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'\n        }\n    }\n}\n\ndependencies {\n    implementation fileTree(dir: 'libs', include: ['*.jar'])\n    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {\n        exclude group: 'com.android.support', module: 'support-annotations'\n    })\n    implementation \"com.android.support:appcompat-v7:$rootProject.ext.supportAppCompatVersion\"\n    testImplementation \"junit:junit:$rootProject.ext.jUnitVersion\"\n    implementation project(':rx2-android-networking')\n}\n"
  },
  {
    "path": "rx2sampleapp/proguard-rules.pro",
    "content": "# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in /Users/amitshekhar/Library/Android/sdk/tools/proguard/proguard-android.txt\n# You can edit the include path and order by changing the proguardFiles\n# directive in build.gradle.\n#\n# For more details, see\n#   http://developer.android.com/guide/developing/tools/proguard.html\n\n# Add any project specific keep options here:\n\n# If your project uses WebView with JS, uncomment the following\n# and specify the fully qualified class name to the JavaScript interface\n# class:\n#-keepclassmembers class fqcn.of.javascript.interface.for.webview {\n#   public *;\n#}\n"
  },
  {
    "path": "rx2sampleapp/src/androidTest/java/com/rx2sampleapp/ExampleInstrumentedTest.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.rx2sampleapp;\n\nimport android.content.Context;\nimport android.support.test.InstrumentationRegistry;\nimport android.support.test.runner.AndroidJUnit4;\n\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\n\nimport static org.junit.Assert.*;\n\n/**\n * Instrumentation test, which will execute on an Android device.\n *\n * @see <a href=\"http://d.android.com/tools/testing\">Testing documentation</a>\n */\n@RunWith(AndroidJUnit4.class)\npublic class ExampleInstrumentedTest {\n    @Test\n    public void useAppContext() throws Exception {\n        // Context of the app under test.\n        Context appContext = InstrumentationRegistry.getTargetContext();\n\n        assertEquals(\"com.rx2sampleapp\", appContext.getPackageName());\n    }\n}\n"
  },
  {
    "path": "rx2sampleapp/src/main/AndroidManifest.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?><!--\n  ~ /*\n  ~  *    Copyright (C) 2016 Amit Shekhar\n  ~  *    Copyright (C) 2011 Android Open Source Project\n  ~  *\n  ~  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n  ~  *    you may not use this file except in compliance with the License.\n  ~  *    You may obtain a copy of the License at\n  ~  *\n  ~  *        http://www.apache.org/licenses/LICENSE-2.0\n  ~  *\n  ~  *    Unless required by applicable law or agreed to in writing, software\n  ~  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n  ~  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  ~  *    See the License for the specific language governing permissions and\n  ~  *    limitations under the License.\n  ~  */\n  -->\n\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    package=\"com.rx2sampleapp\">\n\n    <uses-permission android:name=\"android.permission.INTERNET\" />\n    <uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\" />\n\n    <application\n        android:name=\".Rx2MyApplication\"\n        android:allowBackup=\"true\"\n        android:icon=\"@mipmap/ic_launcher\"\n        android:label=\"@string/app_name\"\n        android:supportsRtl=\"true\"\n        android:theme=\"@style/AppTheme\">\n        <activity android:name=\".Rx2OperatorExampleActivity\">\n            <intent-filter>\n                <action android:name=\"android.intent.action.MAIN\" />\n\n                <category android:name=\"android.intent.category.LAUNCHER\" />\n            </intent-filter>\n        </activity>\n        <activity android:name=\".Rx2ApiTestActivity\"></activity>\n        <activity android:name=\".SubscriptionActivity\"></activity>\n    </application>\n\n</manifest>"
  },
  {
    "path": "rx2sampleapp/src/main/java/com/rx2sampleapp/ApiEndPoint.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.rx2sampleapp;\n\n/**\n * Created by amitshekhar on 29/03/16.\n */\npublic class ApiEndPoint {\n\n    public static final String BASE_URL = \"https://fierce-cove-29863.herokuapp.com\";\n    public static final String GET_JSON_ARRAY = \"/getAllUsers/{pageNumber}\";\n    public static final String GET_JSON_OBJECT = \"/getAnUserDetail/{userId}\";\n    public static final String CHECK_FOR_HEADER = \"/checkForHeader\";\n    public static final String POST_CREATE_AN_USER = \"/createAnUser\";\n    public static final String UPLOAD_IMAGE = \"/uploadImage\";\n\n}\n"
  },
  {
    "path": "rx2sampleapp/src/main/java/com/rx2sampleapp/Rx2ApiTestActivity.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\npackage com.rx2sampleapp;\n\nimport android.graphics.Bitmap;\nimport android.os.Bundle;\nimport android.os.Environment;\nimport android.os.Looper;\nimport android.support.annotation.Nullable;\nimport android.support.v7.app.AppCompatActivity;\nimport android.util.Log;\nimport android.view.View;\nimport android.widget.ImageView;\n\nimport com.androidnetworking.AndroidNetworking;\nimport com.androidnetworking.interfaces.AnalyticsListener;\nimport com.androidnetworking.interfaces.DownloadProgressListener;\nimport com.androidnetworking.interfaces.UploadProgressListener;\nimport com.rx2androidnetworking.Rx2ANRequest;\nimport com.rx2androidnetworking.Rx2AndroidNetworking;\nimport com.rx2sampleapp.model.User;\nimport com.rx2sampleapp.utils.Utils;\n\nimport org.json.JSONException;\nimport org.json.JSONObject;\n\nimport java.io.File;\nimport java.util.List;\n\nimport io.reactivex.CompletableObserver;\nimport io.reactivex.Single;\nimport io.reactivex.SingleObserver;\nimport io.reactivex.android.schedulers.AndroidSchedulers;\nimport io.reactivex.annotations.NonNull;\nimport io.reactivex.disposables.Disposable;\nimport io.reactivex.schedulers.Schedulers;\n\n/**\n * Created by Prashant Gupta on 25-07-2016.\n */\npublic class Rx2ApiTestActivity extends AppCompatActivity {\n\n    private static final String TAG = Rx2ApiTestActivity.class.getSimpleName();\n\n    @Override\n    protected void onCreate(@Nullable Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_rx_api_test);\n    }\n\n    public void getAllUsers(View view) {\n        Rx2AndroidNetworking.get(ApiEndPoint.BASE_URL + ApiEndPoint.GET_JSON_ARRAY)\n                .addPathParameter(\"pageNumber\", \"0\")\n                .addQueryParameter(\"limit\", \"3\")\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .getObjectListSingle(User.class)\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new SingleObserver<List<User>>() {\n                    @Override\n                    public void onSubscribe(@NonNull Disposable disposable) {\n\n                    }\n\n                    @Override\n                    public void onSuccess(@NonNull List<User> users) {\n                        Log.d(TAG, \"onResponse isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                        Log.d(TAG, \"userList size : \" + users.size());\n                        for (User user : users) {\n                            Log.d(TAG, \"id : \" + user.id);\n                            Log.d(TAG, \"firstname : \" + user.firstname);\n                            Log.d(TAG, \"lastname : \" + user.lastname);\n                        }\n                    }\n\n                    @Override\n                    public void onError(@NonNull Throwable throwable) {\n                        Utils.logError(TAG, throwable);\n                    }\n                });\n    }\n\n    public void getAnUser(View view) {\n        Rx2AndroidNetworking.get(ApiEndPoint.BASE_URL + ApiEndPoint.GET_JSON_OBJECT)\n                .addPathParameter(\"userId\", \"1\")\n                .setUserAgent(\"getAnUser\")\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .getObjectSingle(User.class)\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new SingleObserver<User>() {\n                    @Override\n                    public void onSubscribe(@NonNull Disposable disposable) {\n\n                    }\n\n                    @Override\n                    public void onSuccess(@NonNull User user) {\n                        Log.d(TAG, \"onResponse isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                        Log.d(TAG, \"id : \" + user.id);\n                        Log.d(TAG, \"firstname : \" + user.firstname);\n                        Log.d(TAG, \"lastname : \" + user.lastname);\n                    }\n\n                    @Override\n                    public void onError(@NonNull Throwable throwable) {\n                        Utils.logError(TAG, throwable);\n                    }\n                });\n    }\n\n    public void checkForHeaderGet(View view) {\n\n        Rx2ANRequest.GetRequestBuilder getRequestBuilder = new Rx2ANRequest.GetRequestBuilder(ApiEndPoint.BASE_URL + ApiEndPoint.CHECK_FOR_HEADER);\n\n        getRequestBuilder.addHeaders(\"token\", \"1234\")\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .getJSONObjectSingle()\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new SingleObserver<JSONObject>() {\n                    @Override\n                    public void onSubscribe(@NonNull Disposable disposable) {\n\n                    }\n\n                    @Override\n                    public void onSuccess(@NonNull JSONObject jsonObject) {\n                        Log.d(TAG, \"onResponse object : \" + jsonObject.toString());\n                        Log.d(TAG, \"onResponse isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                    }\n\n                    @Override\n                    public void onError(@NonNull Throwable throwable) {\n                        Utils.logError(TAG, throwable);\n                    }\n                });\n    }\n\n    public void checkForHeaderPost(View view) {\n\n        Rx2ANRequest.PostRequestBuilder postRequestBuilder = Rx2AndroidNetworking.post(ApiEndPoint.BASE_URL + ApiEndPoint.CHECK_FOR_HEADER);\n\n        postRequestBuilder.addHeaders(\"token\", \"1234\");\n\n        Rx2ANRequest rxAnRequest = postRequestBuilder.setTag(this)\n                .build();\n\n        rxAnRequest.setAnalyticsListener(new AnalyticsListener() {\n            @Override\n            public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                Log.d(TAG, \" bytesSent : \" + bytesSent);\n                Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                Log.d(TAG, \" isFromCache : \" + isFromCache);\n            }\n        });\n\n        rxAnRequest.getJSONObjectSingle()\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new SingleObserver<JSONObject>() {\n                    @Override\n                    public void onSubscribe(@NonNull Disposable disposable) {\n\n                    }\n\n                    @Override\n                    public void onSuccess(@NonNull JSONObject jsonObject) {\n                        Log.d(TAG, \"onResponse object : \" + jsonObject.toString());\n                        Log.d(TAG, \"onResponse isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                    }\n\n                    @Override\n                    public void onError(@NonNull Throwable throwable) {\n                        Utils.logError(TAG, throwable);\n                    }\n                });\n    }\n\n    public void createAnUser(View view) {\n        Rx2AndroidNetworking.post(ApiEndPoint.BASE_URL + ApiEndPoint.POST_CREATE_AN_USER)\n                .addBodyParameter(\"firstname\", \"Amit\")\n                .addBodyParameter(\"lastname\", \"Shekhar\")\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .getJSONObjectSingle()\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new SingleObserver<JSONObject>() {\n                    @Override\n                    public void onSubscribe(@NonNull Disposable disposable) {\n\n                    }\n\n                    @Override\n                    public void onSuccess(@NonNull JSONObject jsonObject) {\n                        Log.d(TAG, \"onResponse object : \" + jsonObject.toString());\n                        Log.d(TAG, \"onResponse isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                    }\n\n                    @Override\n                    public void onError(@NonNull Throwable throwable) {\n                        Utils.logError(TAG, throwable);\n                    }\n                });\n    }\n\n    public void createAnUserJSONObject(View view) {\n        JSONObject jsonObject = new JSONObject();\n        try {\n            jsonObject.put(\"firstname\", \"Rohit\");\n            jsonObject.put(\"lastname\", \"Kumar\");\n        } catch (JSONException e) {\n            e.printStackTrace();\n        }\n        Rx2AndroidNetworking.post(ApiEndPoint.BASE_URL + ApiEndPoint.POST_CREATE_AN_USER)\n                .addJSONObjectBody(jsonObject)\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .getJSONObjectSingle()\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new SingleObserver<JSONObject>() {\n                    @Override\n                    public void onSubscribe(@NonNull Disposable disposable) {\n\n                    }\n\n                    @Override\n                    public void onSuccess(@NonNull JSONObject jsonObject) {\n                        Log.d(TAG, \"onResponse object : \" + jsonObject.toString());\n                        Log.d(TAG, \"onResponse isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                    }\n\n                    @Override\n                    public void onError(@NonNull Throwable throwable) {\n                        Utils.logError(TAG, throwable);\n                    }\n                });\n    }\n\n    public void downloadFile(final View view) {\n        String url = \"http://www.colorado.edu/conflict/peace/download/peace_problem.ZIP\";\n        Rx2AndroidNetworking.download(url, Utils.getRootDirPath(getApplicationContext()), \"file1.zip\")\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .setDownloadProgressListener(new DownloadProgressListener() {\n                    @Override\n                    public void onProgress(long bytesDownloaded, long totalBytes) {\n                        Log.d(TAG, \"bytesDownloaded : \" + bytesDownloaded + \" totalBytes : \" + totalBytes);\n                        Log.d(TAG, \"setDownloadProgressListener isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                    }\n                })\n                .getDownloadCompletable()\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new CompletableObserver() {\n                    @Override\n                    public void onSubscribe(@NonNull Disposable disposable) {\n\n                    }\n\n                    @Override\n                    public void onComplete() {\n                        Log.d(TAG, \"File download Completed\");\n                        Log.d(TAG, \"onDownloadComplete isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                    }\n\n                    @Override\n                    public void onError(@NonNull Throwable throwable) {\n                        Utils.logError(TAG, throwable);\n                    }\n                });\n    }\n\n    public void downloadImage(final View view) {\n        String url = \"http://i.imgur.com/AtbX9iX.png\";\n        Rx2AndroidNetworking.download(url, Utils.getRootDirPath(getApplicationContext()), \"image1.png\")\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .getDownloadCompletable()\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new CompletableObserver() {\n                    @Override\n                    public void onSubscribe(@NonNull Disposable disposable) {\n\n                    }\n\n                    @Override\n                    public void onComplete() {\n                        Log.d(TAG, \"File download Completed\");\n                        Log.d(TAG, \"onDownloadComplete isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                    }\n\n                    @Override\n                    public void onError(@NonNull Throwable throwable) {\n                        Utils.logError(TAG, throwable);\n                    }\n                });\n    }\n\n    public void uploadImage(final View view) {\n        Single<JSONObject> single = Rx2AndroidNetworking.upload(ApiEndPoint.BASE_URL + ApiEndPoint.UPLOAD_IMAGE)\n                .addMultipartFile(\"image\", new File(Environment.getExternalStorageDirectory().getAbsolutePath(), \"test.png\"))\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .setUploadProgressListener(new UploadProgressListener() {\n                    @Override\n                    public void onProgress(long bytesUploaded, long totalBytes) {\n                        Log.d(TAG, \"bytesUploaded : \" + bytesUploaded + \" totalBytes : \" + totalBytes);\n                        Log.d(TAG, \"setUploadProgressListener isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                    }\n                })\n                .getJSONObjectSingle();\n\n        single.subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new SingleObserver<JSONObject>() {\n                    @Override\n                    public void onSubscribe(@NonNull Disposable disposable) {\n\n                    }\n\n                    @Override\n                    public void onSuccess(@NonNull JSONObject jsonObject) {\n                        Log.d(TAG + \"_1\", \"Image upload Completed\");\n                        Log.d(TAG + \"_1\", \"onResponse object : \" + jsonObject.toString());\n                    }\n\n                    @Override\n                    public void onError(@NonNull Throwable throwable) {\n                        Utils.logError(TAG, throwable);\n                    }\n                });\n\n        single.subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new SingleObserver<JSONObject>() {\n                    @Override\n                    public void onSubscribe(@NonNull Disposable disposable) {\n\n                    }\n\n                    @Override\n                    public void onSuccess(@NonNull JSONObject jsonObject) {\n                        Log.d(TAG + \"_2\", \"Image upload Completed\");\n                        Log.d(TAG + \"_2\", \"onResponse object : \" + jsonObject.toString());\n                    }\n\n                    @Override\n                    public void onError(@NonNull Throwable throwable) {\n                        Utils.logError(TAG, throwable);\n                    }\n                });\n\n    }\n\n    public void getCurrentConnectionQuality(View view) {\n        Log.d(TAG, \"getCurrentConnectionQuality : \" + AndroidNetworking.getCurrentConnectionQuality() + \" currentBandwidth : \" + AndroidNetworking.getCurrentBandwidth());\n    }\n\n    public void loadImage(View view) {\n        final String URL_IMAGE = \"http://i.imgur.com/2M7Hasn.png\";\n        Rx2AndroidNetworking.get(URL_IMAGE)\n                .setImageScaleType(null)\n                .setBitmapMaxHeight(0)\n                .setBitmapMaxWidth(0)\n                .setBitmapConfig(Bitmap.Config.ARGB_8888)\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .getBitmapSingle()\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new SingleObserver<Bitmap>() {\n                    @Override\n                    public void onSubscribe(@NonNull Disposable disposable) {\n\n                    }\n\n                    @Override\n                    public void onSuccess(@NonNull Bitmap bitmap) {\n                        Log.d(TAG, \"onResponse Bitmap\");\n                        ImageView imageView = findViewById(R.id.imageView);\n                        imageView.setImageBitmap(bitmap);\n                    }\n\n                    @Override\n                    public void onError(@NonNull Throwable throwable) {\n                        Utils.logError(TAG, throwable);\n                    }\n                });\n\n    }\n\n}\n"
  },
  {
    "path": "rx2sampleapp/src/main/java/com/rx2sampleapp/Rx2MyApplication.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\npackage com.rx2sampleapp;\n\nimport android.app.Application;\nimport android.util.Log;\n\nimport com.androidnetworking.AndroidNetworking;\nimport com.androidnetworking.common.ConnectionQuality;\nimport com.androidnetworking.interfaces.ConnectionQualityChangeListener;\n\npublic class Rx2MyApplication extends Application {\n\n    private static final String TAG = Rx2MyApplication.class.getSimpleName();\n    private static Rx2MyApplication appInstance = null;\n\n    public static Rx2MyApplication getInstance() {\n        return appInstance;\n    }\n\n    @Override\n    public void onCreate() {\n        super.onCreate();\n        appInstance = this;\n        AndroidNetworking.initialize(getApplicationContext());\n        AndroidNetworking.enableLogging();\n        AndroidNetworking.setConnectionQualityChangeListener(new ConnectionQualityChangeListener() {\n            @Override\n            public void onChange(ConnectionQuality currentConnectionQuality, int currentBandwidth) {\n                Log.d(TAG, \"onChange: currentConnectionQuality : \" + currentConnectionQuality + \" currentBandwidth : \" + currentBandwidth);\n            }\n        });\n    }\n\n}"
  },
  {
    "path": "rx2sampleapp/src/main/java/com/rx2sampleapp/Rx2OperatorExampleActivity.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.rx2sampleapp;\n\nimport android.content.Intent;\nimport android.os.Bundle;\nimport android.support.v7.app.AppCompatActivity;\nimport android.util.Log;\nimport android.util.Pair;\nimport android.view.View;\n\nimport com.androidnetworking.interfaces.AnalyticsListener;\nimport com.rx2androidnetworking.Rx2AndroidNetworking;\nimport com.rx2sampleapp.model.ApiUser;\nimport com.rx2sampleapp.model.User;\nimport com.rx2sampleapp.model.UserDetail;\nimport com.rx2sampleapp.utils.Utils;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport io.reactivex.Observable;\nimport io.reactivex.ObservableSource;\nimport io.reactivex.Observer;\nimport io.reactivex.Single;\nimport io.reactivex.SingleObserver;\nimport io.reactivex.android.schedulers.AndroidSchedulers;\nimport io.reactivex.annotations.NonNull;\nimport io.reactivex.disposables.Disposable;\nimport io.reactivex.functions.BiFunction;\nimport io.reactivex.functions.Function;\nimport io.reactivex.functions.Predicate;\nimport io.reactivex.schedulers.Schedulers;\n\n\n/**\n * Created by amitshekhar on 30/01/17.\n */\npublic class Rx2OperatorExampleActivity extends AppCompatActivity {\n\n    private static final String TAG = Rx2OperatorExampleActivity.class.getSimpleName();\n\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_rx_operator_example);\n        testApi();\n    }\n\n    @Override\n    protected void onDestroy() {\n        super.onDestroy();\n    }\n\n    /************************************\n     * Just an test api start\n     ************************************/\n\n    private void testApi() {\n\n        Single<List<User>> single = Rx2AndroidNetworking.get(\"https://fierce-cove-29863.herokuapp.com/getAllUsers/{pageNumber}\")\n                .addPathParameter(\"pageNumber\", \"0\")\n                .addQueryParameter(\"limit\", \"3\")\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .getObjectListSingle(User.class);\n\n        // first observer\n        single.subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new SingleObserver<List<User>>() {\n                    @Override\n                    public void onSubscribe(@NonNull Disposable disposable) {\n                        Log.d(TAG + \"_1\", \"onSubscribe\");\n                    }\n\n                    @Override\n                    public void onSuccess(@NonNull List<User> users) {\n                        Log.d(TAG + \"_1\", \"userList size : \" + users.size());\n                        for (User user : users) {\n                            Log.d(TAG, \"id : \" + user.id);\n                            Log.d(TAG, \"firstname : \" + user.firstname);\n                            Log.d(TAG, \"lastname : \" + user.lastname);\n                        }\n                    }\n\n                    @Override\n                    public void onError(@NonNull Throwable throwable) {\n                        Utils.logError(TAG + \"_1\", throwable);\n                    }\n                });\n\n        // second observer\n        single.subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new SingleObserver<List<User>>() {\n                    @Override\n                    public void onSubscribe(@NonNull Disposable disposable) {\n                        Log.d(TAG + \"_2\", \"onSubscribe\");\n                    }\n\n                    @Override\n                    public void onSuccess(@NonNull List<User> users) {\n                        Log.d(TAG + \"_2\", \"userList size : \" + users.size());\n                        for (User user : users) {\n                            Log.d(TAG, \"id : \" + user.id);\n                            Log.d(TAG, \"firstname : \" + user.firstname);\n                            Log.d(TAG, \"lastname : \" + user.lastname);\n                        }\n                    }\n\n                    @Override\n                    public void onError(@NonNull Throwable throwable) {\n                        Utils.logError(TAG + \"_2\", throwable);\n                    }\n                });\n    }\n\n    /************************************\n     * map operator start\n     ************************************/\n\n    public void map(View view) {\n        Rx2AndroidNetworking.get(\"https://fierce-cove-29863.herokuapp.com/getAnUser/{userId}\")\n                .addPathParameter(\"userId\", \"1\")\n                .build()\n                .getObjectSingle(ApiUser.class)\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .map(new Function<ApiUser, User>() {\n                    @Override\n                    public User apply(ApiUser apiUser) throws Exception {\n                        // here we get ApiUser from server\n                        User user = new User(apiUser);\n                        // then by converting, we are returning user\n                        return user;\n                    }\n                })\n                .subscribe(new SingleObserver<User>() {\n                    @Override\n                    public void onSubscribe(@NonNull Disposable disposable) {\n\n                    }\n\n                    @Override\n                    public void onSuccess(@NonNull User user) {\n                        Log.d(TAG, \"user id : \" + user.id);\n                        Log.d(TAG, \"user firstname : \" + user.firstname);\n                        Log.d(TAG, \"user lastname : \" + user.lastname);\n                    }\n\n                    @Override\n                    public void onError(@NonNull Throwable throwable) {\n                        Utils.logError(TAG, throwable);\n                    }\n                });\n    }\n\n\n    /************************************\n     * zip operator start\n     *********************************/\n\n    /*\n    * This observable return the list of User who loves cricket\n    */\n    private Observable<List<User>> getCricketFansObservable() {\n        return Rx2AndroidNetworking.get(\"https://fierce-cove-29863.herokuapp.com/getAllCricketFans\")\n                .build()\n                .getObjectListObservable(User.class);\n    }\n\n    /*\n    * This observable return the list of User who loves Football\n    */\n    private Observable<List<User>> getFootballFansObservable() {\n        return Rx2AndroidNetworking.get(\"https://fierce-cove-29863.herokuapp.com/getAllFootballFans\")\n                .build()\n                .getObjectListObservable(User.class);\n    }\n\n    /*\n    * This do the complete magic, make both network call\n    * and then returns the list of user who loves both\n    * Using zip operator to get both response at a time\n    */\n    private void findUsersWhoLovesBoth() {\n        // here we are using zip operator to combine both request\n        Observable.zip(getCricketFansObservable(), getFootballFansObservable(),\n                new BiFunction<List<User>, List<User>, List<User>>() {\n                    @Override\n                    public List<User> apply(List<User> cricketFans, List<User> footballFans) throws Exception {\n                        List<User> userWhoLovesBoth =\n                                filterUserWhoLovesBoth(cricketFans, footballFans);\n                        return userWhoLovesBoth;\n                    }\n                })\n                .subscribeOn(Schedulers.newThread())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new Observer<List<User>>() {\n                    @Override\n                    public void onSubscribe(Disposable d) {\n\n                    }\n\n                    @Override\n                    public void onNext(List<User> users) {\n                        // do anything with user who loves both\n                        Log.d(TAG, \"userList size : \" + users.size());\n                        for (User user : users) {\n                            Log.d(TAG, \"id : \" + user.id);\n                            Log.d(TAG, \"firstname : \" + user.firstname);\n                            Log.d(TAG, \"lastname : \" + user.lastname);\n                        }\n                    }\n\n                    @Override\n                    public void onError(Throwable e) {\n                        Utils.logError(TAG, e);\n                    }\n\n                    @Override\n                    public void onComplete() {\n                        Log.d(TAG, \"onComplete\");\n                    }\n                });\n    }\n\n    private List<User> filterUserWhoLovesBoth(List<User> cricketFans, List<User> footballFans) {\n        List<User> userWhoLovesBoth = new ArrayList<>();\n        for (User cricketFan : cricketFans) {\n            for (User footballFan : footballFans) {\n                if (cricketFan.id == footballFan.id) {\n                    userWhoLovesBoth.add(cricketFan);\n                }\n            }\n        }\n        return userWhoLovesBoth;\n    }\n\n\n    public void zip(View view) {\n        findUsersWhoLovesBoth();\n    }\n\n    /************************************\n     * flatMap and filter operator start\n     ************************************/\n\n    private Observable<List<User>> getAllMyFriendsObservable() {\n        return Rx2AndroidNetworking.get(\"https://fierce-cove-29863.herokuapp.com/getAllFriends/{userId}\")\n                .addPathParameter(\"userId\", \"1\")\n                .build()\n                .getObjectListObservable(User.class);\n    }\n\n    public void flatMapAndFilter(View view) {\n        getAllMyFriendsObservable()\n                .flatMap(new Function<List<User>, ObservableSource<User>>() { // flatMap - to return users one by one\n                    @Override\n                    public ObservableSource<User> apply(List<User> usersList) throws Exception {\n                        return Observable.fromIterable(usersList); // returning user one by one from usersList.\n                    }\n                })\n                .filter(new Predicate<User>() {\n                    @Override\n                    public boolean test(User user) throws Exception {\n                        // filtering user who follows me.\n                        return user.isFollowing;\n                    }\n                })\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new Observer<User>() {\n                    @Override\n                    public void onSubscribe(Disposable d) {\n\n                    }\n\n                    @Override\n                    public void onNext(User user) {\n                        // only the user who is following me comes here one by one\n                        Log.d(TAG, \"user id : \" + user.id);\n                        Log.d(TAG, \"user firstname : \" + user.firstname);\n                        Log.d(TAG, \"user lastname : \" + user.lastname);\n                    }\n\n                    @Override\n                    public void onError(Throwable e) {\n                        Utils.logError(TAG, e);\n                    }\n\n                    @Override\n                    public void onComplete() {\n                        Log.d(TAG, \"onComplete\");\n                    }\n                });\n    }\n\n    /************************************\n     * take operator start\n     ************************************/\n\n    public void take(View view) {\n        getUserListObservable()\n                .flatMap(new Function<List<User>, ObservableSource<User>>() { // flatMap - to return users one by one\n                    @Override\n                    public ObservableSource<User> apply(List<User> usersList) throws Exception {\n                        return Observable.fromIterable(usersList); // returning user one by one from usersList.\n                    }\n                })\n                .take(4) // it will only emit first 4 users out of all\n                .subscribeOn(Schedulers.newThread())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new Observer<User>() {\n                    @Override\n                    public void onSubscribe(Disposable d) {\n\n                    }\n\n                    @Override\n                    public void onNext(User user) {\n                        // // only four user comes here one by one\n                        Log.d(TAG, \"user id : \" + user.id);\n                        Log.d(TAG, \"user firstname : \" + user.firstname);\n                        Log.d(TAG, \"user lastname : \" + user.lastname);\n                        Log.d(TAG, \"isFollowing : \" + user.isFollowing);\n                    }\n\n                    @Override\n                    public void onError(Throwable e) {\n                        Utils.logError(TAG, e);\n                    }\n\n                    @Override\n                    public void onComplete() {\n                        Log.d(TAG, \"onComplete\");\n                    }\n                });\n    }\n\n\n    /************************************\n     * flatMap operator start\n     ************************************/\n\n\n    public void flatMap(View view) {\n        getUserListObservable()\n                .flatMap(new Function<List<User>, ObservableSource<User>>() { // flatMap - to return users one by one\n                    @Override\n                    public ObservableSource<User> apply(List<User> usersList) throws Exception {\n                        return Observable.fromIterable(usersList); // returning user one by one from usersList.\n                    }\n                })\n                .flatMap(new Function<User, ObservableSource<UserDetail>>() {\n                    @Override\n                    public ObservableSource<UserDetail> apply(User user) throws Exception {\n                        // here we get the user one by one\n                        // and returns corresponding getUserDetailObservable\n                        // for that userId\n                        return getUserDetailObservable(user.id);\n                    }\n                })\n                .subscribeOn(Schedulers.newThread())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new Observer<UserDetail>() {\n                    @Override\n                    public void onSubscribe(Disposable d) {\n\n                    }\n\n                    @Override\n                    public void onError(Throwable e) {\n                        Utils.logError(TAG, e);\n                    }\n\n                    @Override\n                    public void onNext(UserDetail userDetail) {\n                        // do anything with userDetail\n                        Log.d(TAG, \"userDetail id : \" + userDetail.id);\n                        Log.d(TAG, \"userDetail firstname : \" + userDetail.firstname);\n                        Log.d(TAG, \"userDetail lastname : \" + userDetail.lastname);\n                    }\n\n                    @Override\n                    public void onComplete() {\n                        Log.d(TAG, \"onComplete\");\n                    }\n                });\n    }\n\n    /************************************\n     * flatMapWithZip operator start\n     ************************************/\n\n    private Observable<List<User>> getUserListObservable() {\n        return Rx2AndroidNetworking.get(\"https://fierce-cove-29863.herokuapp.com/getAllUsers/{pageNumber}\")\n                .addPathParameter(\"pageNumber\", \"0\")\n                .addQueryParameter(\"limit\", \"10\")\n                .build()\n                .getObjectListObservable(User.class);\n    }\n\n    private Observable<UserDetail> getUserDetailObservable(long id) {\n        return Rx2AndroidNetworking.get(\"https://fierce-cove-29863.herokuapp.com/getAnUserDetail/{userId}\")\n                .addPathParameter(\"userId\", String.valueOf(id))\n                .build()\n                .getObjectObservable(UserDetail.class);\n    }\n\n    public void flatMapWithZip(View view) {\n        getUserListObservable()\n                .flatMap(new Function<List<User>, ObservableSource<User>>() { // flatMap - to return users one by one\n                    @Override\n                    public ObservableSource<User> apply(List<User> usersList) throws Exception {\n                        return Observable.fromIterable(usersList); // returning user one by one from usersList.\n                    }\n                })\n                .flatMap(new Function<User, ObservableSource<Pair<UserDetail, User>>>() {\n                    @Override\n                    public ObservableSource<Pair<UserDetail, User>> apply(User user) throws Exception {\n                        // here we get the user one by one and then we are zipping\n                        // two observable - one getUserDetailObservable (network call to get userDetail)\n                        // and another Observable.just(user) - just to emit user\n                        return Observable.zip(getUserDetailObservable(user.id),\n                                Observable.just(user),\n                                new BiFunction<UserDetail, User, Pair<UserDetail, User>>() {\n                                    @Override\n                                    public Pair<UserDetail, User> apply(UserDetail userDetail, User user) throws Exception {\n                                        // runs when network call completes\n                                        // we get here userDetail for the corresponding user\n                                        return new Pair<>(userDetail, user); // returning the pair(userDetail, user)\n                                    }\n                                });\n                    }\n                })\n                .subscribeOn(Schedulers.newThread())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new Observer<Pair<UserDetail, User>>() {\n                    @Override\n                    public void onComplete() {\n                        // do something onCompleted\n                        Log.d(TAG, \"onComplete\");\n                    }\n\n                    @Override\n                    public void onError(Throwable e) {\n                        // handle error\n                        Utils.logError(TAG, e);\n                    }\n\n                    @Override\n                    public void onSubscribe(Disposable d) {\n\n                    }\n\n                    @Override\n                    public void onNext(Pair<UserDetail, User> pair) {\n                        // here we are getting the userDetail for the corresponding user one by one\n                        UserDetail userDetail = pair.first;\n                        User user = pair.second;\n                        Log.d(TAG, \"userId : \" + user.id);\n                        Log.d(TAG, \"userDetail firstname : \" + userDetail.firstname);\n                        Log.d(TAG, \"userDetail lastname : \" + userDetail.lastname);\n                    }\n                });\n    }\n\n    /************************************\n     * others start here\n     ************************************/\n\n    public void startRxApiTestActivity(View view) {\n        startActivity(new Intent(Rx2OperatorExampleActivity.this, Rx2ApiTestActivity.class));\n    }\n\n    public void startSubscriptionActivity(View view) {\n        startActivity(new Intent(Rx2OperatorExampleActivity.this, SubscriptionActivity.class));\n    }\n\n}\n"
  },
  {
    "path": "rx2sampleapp/src/main/java/com/rx2sampleapp/SubscriptionActivity.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.rx2sampleapp;\n\nimport android.os.Bundle;\nimport android.support.v7.app.AppCompatActivity;\nimport android.util.Log;\nimport android.view.View;\n\nimport com.rx2androidnetworking.Rx2AndroidNetworking;\nimport com.rx2sampleapp.utils.Utils;\n\nimport io.reactivex.Completable;\nimport io.reactivex.android.schedulers.AndroidSchedulers;\nimport io.reactivex.annotations.NonNull;\nimport io.reactivex.disposables.CompositeDisposable;\nimport io.reactivex.observers.DisposableCompletableObserver;\nimport io.reactivex.schedulers.Schedulers;\n\n\n/**\n * Created by amitshekhar on 31/07/16.\n */\npublic class SubscriptionActivity extends AppCompatActivity {\n\n    private static final String TAG = SubscriptionActivity.class.getSimpleName();\n    private static final String URL = \"http://i.imgur.com/AtbX9iX.png\";\n    private String dirPath;\n    private String fileName = \"imgurimage.png\";\n    private final CompositeDisposable disposables = new CompositeDisposable();\n\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_subscription);\n        dirPath = Utils.getRootDirPath(getApplicationContext());\n    }\n\n    @Override\n    protected void onDestroy() {\n        super.onDestroy();\n        disposables.clear();\n    }\n\n    public Completable getCompletable() {\n        return Rx2AndroidNetworking.download(URL, dirPath, fileName)\n                .build()\n                .getDownloadCompletable();\n    }\n\n    private DisposableCompletableObserver getDisposableObserver() {\n\n        return new DisposableCompletableObserver() {\n            @Override\n            public void onComplete() {\n                Log.d(TAG, \"onCompleted\");\n            }\n\n            @Override\n            public void onError(@NonNull Throwable throwable) {\n                Log.d(TAG, \"onError \" + throwable.getMessage());\n            }\n        };\n\n    }\n\n    public void downloadFile(View view) {\n        disposables.add(getCompletable()\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribeWith(getDisposableObserver()));\n    }\n}"
  },
  {
    "path": "rx2sampleapp/src/main/java/com/rx2sampleapp/model/ApiUser.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.rx2sampleapp.model;\n\n/**\n * Created by amitshekhar on 02/08/16.\n */\npublic class ApiUser {\n    public long id;\n    public String firstname;\n    public String lastname;\n}\n"
  },
  {
    "path": "rx2sampleapp/src/main/java/com/rx2sampleapp/model/User.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.rx2sampleapp.model;\n\n/**\n * Created by amitshekhar on 31/07/16.\n */\npublic class User {\n    public long id;\n    public String firstname;\n    public String lastname;\n    public boolean isFollowing;\n\n    public User(ApiUser apiUser) {\n        this.id = apiUser.id;\n        this.firstname = apiUser.firstname;\n        this.lastname = apiUser.lastname;\n    }\n}\n"
  },
  {
    "path": "rx2sampleapp/src/main/java/com/rx2sampleapp/model/UserDetail.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.rx2sampleapp.model;\n\n/**\n * Created by amitshekhar on 02/08/16.\n */\npublic class UserDetail {\n\n    public long id;\n    public String firstname;\n    public String lastname;\n\n}\n"
  },
  {
    "path": "rx2sampleapp/src/main/java/com/rx2sampleapp/utils/Utils.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\npackage com.rx2sampleapp.utils;\n\nimport android.content.Context;\nimport android.os.Environment;\nimport android.support.v4.content.ContextCompat;\nimport android.util.Log;\n\nimport com.androidnetworking.error.ANError;\n\nimport java.io.File;\n\n/**\n * Created by Prashant Gupta on 29-07-2016.\n */\npublic class Utils {\n\n    public static String getRootDirPath(Context context) {\n        if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {\n            File file = ContextCompat.getExternalFilesDirs(context.getApplicationContext(), null)[0];\n            return file.getAbsolutePath();\n        } else {\n            return context.getApplicationContext().getFilesDir().getAbsolutePath();\n        }\n    }\n\n    public static void logError(String TAG, Throwable e) {\n        if (e instanceof ANError) {\n            ANError anError = (ANError) e;\n            if (anError.getErrorCode() != 0) {\n                // received ANError from server\n                // error.getErrorCode() - the ANError code from server\n                // error.getErrorBody() - the ANError body from server\n                // error.getErrorDetail() - just a ANError detail\n                Log.d(TAG, \"onError errorCode : \" + anError.getErrorCode());\n                Log.d(TAG, \"onError errorBody : \" + anError.getErrorBody());\n                Log.d(TAG, \"onError errorDetail : \" + anError.getErrorDetail());\n            } else {\n                // error.getErrorDetail() : connectionError, parseError, requestCancelledError\n                Log.d(TAG, \"onError errorDetail : \" + anError.getErrorDetail());\n            }\n        } else {\n            Log.d(TAG, \"onError errorMessage : \" + e.getMessage());\n        }\n    }\n\n}\n"
  },
  {
    "path": "rx2sampleapp/src/main/res/layout/activity_rx_api_test.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?><!--\n  ~    Copyright (C) 2016 Amit Shekhar\n  ~    Copyright (C) 2011 Android Open Source Project\n  ~\n  ~    Licensed under the Apache License, Version 2.0 (the \"License\");\n  ~    you may not use this file except in compliance with the License.\n  ~    You may obtain a copy of the License at\n  ~\n  ~        http://www.apache.org/licenses/LICENSE-2.0\n  ~\n  ~    Unless required by applicable law or agreed to in writing, software\n  ~    distributed under the License is distributed on an \"AS IS\" BASIS,\n  ~    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  ~    See the License for the specific language governing permissions and\n  ~    limitations under the License.\n  -->\n\n<ScrollView xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\">\n\n    <LinearLayout\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"\n        android:orientation=\"vertical\"\n        android:paddingBottom=\"@dimen/activity_vertical_margin\"\n        android:paddingLeft=\"@dimen/activity_horizontal_margin\"\n        android:paddingRight=\"@dimen/activity_horizontal_margin\"\n        android:paddingTop=\"@dimen/activity_vertical_margin\">\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <Button\n            android:id=\"@+id/getAllUsers\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"getAllUsers\"\n            android:text=\"/getAllUsers/{pageNumber}\" />\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <Button\n            android:id=\"@+id/getAnUser\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"getAnUser\"\n            android:text=\"/getAnUser/{userId}\" />\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <Button\n            android:id=\"@+id/checkForHeaderGet\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"checkForHeaderGet\"\n            android:text=\"GET : checkForHeader\" />\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <Button\n            android:id=\"@+id/checkForHeaderPost\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"checkForHeaderPost\"\n            android:text=\"POST : checkForHeader\" />\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <Button\n            android:id=\"@+id/createAnUser\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"createAnUser\"\n            android:text=\"/createAnUser\" />\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <Button\n            android:id=\"@+id/createAnUserJSONObject\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"createAnUserJSONObject\"\n            android:text=\"/createAnUserJSONObject\" />\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <Button\n            android:id=\"@+id/downloadFile\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"downloadFile\"\n            android:text=\"downloadFile\" />\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <Button\n            android:id=\"@+id/downloadImage\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"downloadImage\"\n            android:text=\"downloadImage\" />\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <Button\n            android:id=\"@+id/uploadImage\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"uploadImage\"\n            android:text=\"uploadImage\" />\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <Button\n            android:id=\"@+id/getCurrentConnectionQuality\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"getCurrentConnectionQuality\"\n            android:text=\"getCurrentConnectionQuality\" />\n\n        <Button\n            android:id=\"@+id/loadImage\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"loadImage\"\n            android:text=\"loadImage\" />\n\n        <ImageView\n            android:id=\"@+id/imageView\"\n            android:layout_width=\"200dp\"\n            android:layout_height=\"200dp\"\n            android:layout_gravity=\"center\" />\n\n    </LinearLayout>\n\n</ScrollView>"
  },
  {
    "path": "rx2sampleapp/src/main/res/layout/activity_rx_operator_example.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?><!--\n  ~ /*\n  ~  *    Copyright (C) 2016 Amit Shekhar\n  ~  *    Copyright (C) 2011 Android Open Source Project\n  ~  *\n  ~  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n  ~  *    you may not use this file except in compliance with the License.\n  ~  *    You may obtain a copy of the License at\n  ~  *\n  ~  *        http://www.apache.org/licenses/LICENSE-2.0\n  ~  *\n  ~  *    Unless required by applicable law or agreed to in writing, software\n  ~  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n  ~  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  ~  *    See the License for the specific language governing permissions and\n  ~  *    limitations under the License.\n  ~  */\n  -->\n\n<ScrollView xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\">\n\n    <LinearLayout\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"\n        android:orientation=\"vertical\"\n        android:paddingBottom=\"@dimen/activity_vertical_margin\"\n        android:paddingLeft=\"@dimen/activity_horizontal_margin\"\n        android:paddingRight=\"@dimen/activity_horizontal_margin\"\n        android:paddingTop=\"@dimen/activity_vertical_margin\">\n\n        <Button\n            android:id=\"@+id/map\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"map\"\n            android:text=\"map\" />\n\n        <Button\n            android:id=\"@+id/zip\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"zip\"\n            android:text=\"zip\" />\n\n        <Button\n            android:id=\"@+id/flatMapAndFilter\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"flatMapAndFilter\"\n            android:text=\"flatMapAndFilter\" />\n\n        <Button\n            android:id=\"@+id/take\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"take\"\n            android:text=\"take\" />\n\n        <Button\n            android:id=\"@+id/flatMap\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"flatMap\"\n            android:text=\"flatMap\" />\n\n        <Button\n            android:id=\"@+id/flatMapWithZip\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"flatMapWithZip\"\n            android:text=\"flatMapWithZip\" />\n\n        <Button\n            android:id=\"@+id/startRxApiTestActivity\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"startRxApiTestActivity\"\n            android:text=\"startRxApiTestActivity\" />\n\n        <Button\n            android:id=\"@+id/startSubscriptionActivity\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"startSubscriptionActivity\"\n            android:text=\"startSubscriptionActivity\" />\n\n\n    </LinearLayout>\n\n</ScrollView>"
  },
  {
    "path": "rx2sampleapp/src/main/res/layout/activity_subscription.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?><!--\n  ~ /*\n  ~  *    Copyright (C) 2016 Amit Shekhar\n  ~  *    Copyright (C) 2011 Android Open Source Project\n  ~  *\n  ~  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n  ~  *    you may not use this file except in compliance with the License.\n  ~  *    You may obtain a copy of the License at\n  ~  *\n  ~  *        http://www.apache.org/licenses/LICENSE-2.0\n  ~  *\n  ~  *    Unless required by applicable law or agreed to in writing, software\n  ~  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n  ~  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  ~  *    See the License for the specific language governing permissions and\n  ~  *    limitations under the License.\n  ~  */\n  -->\n\n<ScrollView xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\">\n\n    <LinearLayout\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"\n        android:orientation=\"vertical\"\n        android:paddingBottom=\"@dimen/activity_vertical_margin\"\n        android:paddingLeft=\"@dimen/activity_horizontal_margin\"\n        android:paddingRight=\"@dimen/activity_horizontal_margin\"\n        android:paddingTop=\"@dimen/activity_vertical_margin\">\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <Button\n            android:id=\"@+id/downloadFile\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"downloadFile\"\n            android:text=\"downloadFile\" />\n\n\n    </LinearLayout>\n\n</ScrollView>"
  },
  {
    "path": "rx2sampleapp/src/main/res/values/colors.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n  ~ /*\n  ~  *    Copyright (C) 2016 Amit Shekhar\n  ~  *    Copyright (C) 2011 Android Open Source Project\n  ~  *\n  ~  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n  ~  *    you may not use this file except in compliance with the License.\n  ~  *    You may obtain a copy of the License at\n  ~  *\n  ~  *        http://www.apache.org/licenses/LICENSE-2.0\n  ~  *\n  ~  *    Unless required by applicable law or agreed to in writing, software\n  ~  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n  ~  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  ~  *    See the License for the specific language governing permissions and\n  ~  *    limitations under the License.\n  ~  */\n  -->\n\n<resources>\n    <color name=\"colorPrimary\">#3F51B5</color>\n    <color name=\"colorPrimaryDark\">#303F9F</color>\n    <color name=\"colorAccent\">#FF4081</color>\n</resources>\n"
  },
  {
    "path": "rx2sampleapp/src/main/res/values/dimens.xml",
    "content": "<!--\n  ~ /*\n  ~  *    Copyright (C) 2016 Amit Shekhar\n  ~  *    Copyright (C) 2011 Android Open Source Project\n  ~  *\n  ~  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n  ~  *    you may not use this file except in compliance with the License.\n  ~  *    You may obtain a copy of the License at\n  ~  *\n  ~  *        http://www.apache.org/licenses/LICENSE-2.0\n  ~  *\n  ~  *    Unless required by applicable law or agreed to in writing, software\n  ~  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n  ~  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  ~  *    See the License for the specific language governing permissions and\n  ~  *    limitations under the License.\n  ~  */\n  -->\n\n<resources>\n    <!-- Default screen margins, per the Android Design guidelines. -->\n    <dimen name=\"activity_horizontal_margin\">16dp</dimen>\n    <dimen name=\"activity_vertical_margin\">16dp</dimen>\n</resources>\n"
  },
  {
    "path": "rx2sampleapp/src/main/res/values/strings.xml",
    "content": "<!--\n  ~ /*\n  ~  *    Copyright (C) 2016 Amit Shekhar\n  ~  *    Copyright (C) 2011 Android Open Source Project\n  ~  *\n  ~  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n  ~  *    you may not use this file except in compliance with the License.\n  ~  *    You may obtain a copy of the License at\n  ~  *\n  ~  *        http://www.apache.org/licenses/LICENSE-2.0\n  ~  *\n  ~  *    Unless required by applicable law or agreed to in writing, software\n  ~  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n  ~  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  ~  *    See the License for the specific language governing permissions and\n  ~  *    limitations under the License.\n  ~  */\n  -->\n\n<resources>\n    <string name=\"app_name\">Rx2SampleApp</string>\n</resources>\n"
  },
  {
    "path": "rx2sampleapp/src/main/res/values/styles.xml",
    "content": "<!--\n  ~ /*\n  ~  *    Copyright (C) 2016 Amit Shekhar\n  ~  *    Copyright (C) 2011 Android Open Source Project\n  ~  *\n  ~  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n  ~  *    you may not use this file except in compliance with the License.\n  ~  *    You may obtain a copy of the License at\n  ~  *\n  ~  *        http://www.apache.org/licenses/LICENSE-2.0\n  ~  *\n  ~  *    Unless required by applicable law or agreed to in writing, software\n  ~  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n  ~  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  ~  *    See the License for the specific language governing permissions and\n  ~  *    limitations under the License.\n  ~  */\n  -->\n\n<resources>\n\n    <!-- Base application theme. -->\n    <style name=\"AppTheme\" parent=\"Theme.AppCompat.Light.DarkActionBar\">\n        <!-- Customize your theme here. -->\n        <item name=\"colorPrimary\">@color/colorPrimary</item>\n        <item name=\"colorPrimaryDark\">@color/colorPrimaryDark</item>\n        <item name=\"colorAccent\">@color/colorAccent</item>\n    </style>\n\n</resources>\n"
  },
  {
    "path": "rx2sampleapp/src/main/res/values-w820dp/dimens.xml",
    "content": "<!--\n  ~ /*\n  ~  *    Copyright (C) 2016 Amit Shekhar\n  ~  *    Copyright (C) 2011 Android Open Source Project\n  ~  *\n  ~  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n  ~  *    you may not use this file except in compliance with the License.\n  ~  *    You may obtain a copy of the License at\n  ~  *\n  ~  *        http://www.apache.org/licenses/LICENSE-2.0\n  ~  *\n  ~  *    Unless required by applicable law or agreed to in writing, software\n  ~  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n  ~  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  ~  *    See the License for the specific language governing permissions and\n  ~  *    limitations under the License.\n  ~  */\n  -->\n\n<resources>\n    <!-- Example customization of dimensions originally defined in res/values/dimens.xml\n         (such as screen margins) for screens with more than 820dp of available width. This\n         would include 7\" and 10\" devices in landscape (~960dp and ~1280dp respectively). -->\n    <dimen name=\"activity_horizontal_margin\">64dp</dimen>\n</resources>\n"
  },
  {
    "path": "rx2sampleapp/src/test/java/com/rx2sampleapp/ExampleUnitTest.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.rx2sampleapp;\n\nimport org.junit.Test;\n\nimport static org.junit.Assert.*;\n\n/**\n * Example local unit test, which will execute on the development machine (host).\n *\n * @see <a href=\"http://d.android.com/tools/testing\">Testing documentation</a>\n */\npublic class ExampleUnitTest {\n    @Test\n    public void addition_isCorrect() throws Exception {\n        assertEquals(4, 2 + 2);\n    }\n}"
  },
  {
    "path": "rxsampleapp/.gitignore",
    "content": "/build\n"
  },
  {
    "path": "rxsampleapp/build.gradle",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\napply plugin: 'com.android.application'\n\nandroid {\n    compileSdkVersion rootProject.ext.compileSdkVersion\n    buildToolsVersion rootProject.ext.buildToolsVersion\n\n    defaultConfig {\n        applicationId \"com.rxsampleapp\"\n        minSdkVersion rootProject.ext.minSdkVersion\n        targetSdkVersion rootProject.ext.targetSdkVersion\n        versionCode 1\n        versionName \"1.0\"\n    }\n    buildTypes {\n        release {\n            minifyEnabled false\n            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'\n        }\n    }\n}\n\ndependencies {\n    implementation fileTree(dir: 'libs', include: ['*.jar'])\n    testImplementation \"junit:junit:$rootProject.ext.jUnitVersion\"\n    implementation \"com.android.support:appcompat-v7:$rootProject.ext.supportAppCompatVersion\"\n    implementation project(':rx-android-networking')\n}\n"
  },
  {
    "path": "rxsampleapp/proguard-rules.pro",
    "content": "# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in C:\\Users\\Psych Inc\\AppData\\Local\\Android\\sdk/tools/proguard/proguard-android.txt\n# You can edit the include path and order by changing the proguardFiles\n# directive in build.gradle.\n#\n# For more details, see\n#   http://developer.android.com/guide/developing/tools/proguard.html\n\n# Add any project specific keep options here:\n\n# If your project uses WebView with JS, uncomment the following\n# and specify the fully qualified class name to the JavaScript interface\n# class:\n#-keepclassmembers class fqcn.of.javascript.interface.for.webview {\n#   public *;\n#}\n"
  },
  {
    "path": "rxsampleapp/src/androidTest/java/com/rxsampleapp/ApplicationTest.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.rxsampleapp;\n\nimport android.app.Application;\nimport android.test.ApplicationTestCase;\n\n/**\n * <a href=\"http://d.android.com/tools/testing/testing_android.html\">Testing Fundamentals</a>\n */\npublic class ApplicationTest extends ApplicationTestCase<Application> {\n    public ApplicationTest() {\n        super(Application.class);\n    }\n}"
  },
  {
    "path": "rxsampleapp/src/main/AndroidManifest.xml",
    "content": "<!--\n  ~    Copyright (C) 2016 Amit Shekhar\n  ~    Copyright (C) 2011 Android Open Source Project\n  ~\n  ~    Licensed under the Apache License, Version 2.0 (the \"License\");\n  ~    you may not use this file except in compliance with the License.\n  ~    You may obtain a copy of the License at\n  ~\n  ~        http://www.apache.org/licenses/LICENSE-2.0\n  ~\n  ~    Unless required by applicable law or agreed to in writing, software\n  ~    distributed under the License is distributed on an \"AS IS\" BASIS,\n  ~    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  ~    See the License for the specific language governing permissions and\n  ~    limitations under the License.\n  -->\n\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    package=\"com.rxsampleapp\">\n\n    <uses-permission android:name=\"android.permission.INTERNET\" />\n    <uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\" />\n\n    <application\n        android:name=\".RxMyApplication\"\n        android:allowBackup=\"true\"\n        android:icon=\"@mipmap/ic_launcher\"\n        android:label=\"@string/app_name\"\n        android:supportsRtl=\"true\"\n        android:theme=\"@style/AppTheme\">\n        <activity android:name=\".RxOperatorExampleActivity\">\n            <intent-filter>\n                <action android:name=\"android.intent.action.MAIN\" />\n\n                <category android:name=\"android.intent.category.LAUNCHER\" />\n            </intent-filter>\n        </activity>\n        <activity android:name=\".RxApiTestActivity\"></activity>\n        <activity android:name=\".SubscriptionActivity\"></activity>\n    </application>\n\n</manifest>\n"
  },
  {
    "path": "rxsampleapp/src/main/java/com/rxsampleapp/ApiEndPoint.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.rxsampleapp;\n\n/**\n * Created by amitshekhar on 29/03/16.\n */\npublic class ApiEndPoint {\n\n    public static final String BASE_URL = \"https://fierce-cove-29863.herokuapp.com\";\n    public static final String GET_JSON_ARRAY = \"/getAllUsers/{pageNumber}\";\n    public static final String GET_JSON_OBJECT = \"/getAnUserDetail/{userId}\";\n    public static final String CHECK_FOR_HEADER = \"/checkForHeader\";\n    public static final String POST_CREATE_AN_USER = \"/createAnUser\";\n    public static final String UPLOAD_IMAGE = \"/uploadImage\";\n\n}\n"
  },
  {
    "path": "rxsampleapp/src/main/java/com/rxsampleapp/RxApiTestActivity.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\npackage com.rxsampleapp;\n\nimport android.graphics.Bitmap;\nimport android.os.Bundle;\nimport android.os.Environment;\nimport android.os.Looper;\nimport android.support.annotation.Nullable;\nimport android.support.v7.app.AppCompatActivity;\nimport android.util.Log;\nimport android.view.View;\nimport android.widget.ImageView;\n\nimport com.androidnetworking.AndroidNetworking;\nimport com.androidnetworking.error.ANError;\nimport com.androidnetworking.interfaces.AnalyticsListener;\nimport com.androidnetworking.interfaces.DownloadProgressListener;\nimport com.androidnetworking.interfaces.UploadProgressListener;\nimport com.rxandroidnetworking.RxANRequest;\nimport com.rxandroidnetworking.RxAndroidNetworking;\nimport com.rxsampleapp.model.User;\nimport com.rxsampleapp.utils.Utils;\n\nimport org.json.JSONException;\nimport org.json.JSONObject;\n\nimport java.io.File;\nimport java.util.List;\n\nimport rx.Observer;\nimport rx.Subscriber;\nimport rx.android.schedulers.AndroidSchedulers;\nimport rx.schedulers.Schedulers;\n\n/**\n * Created by Prashant Gupta on 25-07-2016.\n */\npublic class RxApiTestActivity extends AppCompatActivity {\n\n    private static final String TAG = RxApiTestActivity.class.getSimpleName();\n\n    @Override\n    protected void onCreate(@Nullable Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_rx_api_test);\n    }\n\n    public void getAllUsers(View view) {\n        RxAndroidNetworking.get(ApiEndPoint.BASE_URL + ApiEndPoint.GET_JSON_ARRAY)\n                .addPathParameter(\"pageNumber\", \"0\")\n                .addQueryParameter(\"limit\", \"3\")\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .getObjectListObservable(User.class)\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new Observer<List<User>>() {\n                    @Override\n                    public void onCompleted() {\n                        Log.d(TAG, \"onComplete Detail : getAllUsers completed\");\n                    }\n\n                    @Override\n                    public void onError(Throwable e) {\n                        Utils.logError(TAG, e);\n                    }\n\n                    @Override\n                    public void onNext(List<User> users) {\n                        Log.d(TAG, \"onResponse isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                        Log.d(TAG, \"userList size : \" + users.size());\n                        for (User user : users) {\n                            Log.d(TAG, \"id : \" + user.id);\n                            Log.d(TAG, \"firstname : \" + user.firstname);\n                            Log.d(TAG, \"lastname : \" + user.lastname);\n                        }\n                    }\n                });\n    }\n\n    public void getAnUser(View view) {\n        RxAndroidNetworking.get(ApiEndPoint.BASE_URL + ApiEndPoint.GET_JSON_OBJECT)\n                .addPathParameter(\"userId\", \"1\")\n                .setUserAgent(\"getAnUser\")\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .getObjectObservable(User.class)\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new Observer<User>() {\n                    @Override\n                    public void onCompleted() {\n                        Log.d(TAG, \"onComplete Detail : getAnUser completed\");\n                    }\n\n                    @Override\n                    public void onError(Throwable e) {\n                        Utils.logError(TAG, e);\n                    }\n\n                    @Override\n                    public void onNext(User user) {\n                        Log.d(TAG, \"onResponse isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                        Log.d(TAG, \"id : \" + user.id);\n                        Log.d(TAG, \"firstname : \" + user.firstname);\n                        Log.d(TAG, \"lastname : \" + user.lastname);\n                    }\n                });\n    }\n\n    public void checkForHeaderGet(View view) {\n\n        RxANRequest.GetRequestBuilder getRequestBuilder = new RxANRequest.GetRequestBuilder(ApiEndPoint.BASE_URL + ApiEndPoint.CHECK_FOR_HEADER);\n\n        getRequestBuilder.addHeaders(\"token\", \"1234\")\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .getJSONObjectObservable()\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new Observer<JSONObject>() {\n                    @Override\n                    public void onCompleted() {\n                        Log.d(TAG, \"onComplete Detail : checkForHeaderGet completed\");\n                    }\n\n                    @Override\n                    public void onError(Throwable e) {\n                        if (e instanceof ANError) {\n                            ANError anError = (ANError) e;\n                            if (anError.getErrorCode() != 0) {\n                                // received ANError from server\n                                // error.getErrorCode() - the ANError code from server\n                                // error.getErrorBody() - the ANError body from server\n                                // error.getErrorDetail() - just a ANError detail\n                                Log.d(TAG, \"onError errorCode : \" + anError.getErrorCode());\n                                Log.d(TAG, \"onError errorBody : \" + anError.getErrorBody());\n                                Log.d(TAG, \"onError errorDetail : \" + anError.getErrorDetail());\n                            } else {\n                                // error.getErrorDetail() : connectionError, parseError, requestCancelledError\n                                Log.d(TAG, \"onError errorDetail : \" + anError.getErrorDetail());\n                            }\n                        } else {\n                            Log.d(TAG, \"onError errorMessage : \" + e.getMessage());\n                        }\n                    }\n\n                    @Override\n                    public void onNext(JSONObject response) {\n                        Log.d(TAG, \"onResponse object : \" + response.toString());\n                        Log.d(TAG, \"onResponse isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                    }\n                });\n    }\n\n    public void checkForHeaderPost(View view) {\n\n        RxANRequest.PostRequestBuilder postRequestBuilder = RxAndroidNetworking.post(ApiEndPoint.BASE_URL + ApiEndPoint.CHECK_FOR_HEADER);\n\n        postRequestBuilder.addHeaders(\"token\", \"1234\");\n\n        RxANRequest rxAnRequest = postRequestBuilder.setTag(this)\n                .build();\n\n        rxAnRequest.setAnalyticsListener(new AnalyticsListener() {\n            @Override\n            public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                Log.d(TAG, \" bytesSent : \" + bytesSent);\n                Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                Log.d(TAG, \" isFromCache : \" + isFromCache);\n            }\n        });\n\n        rxAnRequest.getJSONObjectObservable()\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new Observer<JSONObject>() {\n                    @Override\n                    public void onCompleted() {\n                        Log.d(TAG, \"onComplete Detail : checkForHeaderPost completed\");\n                    }\n\n                    @Override\n                    public void onError(Throwable e) {\n                        if (e instanceof ANError) {\n                            ANError anError = (ANError) e;\n                            if (anError.getErrorCode() != 0) {\n                                // received ANError from server\n                                // error.getErrorCode() - the ANError code from server\n                                // error.getErrorBody() - the ANError body from server\n                                // error.getErrorDetail() - just a ANError detail\n                                Log.d(TAG, \"onError errorCode : \" + anError.getErrorCode());\n                                Log.d(TAG, \"onError errorBody : \" + anError.getErrorBody());\n                                Log.d(TAG, \"onError errorDetail : \" + anError.getErrorDetail());\n                            } else {\n                                // error.getErrorDetail() : connectionError, parseError, requestCancelledError\n                                Log.d(TAG, \"onError errorDetail : \" + anError.getErrorDetail());\n                            }\n                        } else {\n                            Log.d(TAG, \"onError errorMessage : \" + e.getMessage());\n                        }\n                    }\n\n                    @Override\n                    public void onNext(JSONObject response) {\n                        Log.d(TAG, \"onResponse object : \" + response.toString());\n                        Log.d(TAG, \"onResponse isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                    }\n                });\n    }\n\n    public void createAnUser(View view) {\n        RxAndroidNetworking.post(ApiEndPoint.BASE_URL + ApiEndPoint.POST_CREATE_AN_USER)\n                .addBodyParameter(\"firstname\", \"Amit\")\n                .addBodyParameter(\"lastname\", \"Shekhar\")\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .getJSONObjectObservable()\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new Observer<JSONObject>() {\n                    @Override\n                    public void onCompleted() {\n                        Log.d(TAG, \"onComplete Detail : createAnUser completed\");\n                    }\n\n                    @Override\n                    public void onError(Throwable e) {\n                        if (e instanceof ANError) {\n                            ANError anError = (ANError) e;\n                            if (anError.getErrorCode() != 0) {\n                                // received ANError from server\n                                // error.getErrorCode() - the ANError code from server\n                                // error.getErrorBody() - the ANError body from server\n                                // error.getErrorDetail() - just a ANError detail\n                                Log.d(TAG, \"onError errorCode : \" + anError.getErrorCode());\n                                Log.d(TAG, \"onError errorBody : \" + anError.getErrorBody());\n                                Log.d(TAG, \"onError errorDetail : \" + anError.getErrorDetail());\n                            } else {\n                                // error.getErrorDetail() : connectionError, parseError, requestCancelledError\n                                Log.d(TAG, \"onError errorDetail : \" + anError.getErrorDetail());\n                            }\n                        } else {\n                            Log.d(TAG, \"onError errorMessage : \" + e.getMessage());\n                        }\n                    }\n\n                    @Override\n                    public void onNext(JSONObject response) {\n                        Log.d(TAG, \"onResponse object : \" + response.toString());\n                        Log.d(TAG, \"onResponse isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                    }\n                });\n    }\n\n    public void createAnUserJSONObject(View view) {\n        JSONObject jsonObject = new JSONObject();\n        try {\n            jsonObject.put(\"firstname\", \"Rohit\");\n            jsonObject.put(\"lastname\", \"Kumar\");\n        } catch (JSONException e) {\n            e.printStackTrace();\n        }\n        RxAndroidNetworking.post(ApiEndPoint.BASE_URL + ApiEndPoint.POST_CREATE_AN_USER)\n                .addJSONObjectBody(jsonObject)\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .getJSONObjectObservable()\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new Subscriber<JSONObject>() {\n                    @Override\n                    public void onCompleted() {\n                        Log.d(TAG, \"onComplete Detail : createAnUserJSONObject completed\");\n                    }\n\n                    @Override\n                    public void onError(Throwable e) {\n                        if (e instanceof ANError) {\n                            ANError anError = (ANError) e;\n                            if (anError.getErrorCode() != 0) {\n                                // received ANError from server\n                                // error.getErrorCode() - the ANError code from server\n                                // error.getErrorBody() - the ANError body from server\n                                // error.getErrorDetail() - just a ANError detail\n                                Log.d(TAG, \"onError errorCode : \" + anError.getErrorCode());\n                                Log.d(TAG, \"onError errorBody : \" + anError.getErrorBody());\n                                Log.d(TAG, \"onError errorDetail : \" + anError.getErrorDetail());\n                            } else {\n                                // error.getErrorDetail() : connectionError, parseError, requestCancelledError\n                                Log.d(TAG, \"onError errorDetail : \" + anError.getErrorDetail());\n                            }\n                        } else {\n                            Log.d(TAG, \"onError errorMessage : \" + e.getMessage());\n                        }\n                    }\n\n                    @Override\n                    public void onNext(JSONObject response) {\n                        Log.d(TAG, \"onResponse object : \" + response.toString());\n                        Log.d(TAG, \"onResponse isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                    }\n                });\n    }\n\n    public void downloadFile(final View view) {\n        String url = \"http://www.colorado.edu/conflict/peace/download/peace_problem.ZIP\";\n        RxAndroidNetworking.download(url, Utils.getRootDirPath(getApplicationContext()), \"file1.zip\")\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .setDownloadProgressListener(new DownloadProgressListener() {\n                    @Override\n                    public void onProgress(long bytesDownloaded, long totalBytes) {\n                        Log.d(TAG, \"bytesDownloaded : \" + bytesDownloaded + \" totalBytes : \" + totalBytes);\n                        Log.d(TAG, \"setDownloadProgressListener isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                    }\n                })\n                .getDownloadObservable()\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new Observer<String>() {\n                    @Override\n                    public void onCompleted() {\n                        Log.d(TAG, \"File download Completed\");\n                        Log.d(TAG, \"onDownloadComplete isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                    }\n\n                    @Override\n                    public void onError(Throwable e) {\n                        if (e instanceof ANError) {\n                            ANError anError = (ANError) e;\n                            if (anError.getErrorCode() != 0) {\n                                // received ANError from server\n                                // error.getErrorCode() - the ANError code from server\n                                // error.getErrorBody() - the ANError body from server\n                                // error.getErrorDetail() - just a ANError detail\n                                Log.d(TAG, \"onError errorCode : \" + anError.getErrorCode());\n                                Log.d(TAG, \"onError errorBody : \" + anError.getErrorBody());\n                                Log.d(TAG, \"onError errorDetail : \" + anError.getErrorDetail());\n                            } else {\n                                // error.getErrorDetail() : connectionError, parseError, requestCancelledError\n                                Log.d(TAG, \"onError errorDetail : \" + anError.getErrorDetail());\n                            }\n                        } else {\n                            Log.d(TAG, \"onError errorMessage : \" + e.getMessage());\n                        }\n                    }\n\n                    @Override\n                    public void onNext(String s) {\n                        Log.d(TAG, \"onNext : \" + s);\n                    }\n                });\n    }\n\n    public void downloadImage(final View view) {\n        String url = \"http://i.imgur.com/AtbX9iX.png\";\n        RxAndroidNetworking.download(url, Utils.getRootDirPath(getApplicationContext()), \"image1.png\")\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .getDownloadObservable()\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new Observer<String>() {\n                    @Override\n                    public void onCompleted() {\n                        Log.d(TAG, \"File download Completed\");\n                        Log.d(TAG, \"onDownloadComplete isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                    }\n\n                    @Override\n                    public void onError(Throwable e) {\n                        if (e instanceof ANError) {\n                            ANError anError = (ANError) e;\n                            if (anError.getErrorCode() != 0) {\n                                // received ANError from server\n                                // error.getErrorCode() - the ANError code from server\n                                // error.getErrorBody() - the ANError body from server\n                                // error.getErrorDetail() - just a ANError detail\n                                Log.d(TAG, \"onError errorCode : \" + anError.getErrorCode());\n                                Log.d(TAG, \"onError errorBody : \" + anError.getErrorBody());\n                                Log.d(TAG, \"onError errorDetail : \" + anError.getErrorDetail());\n                            } else {\n                                // error.getErrorDetail() : connectionError, parseError, requestCancelledError\n                                Log.d(TAG, \"onError errorDetail : \" + anError.getErrorDetail());\n                            }\n                        } else {\n                            Log.d(TAG, \"onError errorMessage : \" + e.getMessage());\n                        }\n                    }\n\n                    @Override\n                    public void onNext(String s) {\n                        Log.d(TAG, \"onNext : \" + s);\n                    }\n                });\n    }\n\n    public void uploadImage(final View view) {\n        RxAndroidNetworking.upload(ApiEndPoint.BASE_URL + ApiEndPoint.UPLOAD_IMAGE)\n                .addMultipartFile(\"image\", new File(Environment.getExternalStorageDirectory().getAbsolutePath(), \"test.png\"))\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .setUploadProgressListener(new UploadProgressListener() {\n                    @Override\n                    public void onProgress(long bytesUploaded, long totalBytes) {\n                        Log.d(TAG, \"bytesUploaded : \" + bytesUploaded + \" totalBytes : \" + totalBytes);\n                        Log.d(TAG, \"setUploadProgressListener isMainThread : \" + String.valueOf(Looper.myLooper() == Looper.getMainLooper()));\n                    }\n                })\n                .getJSONObjectObservable()\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new Observer<JSONObject>() {\n                    @Override\n                    public void onCompleted() {\n                        Log.d(TAG, \"onComplete Detail : uploadImage completed\");\n                    }\n\n                    @Override\n                    public void onError(Throwable e) {\n                        if (e instanceof ANError) {\n                            ANError anError = (ANError) e;\n                            if (anError.getErrorCode() != 0) {\n                                // received ANError from server\n                                // error.getErrorCode() - the ANError code from server\n                                // error.getErrorBody() - the ANError body from server\n                                // error.getErrorDetail() - just a ANError detail\n                                Log.d(TAG, \"onError errorCode : \" + anError.getErrorCode());\n                                Log.d(TAG, \"onError errorBody : \" + anError.getErrorBody());\n                                Log.d(TAG, \"onError errorDetail : \" + anError.getErrorDetail());\n                            } else {\n                                // error.getErrorDetail() : connectionError, parseError, requestCancelledError\n                                Log.d(TAG, \"onError errorDetail : \" + anError.getErrorDetail());\n                            }\n                        } else {\n                            Log.d(TAG, \"onError errorMessage : \" + e.getMessage());\n                        }\n                    }\n\n                    @Override\n                    public void onNext(JSONObject response) {\n                        Log.d(TAG, \"Image upload Completed\");\n                        Log.d(TAG, \"onResponse object : \" + response.toString());\n                    }\n                });\n    }\n\n    public void getCurrentConnectionQuality(View view) {\n        Log.d(TAG, \"getCurrentConnectionQuality : \" + AndroidNetworking.getCurrentConnectionQuality() + \" currentBandwidth : \" + AndroidNetworking.getCurrentBandwidth());\n    }\n\n    public void loadImage(View view) {\n        final String URL_IMAGE = \"http://i.imgur.com/2M7Hasn.png\";\n        RxAndroidNetworking.get(URL_IMAGE)\n                .setImageScaleType(null)\n                .setBitmapMaxHeight(0)\n                .setBitmapMaxWidth(0)\n                .setBitmapConfig(Bitmap.Config.ARGB_8888)\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .getBitmapObservable()\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new Observer<Bitmap>() {\n                    @Override\n                    public void onCompleted() {\n                        Log.d(TAG, \"onComplete Bitmap\");\n\n\n                    }\n\n                    @Override\n                    public void onError(Throwable e) {\n                        if (e instanceof ANError) {\n                            ANError anError = (ANError) e;\n                            if (anError.getErrorCode() != 0) {\n                                // received ANError from server\n                                // error.getErrorCode() - the ANError code from server\n                                // error.getErrorBody() - the ANError body from server\n                                // error.getErrorDetail() - just a ANError detail\n                                Log.d(TAG, \"onError errorCode : \" + anError.getErrorCode());\n                                Log.d(TAG, \"onError errorBody : \" + anError.getErrorBody());\n                                Log.d(TAG, \"onError errorDetail : \" + anError.getErrorDetail());\n                            } else {\n                                // error.getErrorDetail() : connectionError, parseError, requestCancelledError\n                                Log.d(TAG, \"onError errorDetail : \" + anError.getErrorDetail());\n                            }\n                        } else {\n                            Log.d(TAG, \"onError errorMessage : \" + e.getMessage());\n                        }\n                    }\n\n                    @Override\n                    public void onNext(Bitmap bitmap) {\n                        Log.d(TAG, \"onResponse Bitmap\");\n                        ImageView imageView = (ImageView) findViewById(R.id.imageView);\n                        imageView.setImageBitmap(bitmap);\n                    }\n                });\n\n    }\n\n}\n"
  },
  {
    "path": "rxsampleapp/src/main/java/com/rxsampleapp/RxMyApplication.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\npackage com.rxsampleapp;\n\nimport android.app.Application;\nimport android.util.Log;\n\nimport com.androidnetworking.AndroidNetworking;\nimport com.androidnetworking.common.ConnectionQuality;\nimport com.androidnetworking.interfaces.ConnectionQualityChangeListener;\n\npublic class RxMyApplication extends Application {\n\n    private static final String TAG = RxMyApplication.class.getSimpleName();\n    private static RxMyApplication appInstance = null;\n\n    public static RxMyApplication getInstance() {\n        return appInstance;\n    }\n\n    @Override\n    public void onCreate() {\n        super.onCreate();\n        appInstance = this;\n        AndroidNetworking.initialize(getApplicationContext());\n        AndroidNetworking.enableLogging();\n        AndroidNetworking.setConnectionQualityChangeListener(new ConnectionQualityChangeListener() {\n            @Override\n            public void onChange(ConnectionQuality currentConnectionQuality, int currentBandwidth) {\n                Log.d(TAG, \"onChange: currentConnectionQuality : \" + currentConnectionQuality + \" currentBandwidth : \" + currentBandwidth);\n            }\n        });\n    }\n\n}"
  },
  {
    "path": "rxsampleapp/src/main/java/com/rxsampleapp/RxOperatorExampleActivity.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.rxsampleapp;\n\nimport android.content.Intent;\nimport android.os.Bundle;\nimport android.support.v7.app.AppCompatActivity;\nimport android.util.Log;\nimport android.util.Pair;\nimport android.view.View;\n\nimport com.androidnetworking.interfaces.AnalyticsListener;\nimport com.google.gson.reflect.TypeToken;\nimport com.rxandroidnetworking.RxAndroidNetworking;\nimport com.rxsampleapp.model.ApiUser;\nimport com.rxsampleapp.model.User;\nimport com.rxsampleapp.model.UserDetail;\nimport com.rxsampleapp.utils.Utils;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\nimport rx.Observable;\nimport rx.Observer;\nimport rx.android.schedulers.AndroidSchedulers;\nimport rx.functions.Func1;\nimport rx.functions.Func2;\nimport rx.schedulers.Schedulers;\n\n/**\n * Created by amitshekhar on 31/07/16.\n */\npublic class RxOperatorExampleActivity extends AppCompatActivity {\n\n    private static final String TAG = RxOperatorExampleActivity.class.getSimpleName();\n\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_rx_operator_example);\n        testApi();\n    }\n\n    @Override\n    protected void onDestroy() {\n        super.onDestroy();\n    }\n\n    /************************************\n     * Just an test api start\n     ************************************/\n\n    private void testApi() {\n        RxAndroidNetworking.get(\"https://fierce-cove-29863.herokuapp.com/getAllUsers/{pageNumber}\")\n                .addPathParameter(\"pageNumber\", \"0\")\n                .addQueryParameter(\"limit\", \"3\")\n                .build()\n                .setAnalyticsListener(new AnalyticsListener() {\n                    @Override\n                    public void onReceived(long timeTakenInMillis, long bytesSent, long bytesReceived, boolean isFromCache) {\n                        Log.d(TAG, \" timeTakenInMillis : \" + timeTakenInMillis);\n                        Log.d(TAG, \" bytesSent : \" + bytesSent);\n                        Log.d(TAG, \" bytesReceived : \" + bytesReceived);\n                        Log.d(TAG, \" isFromCache : \" + isFromCache);\n                    }\n                })\n                .getParseObservable(new TypeToken<List<User>>() {\n                })\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new Observer<List<User>>() {\n                    @Override\n                    public void onCompleted() {\n                        Log.d(TAG, \"onComplete Detail : getAllUsers completed\");\n                    }\n\n                    @Override\n                    public void onError(Throwable e) {\n                        Utils.logError(TAG, e);\n                    }\n\n                    @Override\n                    public void onNext(List<User> users) {\n                        Log.d(TAG, \"userList size : \" + users.size());\n                        for (User user : users) {\n                            Log.d(TAG, \"id : \" + user.id);\n                            Log.d(TAG, \"firstname : \" + user.firstname);\n                            Log.d(TAG, \"lastname : \" + user.lastname);\n                        }\n                    }\n                });\n    }\n\n    /************************************\n     * map operator start\n     ************************************/\n\n    public void map(View view) {\n        RxAndroidNetworking.get(\"https://fierce-cove-29863.herokuapp.com/getAnUser/{userId}\")\n                .addPathParameter(\"userId\", \"1\")\n                .build()\n                .getParseObservable(new TypeToken<ApiUser>() {\n                })\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .map(new Func1<ApiUser, User>() {\n                    @Override\n                    public User call(ApiUser apiUser) {\n                        // here we get ApiUser from server\n                        User user = new User(apiUser);\n                        // then by converting, we are returning user\n                        return user;\n                    }\n                })\n                .subscribe(new Observer<User>() {\n                    @Override\n                    public void onCompleted() {\n                        // do anything onComplete\n                    }\n\n                    @Override\n                    public void onError(Throwable e) {\n                        // handle error\n                        Utils.logError(TAG, e);\n                    }\n\n                    @Override\n                    public void onNext(User user) {\n                        Log.d(TAG, \"user id : \" + user.id);\n                        Log.d(TAG, \"user firstname : \" + user.firstname);\n                        Log.d(TAG, \"user lastname : \" + user.lastname);\n                    }\n                });\n    }\n\n\n    /************************************\n     * zip operator start\n     *********************************/\n\n    /*\n    * This observable return the list of User who loves cricket\n    */\n    private Observable<List<User>> getCricketFansObservable() {\n        return RxAndroidNetworking.get(\"https://fierce-cove-29863.herokuapp.com/getAllCricketFans\")\n                .build()\n                .getParseObservable(new TypeToken<List<User>>() {\n                });\n    }\n\n    /*\n    * This observable return the list of User who loves Football\n    */\n    private Observable<List<User>> getFootballFansObservable() {\n        return RxAndroidNetworking.get(\"https://fierce-cove-29863.herokuapp.com/getAllFootballFans\")\n                .build()\n                .getParseObservable(new TypeToken<List<User>>() {\n                });\n    }\n\n    /*\n    * This do the complete magic, make both network call\n    * and then returns the list of user who loves both\n    * Using zip operator to get both response at a time\n    */\n    private void findUsersWhoLovesBoth() {\n        // here we are using zip operator to combine both request\n        Observable.zip(getCricketFansObservable(), getFootballFansObservable(),\n                new Func2<List<User>, List<User>, List<User>>() {\n                    @Override\n                    public List<User> call(List<User> cricketFans,\n                                           List<User> footballFans) {\n                        List<User> userWhoLovesBoth =\n                                filterUserWhoLovesBoth(cricketFans, footballFans);\n                        return userWhoLovesBoth;\n                    }\n                }\n        ).subscribeOn(Schedulers.newThread())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new Observer<List<User>>() {\n                    @Override\n                    public void onCompleted() {\n                        // do anything onComplete\n                    }\n\n                    @Override\n                    public void onError(Throwable e) {\n                        // handle error\n                    }\n\n                    @Override\n                    public void onNext(List<User> users) {\n                        // do anything with user who loves both\n                        Log.d(TAG, \"userList size : \" + users.size());\n                        for (User user : users) {\n                            Log.d(TAG, \"id : \" + user.id);\n                            Log.d(TAG, \"firstname : \" + user.firstname);\n                            Log.d(TAG, \"lastname : \" + user.lastname);\n                        }\n                    }\n                });\n    }\n\n    private List<User> filterUserWhoLovesBoth(List<User> cricketFans, List<User> footballFans) {\n        List<User> userWhoLovesBoth = new ArrayList<User>();\n        for (User cricketFan : cricketFans) {\n            for (User footballFan : footballFans) {\n                if (cricketFan.id == footballFan.id) {\n                    userWhoLovesBoth.add(cricketFan);\n                }\n            }\n        }\n        return userWhoLovesBoth;\n    }\n\n\n    public void zip(View view) {\n        findUsersWhoLovesBoth();\n    }\n\n    /************************************\n     * flatMap and filter operator start\n     ************************************/\n\n    private Observable<List<User>> getAllMyFriendsObservable() {\n        return RxAndroidNetworking.get(\"https://fierce-cove-29863.herokuapp.com/getAllFriends/{userId}\")\n                .addPathParameter(\"userId\", \"1\")\n                .build()\n                .getParseObservable(new TypeToken<List<User>>() {\n                });\n    }\n\n    public void flatMapAndFilter(View view) {\n        getAllMyFriendsObservable()\n                .flatMap(new Func1<List<User>, Observable<User>>() { // flatMap - to return users one by one\n                    @Override\n                    public Observable<User> call(List<User> usersList) {\n                        return Observable.from(usersList); // returning user one by one from usersList.\n                    }\n                })\n                .filter(new Func1<User, Boolean>() {\n                    @Override\n                    public Boolean call(User user) {\n                        // filtering user who follows me.\n                        return user.isFollowing;\n                    }\n                })\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new Observer<User>() {\n                    @Override\n                    public void onCompleted() {\n                        // do anything onComplete\n                    }\n\n                    @Override\n                    public void onError(Throwable e) {\n                        // handle error\n                    }\n\n                    @Override\n                    public void onNext(User user) {\n                        // only the user who is following me comes here one by one\n                        Log.d(TAG, \"id : \" + user.id);\n                        Log.d(TAG, \"firstname : \" + user.firstname);\n                        Log.d(TAG, \"lastname : \" + user.lastname);\n                        Log.d(TAG, \"isFollowing : \" + user.isFollowing);\n                    }\n                });\n    }\n\n    /************************************\n     * take operator start\n     ************************************/\n\n    public void take(View view) {\n        getUserListObservable()\n                .flatMap(new Func1<List<User>, Observable<User>>() { // flatMap - to return users one by one\n                    @Override\n                    public Observable<User> call(List<User> usersList) {\n                        return Observable.from(usersList); // returning user one by one from usersList.\n                    }\n                })\n                .take(4) // it will only emit first 4 users out of all\n                .subscribeOn(Schedulers.newThread())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new Observer<User>() {\n                    @Override\n                    public void onCompleted() {\n\n                    }\n\n                    @Override\n                    public void onError(Throwable e) {\n\n                    }\n\n                    @Override\n                    public void onNext(User user) {\n                        // only four user comes here one by one\n                        Log.d(TAG, \"id : \" + user.id);\n                        Log.d(TAG, \"firstname : \" + user.firstname);\n                        Log.d(TAG, \"lastname : \" + user.lastname);\n                        Log.d(TAG, \"isFollowing : \" + user.isFollowing);\n                    }\n                });\n    }\n\n\n    /************************************\n     * flatMap operator start\n     ************************************/\n\n\n    public void flatMap(View view) {\n        getUserListObservable()\n                .flatMap(new Func1<List<User>, Observable<User>>() { // flatMap - to return users one by one\n                    @Override\n                    public Observable<User> call(List<User> usersList) {\n                        return Observable.from(usersList); // returning user one by one from usersList.\n                    }\n                })\n                .flatMap(new Func1<User, Observable<UserDetail>>() {\n                    @Override\n                    public Observable<UserDetail> call(User user) {\n                        // here we get the user one by one\n                        // and returns corresponding getUserDetailObservable\n                        // for that userId\n                        return getUserDetailObservable(user.id);\n                    }\n                })\n                .subscribeOn(Schedulers.newThread())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new Observer<UserDetail>() {\n                    @Override\n                    public void onCompleted() {\n                        // do something onCompleted\n                    }\n\n                    @Override\n                    public void onError(Throwable e) {\n                        // handle error\n                        Utils.logError(TAG, e);\n                    }\n\n                    @Override\n                    public void onNext(UserDetail userDetail) {\n                        // do anything with userDetail\n                        Log.d(TAG, \"userDetail id : \" + userDetail.id);\n                        Log.d(TAG, \"userDetail firstname : \" + userDetail.firstname);\n                        Log.d(TAG, \"userDetail lastname : \" + userDetail.lastname);\n                    }\n                });\n    }\n\n    /************************************\n     * flatMapWithZip operator start\n     ************************************/\n\n    private Observable<List<User>> getUserListObservable() {\n        return RxAndroidNetworking.get(\"https://fierce-cove-29863.herokuapp.com/getAllUsers/{pageNumber}\")\n                .addPathParameter(\"pageNumber\", \"0\")\n                .addQueryParameter(\"limit\", \"10\")\n                .build()\n                .getParseObservable(new TypeToken<List<User>>() {\n                });\n    }\n\n    private Observable<UserDetail> getUserDetailObservable(long id) {\n        return RxAndroidNetworking.get(\"https://fierce-cove-29863.herokuapp.com/getAnUserDetail/{userId}\")\n                .addPathParameter(\"userId\", String.valueOf(id))\n                .build()\n                .getParseObservable(new TypeToken<UserDetail>() {\n                });\n    }\n\n    public void flatMapWithZip(View view) {\n        getUserListObservable()\n                .flatMap(new Func1<List<User>, Observable<User>>() { // flatMap - to return users one by one\n                    @Override\n                    public Observable<User> call(List<User> usersList) {\n                        return Observable.from(usersList); // returning user one by one from usersList.\n                    }\n                })\n                .flatMap(new Func1<User, Observable<Pair<UserDetail, User>>>() {\n                    @Override\n                    public Observable<Pair<UserDetail, User>> call(User user) {\n                        // here we get the user one by one and then we are zipping\n                        // two observable - one getUserDetailObservable (network call to get userDetail)\n                        // and another Observable.just(user) - just to emit user\n                        return Observable.zip(getUserDetailObservable(user.id), // zip to combine two observable\n                                Observable.just(user),\n                                new Func2<UserDetail, User, Pair<UserDetail, User>>() {\n                                    @Override\n                                    public Pair<UserDetail, User> call(UserDetail userDetail, User user) {\n                                        // runs when network call completes\n                                        // we get here userDetail for the corresponding user\n                                        return new Pair<>(userDetail, user); // returning the pair(userDetail, user)\n                                    }\n                                });\n                    }\n                })\n                .subscribeOn(Schedulers.newThread())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(new Observer<Pair<UserDetail, User>>() {\n                    @Override\n                    public void onCompleted() {\n                        // do something onCompleted\n                    }\n\n                    @Override\n                    public void onError(Throwable e) {\n                        // handle error\n                        Utils.logError(TAG, e);\n                    }\n\n                    @Override\n                    public void onNext(Pair<UserDetail, User> pair) {\n                        // here we are getting the userDetail for the corresponding user one by one\n                        UserDetail userDetail = pair.first;\n                        User user = pair.second;\n                        Log.d(TAG, \"userId : \" + user.id);\n                        Log.d(TAG, \"userDetail firstname : \" + userDetail.firstname);\n                        Log.d(TAG, \"userDetail lastname : \" + userDetail.lastname);\n                    }\n                });\n    }\n\n    /************************************\n     * others start here\n     ************************************/\n\n    public void startRxApiTestActivity(View view) {\n        startActivity(new Intent(RxOperatorExampleActivity.this, RxApiTestActivity.class));\n    }\n\n    public void startSubscriptionActivity(View view) {\n        startActivity(new Intent(RxOperatorExampleActivity.this, SubscriptionActivity.class));\n    }\n\n}\n"
  },
  {
    "path": "rxsampleapp/src/main/java/com/rxsampleapp/SubscriptionActivity.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.rxsampleapp;\n\nimport android.app.Activity;\nimport android.os.Bundle;\nimport android.support.v7.app.AppCompatActivity;\nimport android.util.Log;\nimport android.view.View;\n\nimport com.rxandroidnetworking.RxAndroidNetworking;\nimport com.rxsampleapp.utils.Utils;\n\nimport rx.Observable;\nimport rx.Observer;\nimport rx.Subscription;\nimport rx.android.schedulers.AndroidSchedulers;\nimport rx.schedulers.Schedulers;\n\n/**\n * Created by amitshekhar on 31/07/16.\n */\npublic class SubscriptionActivity extends AppCompatActivity {\n\n    private static final String TAG = SubscriptionActivity.class.getSimpleName();\n    private static final String URL = \"http://i.imgur.com/AtbX9iX.png\";\n    private String dirPath;\n    private String fileName = \"imgurimage.png\";\n    Subscription subscription;\n\n    @Override\n    protected void onCreate(Bundle savedInstanceState) {\n        super.onCreate(savedInstanceState);\n        setContentView(R.layout.activity_subscription);\n        dirPath = Utils.getRootDirPath(getApplicationContext());\n    }\n\n\n    @Override\n    protected void onDestroy() {\n        super.onDestroy();\n        if (subscription != null) {\n            subscription.unsubscribe();\n        }\n    }\n\n    public Observable<String> getObservable() {\n        return RxAndroidNetworking.download(URL, dirPath, fileName)\n                .build()\n                .getDownloadObservable();\n    }\n\n    private Observer<String> getObserver() {\n        return new Observer<String>() {\n            @Override\n            public void onCompleted() {\n                Log.d(TAG, \"onCompleted\");\n            }\n\n            @Override\n            public void onError(Throwable e) {\n                Log.d(TAG, \"onError \" + e.getMessage());\n            }\n\n            @Override\n            public void onNext(String response) {\n                Log.d(TAG, \"onResponse response : \" + response);\n            }\n        };\n    }\n\n    public void downloadFile(View view) {\n        subscription = getObservable()\n                .subscribeOn(Schedulers.io())\n                .observeOn(AndroidSchedulers.mainThread())\n                .subscribe(getObserver());\n    }\n}"
  },
  {
    "path": "rxsampleapp/src/main/java/com/rxsampleapp/model/ApiUser.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.rxsampleapp.model;\n\n/**\n * Created by amitshekhar on 02/08/16.\n */\npublic class ApiUser {\n    public long id;\n    public String firstname;\n    public String lastname;\n}\n"
  },
  {
    "path": "rxsampleapp/src/main/java/com/rxsampleapp/model/User.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.rxsampleapp.model;\n\n/**\n * Created by amitshekhar on 31/07/16.\n */\npublic class User {\n    public long id;\n    public String firstname;\n    public String lastname;\n    public boolean isFollowing;\n\n    public User(ApiUser apiUser) {\n        this.id = apiUser.id;\n        this.firstname = apiUser.firstname;\n        this.lastname = apiUser.lastname;\n    }\n}\n"
  },
  {
    "path": "rxsampleapp/src/main/java/com/rxsampleapp/model/UserDetail.java",
    "content": "/*\n *\n *  *    Copyright (C) 2016 Amit Shekhar\n *  *    Copyright (C) 2011 Android Open Source Project\n *  *\n *  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *  *    you may not use this file except in compliance with the License.\n *  *    You may obtain a copy of the License at\n *  *\n *  *        http://www.apache.org/licenses/LICENSE-2.0\n *  *\n *  *    Unless required by applicable law or agreed to in writing, software\n *  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *  *    See the License for the specific language governing permissions and\n *  *    limitations under the License.\n *\n */\n\npackage com.rxsampleapp.model;\n\n/**\n * Created by amitshekhar on 02/08/16.\n */\npublic class UserDetail {\n\n    public long id;\n    public String firstname;\n    public String lastname;\n\n}\n"
  },
  {
    "path": "rxsampleapp/src/main/java/com/rxsampleapp/utils/Utils.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\npackage com.rxsampleapp.utils;\n\nimport android.content.Context;\nimport android.os.Environment;\nimport android.support.v4.content.ContextCompat;\nimport android.util.Log;\n\nimport com.androidnetworking.error.ANError;\n\nimport java.io.File;\n\n/**\n * Created by Prashant Gupta on 29-07-2016.\n */\npublic class Utils {\n\n    public static String getRootDirPath(Context context) {\n        if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {\n            File file = ContextCompat.getExternalFilesDirs(context.getApplicationContext(), null)[0];\n            return file.getAbsolutePath();\n        } else {\n            return context.getApplicationContext().getFilesDir().getAbsolutePath();\n        }\n    }\n\n    public static void logError(String TAG, Throwable e) {\n        if (e instanceof ANError) {\n            ANError anError = (ANError) e;\n            if (anError.getErrorCode() != 0) {\n                // received ANError from server\n                // error.getErrorCode() - the ANError code from server\n                // error.getErrorBody() - the ANError body from server\n                // error.getErrorDetail() - just a ANError detail\n                Log.d(TAG, \"onError errorCode : \" + anError.getErrorCode());\n                Log.d(TAG, \"onError errorBody : \" + anError.getErrorBody());\n                Log.d(TAG, \"onError errorDetail : \" + anError.getErrorDetail());\n            } else {\n                // error.getErrorDetail() : connectionError, parseError, requestCancelledError\n                Log.d(TAG, \"onError errorDetail : \" + anError.getErrorDetail());\n            }\n        } else {\n            Log.d(TAG, \"onError errorMessage : \" + e.getMessage());\n        }\n    }\n\n}\n"
  },
  {
    "path": "rxsampleapp/src/main/res/layout/activity_rx_api_test.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?><!--\n  ~    Copyright (C) 2016 Amit Shekhar\n  ~    Copyright (C) 2011 Android Open Source Project\n  ~\n  ~    Licensed under the Apache License, Version 2.0 (the \"License\");\n  ~    you may not use this file except in compliance with the License.\n  ~    You may obtain a copy of the License at\n  ~\n  ~        http://www.apache.org/licenses/LICENSE-2.0\n  ~\n  ~    Unless required by applicable law or agreed to in writing, software\n  ~    distributed under the License is distributed on an \"AS IS\" BASIS,\n  ~    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  ~    See the License for the specific language governing permissions and\n  ~    limitations under the License.\n  -->\n\n<ScrollView xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\">\n\n    <LinearLayout\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"\n        android:orientation=\"vertical\"\n        android:paddingBottom=\"@dimen/activity_vertical_margin\"\n        android:paddingLeft=\"@dimen/activity_horizontal_margin\"\n        android:paddingRight=\"@dimen/activity_horizontal_margin\"\n        android:paddingTop=\"@dimen/activity_vertical_margin\">\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <Button\n            android:id=\"@+id/getAllUsers\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"getAllUsers\"\n            android:text=\"/getAllUsers/{pageNumber}\" />\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <Button\n            android:id=\"@+id/getAnUser\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"getAnUser\"\n            android:text=\"/getAnUser/{userId}\" />\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <Button\n            android:id=\"@+id/checkForHeaderGet\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"checkForHeaderGet\"\n            android:text=\"GET : checkForHeader\" />\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <Button\n            android:id=\"@+id/checkForHeaderPost\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"checkForHeaderPost\"\n            android:text=\"POST : checkForHeader\" />\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <Button\n            android:id=\"@+id/createAnUser\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"createAnUser\"\n            android:text=\"/createAnUser\" />\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <Button\n            android:id=\"@+id/createAnUserJSONObject\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"createAnUserJSONObject\"\n            android:text=\"/createAnUserJSONObject\" />\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <Button\n            android:id=\"@+id/downloadFile\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"downloadFile\"\n            android:text=\"downloadFile\" />\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <Button\n            android:id=\"@+id/downloadImage\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"downloadImage\"\n            android:text=\"downloadImage\" />\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <Button\n            android:id=\"@+id/uploadImage\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"uploadImage\"\n            android:text=\"uploadImage\" />\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <Button\n            android:id=\"@+id/getCurrentConnectionQuality\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"getCurrentConnectionQuality\"\n            android:text=\"getCurrentConnectionQuality\" />\n\n        <Button\n            android:id=\"@+id/loadImage\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"loadImage\"\n            android:text=\"loadImage\" />\n\n        <ImageView\n            android:id=\"@+id/imageView\"\n            android:layout_width=\"200dp\"\n            android:layout_height=\"200dp\"\n            android:layout_gravity=\"center\" />\n\n    </LinearLayout>\n\n</ScrollView>"
  },
  {
    "path": "rxsampleapp/src/main/res/layout/activity_rx_operator_example.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?><!--\n  ~ /*\n  ~  *    Copyright (C) 2016 Amit Shekhar\n  ~  *    Copyright (C) 2011 Android Open Source Project\n  ~  *\n  ~  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n  ~  *    you may not use this file except in compliance with the License.\n  ~  *    You may obtain a copy of the License at\n  ~  *\n  ~  *        http://www.apache.org/licenses/LICENSE-2.0\n  ~  *\n  ~  *    Unless required by applicable law or agreed to in writing, software\n  ~  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n  ~  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  ~  *    See the License for the specific language governing permissions and\n  ~  *    limitations under the License.\n  ~  */\n  -->\n\n<ScrollView xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\">\n\n    <LinearLayout\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"\n        android:orientation=\"vertical\"\n        android:paddingBottom=\"@dimen/activity_vertical_margin\"\n        android:paddingLeft=\"@dimen/activity_horizontal_margin\"\n        android:paddingRight=\"@dimen/activity_horizontal_margin\"\n        android:paddingTop=\"@dimen/activity_vertical_margin\">\n\n        <Button\n            android:id=\"@+id/map\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"map\"\n            android:text=\"map\" />\n\n        <Button\n            android:id=\"@+id/zip\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"zip\"\n            android:text=\"zip\" />\n\n        <Button\n            android:id=\"@+id/flatMapAndFilter\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"flatMapAndFilter\"\n            android:text=\"flatMapAndFilter\" />\n\n        <Button\n            android:id=\"@+id/take\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"take\"\n            android:text=\"take\" />\n\n        <Button\n            android:id=\"@+id/flatMap\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"flatMap\"\n            android:text=\"flatMap\" />\n\n        <Button\n            android:id=\"@+id/flatMapWithZip\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"flatMapWithZip\"\n            android:text=\"flatMapWithZip\" />\n\n        <Button\n            android:id=\"@+id/startRxApiTestActivity\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"startRxApiTestActivity\"\n            android:text=\"startRxApiTestActivity\" />\n\n        <Button\n            android:id=\"@+id/startSubscriptionActivity\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"startSubscriptionActivity\"\n            android:text=\"startSubscriptionActivity\" />\n\n\n    </LinearLayout>\n\n</ScrollView>"
  },
  {
    "path": "rxsampleapp/src/main/res/layout/activity_subscription.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?><!--\n  ~ /*\n  ~  *    Copyright (C) 2016 Amit Shekhar\n  ~  *    Copyright (C) 2011 Android Open Source Project\n  ~  *\n  ~  *    Licensed under the Apache License, Version 2.0 (the \"License\");\n  ~  *    you may not use this file except in compliance with the License.\n  ~  *    You may obtain a copy of the License at\n  ~  *\n  ~  *        http://www.apache.org/licenses/LICENSE-2.0\n  ~  *\n  ~  *    Unless required by applicable law or agreed to in writing, software\n  ~  *    distributed under the License is distributed on an \"AS IS\" BASIS,\n  ~  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  ~  *    See the License for the specific language governing permissions and\n  ~  *    limitations under the License.\n  ~  */\n  -->\n\n<ScrollView xmlns:android=\"http://schemas.android.com/apk/res/android\"\n    android:layout_width=\"match_parent\"\n    android:layout_height=\"match_parent\">\n\n    <LinearLayout\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\"\n        android:orientation=\"vertical\"\n        android:paddingBottom=\"@dimen/activity_vertical_margin\"\n        android:paddingLeft=\"@dimen/activity_horizontal_margin\"\n        android:paddingRight=\"@dimen/activity_horizontal_margin\"\n        android:paddingTop=\"@dimen/activity_vertical_margin\">\n\n        <ProgressBar\n            android:layout_width=\"wrap_content\"\n            android:layout_height=\"wrap_content\"\n            android:layout_gravity=\"center\" />\n\n        <Button\n            android:id=\"@+id/downloadFile\"\n            android:layout_width=\"match_parent\"\n            android:layout_height=\"48dp\"\n            android:layout_margin=\"8dp\"\n            android:onClick=\"downloadFile\"\n            android:text=\"downloadFile\" />\n\n\n    </LinearLayout>\n\n</ScrollView>"
  },
  {
    "path": "rxsampleapp/src/main/res/values/colors.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\n  ~    Copyright (C) 2016 Amit Shekhar\n  ~    Copyright (C) 2011 Android Open Source Project\n  ~\n  ~    Licensed under the Apache License, Version 2.0 (the \"License\");\n  ~    you may not use this file except in compliance with the License.\n  ~    You may obtain a copy of the License at\n  ~\n  ~        http://www.apache.org/licenses/LICENSE-2.0\n  ~\n  ~    Unless required by applicable law or agreed to in writing, software\n  ~    distributed under the License is distributed on an \"AS IS\" BASIS,\n  ~    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  ~    See the License for the specific language governing permissions and\n  ~    limitations under the License.\n  -->\n\n<resources>\n    <color name=\"colorPrimary\">#3F51B5</color>\n    <color name=\"colorPrimaryDark\">#303F9F</color>\n    <color name=\"colorAccent\">#FF4081</color>\n</resources>\n"
  },
  {
    "path": "rxsampleapp/src/main/res/values/dimens.xml",
    "content": "<!--\n  ~    Copyright (C) 2016 Amit Shekhar\n  ~    Copyright (C) 2011 Android Open Source Project\n  ~\n  ~    Licensed under the Apache License, Version 2.0 (the \"License\");\n  ~    you may not use this file except in compliance with the License.\n  ~    You may obtain a copy of the License at\n  ~\n  ~        http://www.apache.org/licenses/LICENSE-2.0\n  ~\n  ~    Unless required by applicable law or agreed to in writing, software\n  ~    distributed under the License is distributed on an \"AS IS\" BASIS,\n  ~    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  ~    See the License for the specific language governing permissions and\n  ~    limitations under the License.\n  -->\n\n<resources>\n    <!-- Default screen margins, per the Android Design guidelines. -->\n    <dimen name=\"activity_horizontal_margin\">16dp</dimen>\n    <dimen name=\"activity_vertical_margin\">16dp</dimen>\n\n    <dimen name=\"image_thumbnail_size\">100dp</dimen>\n    <dimen name=\"image_thumbnail_spacing\">1dp</dimen>\n</resources>"
  },
  {
    "path": "rxsampleapp/src/main/res/values/strings.xml",
    "content": "<!--\n  ~    Copyright (C) 2016 Amit Shekhar\n  ~    Copyright (C) 2011 Android Open Source Project\n  ~\n  ~    Licensed under the Apache License, Version 2.0 (the \"License\");\n  ~    you may not use this file except in compliance with the License.\n  ~    You may obtain a copy of the License at\n  ~\n  ~        http://www.apache.org/licenses/LICENSE-2.0\n  ~\n  ~    Unless required by applicable law or agreed to in writing, software\n  ~    distributed under the License is distributed on an \"AS IS\" BASIS,\n  ~    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  ~    See the License for the specific language governing permissions and\n  ~    limitations under the License.\n  -->\n\n<resources>\n    <string name=\"app_name\">RxSampleApp</string>\n</resources>\n"
  },
  {
    "path": "rxsampleapp/src/main/res/values/styles.xml",
    "content": "<!--\n  ~    Copyright (C) 2016 Amit Shekhar\n  ~    Copyright (C) 2011 Android Open Source Project\n  ~\n  ~    Licensed under the Apache License, Version 2.0 (the \"License\");\n  ~    you may not use this file except in compliance with the License.\n  ~    You may obtain a copy of the License at\n  ~\n  ~        http://www.apache.org/licenses/LICENSE-2.0\n  ~\n  ~    Unless required by applicable law or agreed to in writing, software\n  ~    distributed under the License is distributed on an \"AS IS\" BASIS,\n  ~    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n  ~    See the License for the specific language governing permissions and\n  ~    limitations under the License.\n  -->\n\n<resources>\n\n    <!-- Base application theme. -->\n    <style name=\"AppTheme\" parent=\"Theme.AppCompat.Light.DarkActionBar\">\n        <!-- Customize your theme here. -->\n        <item name=\"colorPrimary\">@color/colorPrimary</item>\n        <item name=\"colorPrimaryDark\">@color/colorPrimaryDark</item>\n        <item name=\"colorAccent\">@color/colorAccent</item>\n    </style>\n\n</resources>\n"
  },
  {
    "path": "rxsampleapp/src/test/java/com/rxsampleapp/ExampleUnitTest.java",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\npackage com.rxsampleapp;\n\nimport org.junit.Test;\n\nimport static org.junit.Assert.*;\n\n/**\n * To work on unit tests, switch the Test Artifact in the Build Variants view.\n */\npublic class ExampleUnitTest {\n    @Test\n    public void addition_isCorrect() throws Exception {\n        assertEquals(4, 2 + 2);\n    }\n}"
  },
  {
    "path": "settings.gradle",
    "content": "/*\n *    Copyright (C) 2016 Amit Shekhar\n *    Copyright (C) 2011 Android Open Source Project\n *\n *    Licensed under the Apache License, Version 2.0 (the \"License\");\n *    you may not use this file except in compliance with the License.\n *    You may obtain a copy of the License at\n *\n *        http://www.apache.org/licenses/LICENSE-2.0\n *\n *    Unless required by applicable law or agreed to in writing, software\n *    distributed under the License is distributed on an \"AS IS\" BASIS,\n *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *    See the License for the specific language governing permissions and\n *    limitations under the License.\n */\n\ninclude ':app', ':android-networking', ':rx-android-networking', ':rxsampleapp', ':jackson-android-networking', ':rx2-android-networking', ':rx2sampleapp'\n"
  }
]