├── .gitignore ├── LICENSE ├── README.md ├── _config.yml ├── build.gradle ├── example ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── main │ ├── AndroidManifest.xml │ ├── assets │ │ ├── novate-config.json │ │ └── novate.png │ ├── java │ │ └── com │ │ │ └── tamic │ │ │ └── excemple │ │ │ ├── ExempleActivity.java │ │ │ ├── MyAPI.java │ │ │ ├── MyBaseSubscriber.java │ │ │ ├── RequstActivity.java │ │ │ └── model │ │ │ ├── CityModel.java │ │ │ ├── IpResult.java │ │ │ ├── ListData.java │ │ │ ├── MovieModel.java │ │ │ ├── MusicBookCategory.java │ │ │ ├── ResultModel.java │ │ │ ├── SouguBean.java │ │ │ └── wetherModel.java │ └── res │ │ ├── layout │ │ ├── activity_exemple.xml │ │ └── activity_requst.xml │ │ ├── mipmap-xhdpi │ │ └── novate.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── tamic │ └── novate │ └── ExampleUnitTest.java ├── novate.gif └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the ART/Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | out/ 15 | 16 | # Gradle files 17 | .gradle/ 18 | build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Log Files 27 | *.log 28 | 29 | # Android Studio Navigation editor temp files 30 | .navigation/ 31 | 32 | # Android Studio captures folder 33 | captures/ 34 | 35 | # Intellij 36 | *.iml 37 | .idea/workspace.xml 38 | 39 | # Keystore files 40 | *.jks 41 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | ![](http://upload-images.jianshu.io/upload_images/2022038-6a900d93d8acb091.jpg) 3 | 4 | # Novate 5 |   a safety Framework by OkHttp for Android, (一款Android网络框架,基于Retrofit和RxJava打造的链式网络库, 强大的泛型解析功能和错误驱动功能,支持okhttp的调用风格,又兼容Retrofit注解方式,并支持rxJava链式操作。方便扩展,并能实现高速加载) 6 | 7 | 8 | # Summary 9 | 10 | 11 | - Join based API, reduce API redundancy 12 | - Offline caching 13 | - Support a variety of ways to access the network (a get, put, post, delete) 14 | - Support file download and upload 15 | - Unified support request header to join 16 | - The unity of the support to return the result 17 | - Support custom extensions API 18 | - Support the unified request access to the network flow control 19 | 20 | 21 | 22 | #dependencies 23 | 24 | **Eclipse:** 25 | 26 | Download the laster JAR:( com.tamic.novate:novate:-1.x.aar) 27 | 28 | copy to libs dirPath! 29 | 30 | **AS Gradle**: 31 |   32 | - root: 33 | 34 | 35 | repositories { 36 | maven { url "https://jitpack.io" } 37 | jcenter() 38 | } 39 | 40 | - app: 41 |     42 | ``` 43 | Gradle < 2.1 44 | dependencies { 45 |             compile 'com.tamic.novate:novate:1.5.5' 46 |          } 47 | 48 | Gradle > 2.1 49 | 50 | plugins { 51 | id "com.tamic.novate:novate "1.5.5" 52 | } 53 | ``` 54 | 55 | 56 | 57 | Snapshots of the development version are available in Sonatype's snapshots repository. 58 | 59 | Retrofit requires at minimum Java 7 or Android 2.3. 60 | 61 | Laster vension: https://bintray.com/neglectedbyboss/maven/Novate 最新版本点击去查询 62 | 63 | **加入权限** 64 | 65 | 66 | ``` 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | ``` 75 | 76 | **混淆**   77 | 78 | -keep class com.tamic.novate.** {*;} 79 | 80 | -------------------------- 81 | 82 | 83 | # 中文文档 84 | 85 | 基于Retrofit和RxJava封装的链式网络库, 支持okhttp的调用分格,又兼容Retrofit注入方式,并支持RxJava调用的链式操作, 86 | 不仅支持开发者自己扩展,还沿用Okhttp的高效的网络加载!最重要的novate自带的异常驱动机制,帮开发者解决了绝大部分的异常 87 |  错误处理,减少API或者业务代码出错的导致崩溃概率。 88 |   89 | 为何起名 Novate? 90 | 91 | Novate 的英文原意是用新事物代替 92 | 目的是用新的东西来代替Retrofit的有些不易操作的地方,因此起名新奇的东西,所以结合了原来的Http用法习惯,又加入了Retrofit的特性,因此起名 :Novate,LOGO也是加速的意思,本框架提供了一种封装架构思路,如果不喜欢本设计思路的朋友可以直接拿源码修改扩展。 93 | 94 | 功能 95 | ---- 96 | - 优化设计:加入基础API,减少Api冗余 97 | - 强大的缓存模式: 支持离线缓存, 无网络智能加载缓存,可配置是否需要缓存 98 | - cookie管理:自带cookie管理机制 99 | - 全方位请求模式:支持多种方式访问网络(get,put, post ,delete) 100 | - 轻送调用:支持表单,图文一起,json上传。 101 | - 文件传输:支持文件下载和上传,支持进度 102 | - 动态添加:支持请求头和参数统一添加,分别添加。 103 | - 结果处理:支持对返回结果的统一处理,自动帮你序列化复杂的数据。 104 | - 扩展性强:支持自定义的Retrofit的API,默认Api无法满足时可自定义自己的Service 105 | - 悠雅方便:支持统一请求访问网络的流程控制,以方便帮你完美加入Processbar进度。 106 | - RxJava结合: 结合RxJava,线程智能控制 107 | 108 |   请求网络无需关心是否在主线程和非UI线程,操作UI直接可在回调处理, 保留了HttpClient的编码习惯,又加入了Builder模式编程! 109 | 110 | 111 | ## [详细介绍 请看:Wiki, wiki, wiki!](https://github.com/Tamicer/Novate/wiki) ## 112 | 113 | Update Log   114 | ----- 115 | 更新历史请看:https://github.com/Tamicer/Novate/releases 116 | 117 | 118 | #License 119 | -------- 120 | 121 |    Copyright 2016 Tamic, Inc. 122 | 123 | Licensed under the Apache License, Version 2.0 (the "License"); 124 | you may not use this file except in compliance with the License. 125 | You may obtain a copy of the License at 126 | 127 | http://www.apache.org/licenses/LICENSE-2.0 128 | 129 | Unless required by applicable law or agreed to in writing, software 130 | distributed under the License is distributed on an "AS IS" BASIS, 131 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 132 | See the License for the specific language governing permissions and 133 | limitations under the License. 134 | 135 | **更多介绍:https://tamicer.github.io/2016/08/10/novate10/** 136 | 137 | 138 | **技术交流QQ群: 458542940** 139 | 140 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-cayman -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | maven { url "https://jitpack.io" } 7 | 8 | } 9 | dependencies { 10 | classpath 'com.android.tools.build:gradle:1.3.0' 11 | // NOTE: Do not place your application dependencies here; they belong 12 | // in the individual module build.gradle files 13 | 14 | } 15 | } 16 | 17 | allprojects { 18 | repositories { 19 | maven { url "https://jitpack.io" } 20 | 21 | jcenter() 22 | } 23 | } 24 | 25 | task clean(type: Delete) { 26 | delete rootProject.buildDir 27 | } 28 | -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the ART/Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | out/ 15 | 16 | # Gradle files 17 | .gradle/ 18 | build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Log Files 27 | *.log 28 | 29 | # Android Studio Navigation editor temp files 30 | .navigation/ 31 | 32 | # Android Studio captures folder 33 | captures/ 34 | 35 | # Intellij 36 | *.iml 37 | .idea/workspace.xml 38 | 39 | # Keystore files 40 | *.jks 41 | -------------------------------------------------------------------------------- /example/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.2" 6 | 7 | defaultConfig { 8 | applicationId "com.tamic.excemple" 9 | minSdkVersion 16 10 | targetSdkVersion 23 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | 21 | lintOptions { 22 | abortOnError false 23 | } 24 | } 25 | 26 | dependencies { 27 | compile fileTree(dir: 'libs', include: ['*.jar']) 28 | testCompile 'junit:junit:4.12' 29 | compile 'com.android.support:appcompat-v7:23.1.0' 30 | compile 'com.tamic.novate:novate:1.5.3' 31 | } 32 | 33 | -------------------------------------------------------------------------------- /example/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in D:\Users\liuyongkui726\AppData\Local\Android\android-sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -keep class retrofit2.** {*;} 19 | 20 | -dontwarn okhttp3** 21 | -keep class okhttp3.**{*;} 22 | -dontwarn okio** 23 | -keep class okio.**{*;} 24 | -keep class rx.**{*;} 25 | 26 | 27 | -keep class com.tamic.novate.Novate.** {*;} 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /example/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /example/src/main/assets/novate-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "isFormat": "false", 3 | "sucessCode": [ 4 | "0", 5 | "1001" 6 | ], 7 | "error": { 8 | "1001": "网络异常" 9 | } 10 | } -------------------------------------------------------------------------------- /example/src/main/assets/novate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tamicer/Novate/c4116ba2601984cfa54409bf2d57a8bf6f086f1e/example/src/main/assets/novate.png -------------------------------------------------------------------------------- /example/src/main/java/com/tamic/excemple/ExempleActivity.java: -------------------------------------------------------------------------------- 1 | package com.tamic.excemple; 2 | 3 | import android.app.ProgressDialog; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.graphics.Bitmap; 7 | import android.graphics.BitmapFactory; 8 | import android.support.v7.app.AppCompatActivity; 9 | import android.os.Bundle; 10 | import android.text.TextUtils; 11 | import android.util.Log; 12 | import android.view.View; 13 | import android.widget.Button; 14 | import android.widget.Toast; 15 | 16 | import com.google.gson.Gson; 17 | import com.google.gson.reflect.TypeToken; 18 | import com.tamic.excemple.model.MovieModel; 19 | import com.tamic.excemple.model.ResultModel; 20 | import com.tamic.excemple.model.SouguBean; 21 | import com.tamic.novate.NovateResponse; 22 | import com.tamic.novate.BaseSubscriber; 23 | import com.tamic.novate.Novate; 24 | import com.tamic.novate.RxApiManager; 25 | import com.tamic.novate.Throwable; 26 | import com.tamic.novate.callback.RxStringCallback; 27 | import com.tamic.novate.download.DownLoadCallBack; 28 | import com.tamic.novate.download.UpLoadCallback; 29 | import com.tamic.novate.request.NovateRequestBody; 30 | import com.tamic.novate.util.FileUtil; 31 | import com.tamic.novate.util.LogWraper; 32 | import com.tamic.novate.util.Utils; 33 | 34 | import java.io.File; 35 | import java.io.IOException; 36 | import java.io.InputStream; 37 | import java.lang.reflect.Type; 38 | import java.util.HashMap; 39 | import java.util.Map; 40 | 41 | import okhttp3.MediaType; 42 | import okhttp3.MultipartBody; 43 | import okhttp3.RequestBody; 44 | import okhttp3.ResponseBody; 45 | import rx.Subscription; 46 | 47 | /** 48 | * Created by Tamic on 2016-06-15. 49 | * {@link # https://github.com/NeglectedByBoss/Novate 50 | * 51 | * @link # http://blog.csdn.net/sk719887916 52 | * } 53 | */ 54 | public class ExempleActivity extends AppCompatActivity { 55 | 56 | String baseUrl = "http://ip.taobao.com/"; 57 | private Novate novate; 58 | private Map parameters = new HashMap(); 59 | private Map headers = new HashMap<>(); 60 | 61 | private Button btn, btn_test, btn_get, btn_post, btn_download, 62 | btn_download_Min, btn_upload, btn_uploadfile, btn_myApi, btn_more; 63 | 64 | private ProgressDialog mProgressDialog; 65 | String uploadPath = ""; 66 | 67 | 68 | 69 | @Override 70 | protected void onCreate(Bundle savedInstanceState) { 71 | super.onCreate(savedInstanceState); 72 | setContentView(R.layout.activity_exemple); 73 | // UI referen 74 | btn = (Button) findViewById(R.id.bt_simple); 75 | btn_test = (Button) findViewById(R.id.bt_test); 76 | btn_get = (Button) findViewById(R.id.bt_get); 77 | btn_post = (Button) findViewById(R.id.bt_post); 78 | btn_download = (Button) findViewById(R.id.bt_download); 79 | btn_upload = (Button) findViewById(R.id.bt_upload); 80 | btn_download_Min = (Button) findViewById(R.id.bt_download_min); 81 | btn_uploadfile = (Button) findViewById(R.id.bt_uploadflie); 82 | btn_myApi = (Button) findViewById(R.id.bt_my_api); 83 | btn_more = (Button) findViewById(R.id.bt_more); 84 | 85 | initProgress(this); 86 | 87 | parameters.put("ip", "21.22.11.33"); 88 | headers.put("Accept", "application/json"); 89 | 90 | novate = new Novate.Builder(this) 91 | //.addParameters(parameters) 92 | .connectTimeout(20) 93 | .writeTimeout(15) 94 | .baseUrl(baseUrl) 95 | .addHeader(headers) 96 | .addCache(true) 97 | .addLog(true) 98 | .build(); 99 | 100 | btn_test.setOnClickListener(new View.OnClickListener() { 101 | @Override 102 | public void onClick(View v) { 103 | 104 | performTest(); 105 | 106 | } 107 | 108 | 109 | }); 110 | 111 | btn.setOnClickListener(new View.OnClickListener() { 112 | @Override 113 | public void onClick(View v) { 114 | 115 | perform(); 116 | } 117 | 118 | 119 | }); 120 | 121 | btn_get.setOnClickListener(new View.OnClickListener() { 122 | @Override 123 | public void onClick(View v) { 124 | performGet(); 125 | } 126 | }); 127 | 128 | btn_post.setOnClickListener(new View.OnClickListener() { 129 | @Override 130 | public void onClick(View v) { 131 | performPost(); 132 | 133 | } 134 | }); 135 | btn_myApi.setOnClickListener(new View.OnClickListener() { 136 | @Override 137 | public void onClick(View v) { 138 | 139 | perform_Api(); 140 | } 141 | 142 | 143 | }); 144 | 145 | btn_download.setOnClickListener(new View.OnClickListener() { 146 | @Override 147 | public void onClick(View v) { 148 | performDown(); 149 | } 150 | }); 151 | btn_download_Min.setOnClickListener(new View.OnClickListener() { 152 | @Override 153 | public void onClick(View v) { 154 | performDownMin(); 155 | } 156 | }); 157 | 158 | btn_upload.setOnClickListener(new View.OnClickListener() { 159 | @Override 160 | public void onClick(View v) { 161 | performUpLoadImage(); 162 | } 163 | }); 164 | 165 | btn_uploadfile.setOnClickListener(new View.OnClickListener() { 166 | @Override 167 | public void onClick(View v) { 168 | performUpLoadFlie(); 169 | } 170 | }); 171 | 172 | btn_more.setOnClickListener(new View.OnClickListener() { 173 | @Override 174 | public void onClick(View v) { 175 | startActivity(new Intent(ExempleActivity.this, RequstActivity.class)); 176 | } 177 | }); 178 | } 179 | 180 | /** 181 | * 初始化进度条 182 | */ 183 | private void initProgress(Context aContext) { 184 | 185 | if (mProgressDialog == null) { 186 | mProgressDialog = new ProgressDialog(aContext); 187 | } 188 | 189 | mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); 190 | mProgressDialog.setTitle("温馨提示"); 191 | mProgressDialog.setMax(100); 192 | mProgressDialog.setMessage("正在上传中..."); 193 | mProgressDialog.setCancelable(true); 194 | 195 | } 196 | 197 | 198 | private void showPressDialog() { 199 | 200 | if (mProgressDialog == null || this.isFinishing()) { 201 | return; 202 | } 203 | mProgressDialog.show(); 204 | } 205 | 206 | 207 | private void dismissProgressDialog() { 208 | if (mProgressDialog != null && mProgressDialog.isShowing()) { 209 | mProgressDialog.dismiss(); 210 | } 211 | } 212 | 213 | private void updateProgressDialog(int progress) { 214 | 215 | if (mProgressDialog != null) { 216 | if (!mProgressDialog.isShowing()) { 217 | showPressDialog(); 218 | } 219 | mProgressDialog.setProgress(progress); 220 | } 221 | } 222 | 223 | 224 | /** 225 | * test 226 | */ 227 | private void performTest() { 228 | 229 | //http://apis.baidu.com/apistore/weatherservice/cityname?cityname=上海 230 | Map headers = new HashMap<>(); 231 | headers.put("apikey", "27b6fb21f2b42e9d70cd722b2ed038a9"); 232 | headers.put("Accept", "application/json"); 233 | novate = new Novate.Builder(this) 234 | .addHeader(headers) 235 | .addParameters(parameters) 236 | .connectTimeout(5) 237 | .baseUrl("https://apis.baidu.com/") 238 | .addHeader(headers) 239 | .addLog(true) 240 | .build(); 241 | 242 | 243 | Subscription subscription = novate.test("https://apis.baidu.com/apistore/weatherservice/cityname?cityname=上海", null, 244 | new MyBaseSubscriber(ExempleActivity.this) { 245 | @Override 246 | public void onError(Throwable e) { 247 | Log.e("OkHttp", e.getMessage()); 248 | Toast.makeText(ExempleActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show(); 249 | } 250 | 251 | @Override 252 | public void onNext(ResponseBody responseBody) { 253 | try { 254 | Toast.makeText(ExempleActivity.this, new String(responseBody.bytes()), Toast.LENGTH_SHORT).show(); 255 | } catch (IOException e) { 256 | e.printStackTrace(); 257 | } 258 | } 259 | }); 260 | 261 | RxApiManager.get().add("test", subscription); 262 | //cancel RxApiManager.get().cancel("my"); 263 | 264 | } 265 | 266 | 267 | @Override 268 | protected void onPause() { 269 | super.onPause(); 270 | //RxApiManager.get().cancel("my"); 271 | } 272 | 273 | /** 274 | * http://www.dianpingmedia.com/framework/web/user/unauth/login 275 | */ 276 | private void perform() { 277 | 278 | parameters = new HashMap<>(); 279 | /*start=0&count=5*/ 280 | parameters.put("start", "0"); 281 | parameters.put("count", "1"); 282 | 283 | Map parameters = new HashMap<>(); 284 | parameters.put("mobileNumber", "18826412577"); 285 | parameters.put("loginPassword", "123456"); 286 | 287 | 288 | 289 | 290 | novate = new Novate.Builder(this) 291 | .addParameters(parameters) 292 | .connectTimeout(10) 293 | .baseUrl("http://api.douban.com/") 294 | //.addApiManager(ApiManager.class) 295 | .addLog(true) 296 | .build(); 297 | 298 | novate.get("v2/movie/top250", parameters, new BaseSubscriber() { 299 | @Override 300 | public void onError(Throwable e) { 301 | Toast.makeText(ExempleActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show(); 302 | } 303 | 304 | @Override 305 | public void onNext(ResponseBody responseBody) { 306 | try { 307 | 308 | String jstr = new String(responseBody.bytes()); 309 | 310 | Type type = new TypeToken() { 311 | }.getType(); 312 | 313 | MovieModel response = new Gson().fromJson(jstr, type); 314 | 315 | Toast.makeText(ExempleActivity.this, response.toString(), Toast.LENGTH_SHORT).show(); 316 | 317 | } catch (IOException e) { 318 | e.printStackTrace(); 319 | } 320 | } 321 | 322 | }); 323 | 324 | 325 | } 326 | 327 | /** 328 | * performGet 329 | * 已废弃 330 | */ 331 | private void performGet() { 332 | 333 | /** 334 | * 如果不需要数据解析后返回 则调用novate.Get() 335 | * 参考 performPost()中的方式 336 | */ 337 | novate.executeGet("service/getIpInfo.php", parameters, new Novate.ResponseCallBack() { 338 | @Override 339 | public void onStart() { 340 | 341 | // todo onStart 342 | 343 | } 344 | 345 | @Override 346 | public void onCompleted() { 347 | 348 | } 349 | 350 | @Override 351 | public void onError(Throwable e) { 352 | Toast.makeText(ExempleActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show(); 353 | } 354 | 355 | @Override 356 | public void onSuccee(NovateResponse response) { 357 | 358 | } 359 | 360 | 361 | @Override 362 | public void onsuccess(int code, String msg, ResultModel response, String originalResponse) { 363 | Toast.makeText(ExempleActivity.this, response.toString(), Toast.LENGTH_SHORT).show(); 364 | } 365 | 366 | }); 367 | 368 | } 369 | 370 | /** 371 | * performPost 372 | */ 373 | private void performPost() { 374 | 375 | Map parameters = new HashMap<>(); 376 | parameters.put("ip", "21.22.11.33"); 377 | novate = new Novate.Builder(this) 378 | .connectTimeout(8) 379 | .baseUrl(baseUrl) 380 | //.addApiManager(ApiManager.class) 381 | .addLog(true) 382 | .build(); 383 | 384 | 385 | /** 386 | * 387 | * 388 | * 调用post需要你自己解析数据 389 | * 390 | * 如果需要解析后返回 则调用novate.executeGet() 391 | * 参考 performGet()中的方式 392 | */ 393 | novate.post("service/getIpInfo.php", parameters, new MyBaseSubscriber(ExempleActivity.this) { 394 | @Override 395 | public void onError(Throwable e) { 396 | if (!TextUtils.isEmpty(e.getMessage())) { 397 | Log.e("OkHttp", e.getMessage()); 398 | Toast.makeText(ExempleActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show(); 399 | } 400 | 401 | } 402 | 403 | @Override 404 | public void onNext(ResponseBody responseBody) { 405 | 406 | try { 407 | String jstr = new String(responseBody.bytes()); 408 | 409 | if (jstr.trim().isEmpty()) { 410 | return; 411 | } 412 | 413 | Type type = new TypeToken>() { 414 | }.getType(); 415 | 416 | NovateResponse response = new Gson().fromJson(jstr, type); 417 | 418 | if (response.getData() != null) { 419 | Toast.makeText(ExempleActivity.this, response.getData().toString(), Toast.LENGTH_SHORT).show(); 420 | } 421 | Toast.makeText(ExempleActivity.this, jstr , Toast.LENGTH_SHORT).show(); 422 | } catch (IOException e) { 423 | e.printStackTrace(); 424 | } 425 | } 426 | }); 427 | 428 | } 429 | 430 | /** 431 | * perform_myApi 432 | * HostUrl = "http://lbs.sougu.net.cn/"; 433 | */ 434 | private void perform_Api() { 435 | 436 | parameters.clear(); 437 | parameters.put("m", "souguapp"); 438 | parameters.put("c", "appusers"); 439 | parameters.put("a", "network"); 440 | 441 | novate = new Novate.Builder(this) 442 | .addHeader(headers) 443 | .addParameters(parameters) 444 | .baseUrl("http://lbs.sougu.net.cn/") 445 | .addLog(true) 446 | .build(); 447 | 448 | 449 | MyAPI myAPI = novate.create(MyAPI.class); 450 | 451 | novate.call(myAPI.getSougu(parameters), 452 | new MyBaseSubscriber(ExempleActivity.this) { 453 | 454 | 455 | @Override 456 | public void onError(Throwable e) { 457 | Toast.makeText(ExempleActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show(); 458 | } 459 | 460 | @Override 461 | public void onNext(SouguBean souguBean) { 462 | 463 | Toast.makeText(ExempleActivity.this, souguBean.toString(), Toast.LENGTH_SHORT).show(); 464 | } 465 | }); 466 | 467 | } 468 | 469 | 470 | /** 471 | * upload 472 | */ 473 | private void performUpLoadImage() { 474 | 475 | String mPath = uploadPath; //"you File path "; 476 | String url = ""; 477 | RequestBody requestFile = 478 | RequestBody.create(MediaType.parse("image/jpg"), new File(mPath)); 479 | 480 | final NovateRequestBody requestBody = Utils.createNovateRequestBody(requestFile, new UpLoadCallback() { 481 | 482 | @Override 483 | public void onProgress(Object tag, int progress, long speed, boolean done) { 484 | 485 | LogWraper.d("uplaod", "tag:" + tag.toString() + "progress:"+ progress); 486 | updateProgressDialog(progress); 487 | 488 | 489 | } 490 | }); 491 | 492 | novate.rxUploadWithBody(url, requestBody, new RxStringCallback() { 493 | 494 | @Override 495 | public void onStart(Object tag) { 496 | super.onStart(tag); 497 | showPressDialog(); 498 | } 499 | 500 | @Override 501 | public void onNext(Object tag, String response) { 502 | LogWraper.d("novate", response); 503 | Toast.makeText(ExempleActivity.this, "成功", Toast.LENGTH_SHORT).show(); 504 | } 505 | 506 | @Override 507 | public void onError(Object tag, Throwable e) { 508 | Toast.makeText(ExempleActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show(); 509 | 510 | dismissProgressDialog(); 511 | } 512 | 513 | @Override 514 | public void onCancel(Object tag, Throwable e) { 515 | 516 | 517 | } 518 | 519 | @Override 520 | public void onCompleted(Object tag) { 521 | super.onCompleted(tag); 522 | dismissProgressDialog(); 523 | } 524 | }); 525 | 526 | } 527 | 528 | /** 529 | * upload 530 | */ 531 | private void performUpLoadFlie() { 532 | 533 | String mPath = uploadPath; //"you File path "; 534 | String url = ""; 535 | File file = new File(mPath); 536 | RequestBody requestFile = RequestBody.create(MediaType.parse("multipart/form-data; charset=utf-8"), file); 537 | 538 | final NovateRequestBody requestBody = Utils.createNovateRequestBody(requestFile, new UpLoadCallback() { 539 | 540 | @Override 541 | public void onProgress(Object tag, int progress, long speed, boolean done) { 542 | 543 | LogWraper.d("uplaod", "tag:" + tag.toString() + "progress:"+ progress); 544 | updateProgressDialog(progress); 545 | } 546 | }); 547 | 548 | 549 | MultipartBody.Part body2 = 550 | MultipartBody.Part.createFormData("image", file.getName(), requestBody); 551 | 552 | novate.rxUploadWithPart(url, body2, new RxStringCallback() { 553 | 554 | @Override 555 | public void onStart(Object tag) { 556 | super.onStart(tag); 557 | showPressDialog(); 558 | } 559 | 560 | @Override 561 | public void onError(Object tag, Throwable e) { 562 | Toast.makeText(ExempleActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show(); 563 | dismissProgressDialog(); 564 | } 565 | 566 | @Override 567 | public void onCancel(Object tag, Throwable e) { 568 | 569 | } 570 | 571 | @Override 572 | public void onNext(Object tag, String response) { 573 | LogWraper.d(response); 574 | Toast.makeText(ExempleActivity.this, "成功", Toast.LENGTH_SHORT).show(); 575 | dismissProgressDialog(); 576 | } 577 | 578 | 579 | }); 580 | 581 | } 582 | 583 | /** 584 | * upload 585 | */ 586 | private void performUpLoadFlies(){ 587 | 588 | String path = uploadPath;//"you File path "; 589 | String url = "http://workflow.tjcclz.com/GWWorkPlatform/NoticeServlet?GWType=wifiUploadFile"; 590 | 591 | File file = new File(path); 592 | // 创建 RequestBody,用于封装 请求RequestBody 593 | RequestBody requestFile = RequestBody.create(MediaType.parse("multipart/form-data"), file); 594 | 595 | final NovateRequestBody requestBody = Utils.createNovateRequestBody(requestFile, new UpLoadCallback() { 596 | 597 | @Override 598 | public void onProgress(Object tag, int progress, long speed, boolean done) { 599 | 600 | LogWraper.d("uplaod", "tag:" + tag.toString() + "progress:"+ progress); 601 | 602 | updateProgressDialog(progress); 603 | 604 | 605 | } 606 | }); 607 | 608 | MultipartBody.Part part = 609 | MultipartBody.Part.createFormData("image", file.getName(), requestBody); 610 | Map maps = new HashMap<>(); 611 | maps.put("image", part); 612 | 613 | novate.rxUploadWithPartMap(url, maps, new RxStringCallback() { 614 | 615 | @Override 616 | public void onStart(Object tag) { 617 | super.onStart(tag); 618 | showPressDialog(); 619 | } 620 | 621 | @Override 622 | public void onNext(Object tag, String response) { 623 | LogWraper.d("novate", response); 624 | Toast.makeText(ExempleActivity.this, "成功", Toast.LENGTH_SHORT).show(); 625 | } 626 | 627 | @Override 628 | public void onError(Object tag, Throwable e) { 629 | Toast.makeText(ExempleActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show(); 630 | 631 | dismissProgressDialog(); 632 | } 633 | 634 | @Override 635 | public void onCancel(Object tag, Throwable e) { 636 | 637 | 638 | } 639 | }); 640 | 641 | } 642 | 643 | /** 644 | * performDown file 645 | * ex: apk , video... 646 | */ 647 | private void performDown() { 648 | String downUrl = "http://wifiapi02.51y5.net/wifiapi/rd.do?f=wk00003&b=gwanz02&rurl=http%3A%2F%2Fdl.lianwifi.com%2Fdownload%2Fandroid%2FWifiKey-3091-guanwang.apk"; 649 | novate.download(downUrl, "test.mei", new DownLoadCallBack() { 650 | 651 | @Override 652 | public void onStart(String s) { 653 | super.onStart(s); 654 | 655 | btn_download.setText("DownLoad cancel"); 656 | showPressDialog(); 657 | } 658 | 659 | @Override 660 | public void onError(Throwable e) { 661 | Toast.makeText(ExempleActivity.this, "onError:" + e.getMessage(), Toast.LENGTH_SHORT).show(); 662 | } 663 | 664 | @Override 665 | public void onProgress(String key, int progress, long fileSizeDownloaded, long totalSize) { 666 | super.onProgress(key, progress, fileSizeDownloaded, totalSize); 667 | Log.v("test", fileSizeDownloaded+""); 668 | //Toast.makeText(ExempleActivity.this, "progress: " + progress + " download: " + fileSizeDownloaded, Toast.LENGTH_SHORT).show(); 669 | updateProgressDialog(progress); 670 | 671 | } 672 | 673 | @Override 674 | public void onSucess(String key, String path, String name, long fileSize) { 675 | Toast.makeText(ExempleActivity.this, "download onSucess", Toast.LENGTH_SHORT).show(); 676 | dismissProgressDialog(); 677 | } 678 | 679 | @Override 680 | public void onCancel() { 681 | super.onCancel(); 682 | dismissProgressDialog(); 683 | } 684 | 685 | }); 686 | } 687 | 688 | /** 689 | * performDown small file 690 | * ex: image txt 691 | */ 692 | private void performDownMin() { 693 | 694 | String downUrl = "https://ss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo/bd_logo1_31bdc765.png"; 695 | novate.downloadMin("tag", downUrl, "my.jpg",new DownLoadCallBack() { 696 | 697 | @Override 698 | public void onStart(String s) { 699 | super.onStart(s); 700 | btn_download.setText("DownLoadMin cancel"); 701 | showPressDialog(); 702 | } 703 | 704 | @Override 705 | public void onError(Throwable e) { 706 | Toast.makeText(ExempleActivity.this, "onError:" + e.getMessage(), Toast.LENGTH_SHORT).show(); 707 | } 708 | 709 | @Override 710 | public void onSucess(String key, String path, String name, long fileSize) { 711 | btn_download.setText("DownLoad start"); 712 | uploadPath = path + name; 713 | dismissProgressDialog(); 714 | } 715 | 716 | 717 | @Override 718 | public void onProgress(String key, int progress, long fileSizeDownloaded, long totalSize) { 719 | super.onProgress(key, progress, fileSizeDownloaded, totalSize); 720 | updateProgressDialog(progress); 721 | Toast.makeText(ExempleActivity.this, "progress: " + progress + " download: " + fileSizeDownloaded, Toast.LENGTH_SHORT).show(); 722 | } 723 | 724 | @Override 725 | public void onCancel() { 726 | super.onCancel(); 727 | btn_download.setText("DownLoadMin start"); 728 | } 729 | 730 | }); 731 | } 732 | 733 | 734 | 735 | } 736 | -------------------------------------------------------------------------------- /example/src/main/java/com/tamic/excemple/MyAPI.java: -------------------------------------------------------------------------------- 1 | package com.tamic.excemple; 2 | 3 | import com.tamic.excemple.model.SouguBean; 4 | 5 | import java.util.Map; 6 | 7 | import okhttp3.ResponseBody; 8 | import retrofit2.http.GET; 9 | import retrofit2.http.Path; 10 | import retrofit2.http.QueryMap; 11 | import rx.Observable; 12 | 13 | /** 14 | * Created by Tamic on 2016-07-07. 15 | */ 16 | public interface MyAPI { 17 | 18 | 19 | 20 | @GET("app.php") 21 | Observable getSougu(@QueryMap Map maps); 22 | 23 | @GET("{url}") 24 | ObservablegetWeatherStr(@Path("url") String url, 25 | @QueryMap Map maps); 26 | } 27 | -------------------------------------------------------------------------------- /example/src/main/java/com/tamic/excemple/MyBaseSubscriber.java: -------------------------------------------------------------------------------- 1 | package com.tamic.excemple; 2 | 3 | import android.app.ProgressDialog; 4 | import android.content.Context; 5 | import android.widget.Toast; 6 | 7 | import com.tamic.novate.BaseSubscriber; 8 | import com.tamic.novate.Throwable; 9 | import com.tamic.novate.util.NetworkUtil; 10 | 11 | /** 12 | * Created by LIUYONGKUI726 on 2017-06-01. 13 | */ 14 | 15 | public abstract class MyBaseSubscriber extends BaseSubscriber { 16 | 17 | private ProgressDialog progress; 18 | 19 | private Context context; 20 | 21 | public MyBaseSubscriber(Context context) { 22 | super(context); 23 | this.context = context; 24 | progress = new ProgressDialog(context); 25 | progress.setMessage("novate拼命加载中...."); 26 | 27 | } 28 | 29 | 30 | @Override 31 | public void onStart() { 32 | super.onStart(); 33 | 34 | if (!NetworkUtil.isNetworkAvailable(context)) { 35 | Toast.makeText( context, "似乎没网O",Toast.LENGTH_SHORT).show(); 36 | onCompleted(); 37 | return; 38 | } 39 | if (progress != null){ 40 | if (progress.isShowing()) { 41 | progress.dismiss(); 42 | } 43 | progress.show(); 44 | } 45 | 46 | 47 | } 48 | 49 | @Override 50 | public void onCompleted() { 51 | super.onCompleted(); 52 | 53 | if (progress != null && progress.isShowing()) { 54 | progress.dismiss(); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /example/src/main/java/com/tamic/excemple/RequstActivity.java: -------------------------------------------------------------------------------- 1 | package com.tamic.excemple; 2 | 3 | import android.graphics.Bitmap; 4 | import android.os.Bundle; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.view.View; 7 | import android.widget.Button; 8 | import android.widget.Toast; 9 | 10 | import com.google.gson.reflect.TypeToken; 11 | import com.tamic.excemple.model.MusicBookCategory; 12 | import com.tamic.excemple.model.ResultModel; 13 | import com.tamic.novate.Novate; 14 | import com.tamic.novate.Throwable; 15 | import com.tamic.novate.callback.RxBitmapCallback; 16 | import com.tamic.novate.callback.RxFileCallBack; 17 | import com.tamic.novate.callback.RxListCallback; 18 | import com.tamic.novate.callback.RxResultCallback; 19 | import com.tamic.novate.callback.RxStringCallback; 20 | import com.tamic.novate.util.FileUtil; 21 | 22 | import java.io.File; 23 | import java.lang.reflect.Type; 24 | import java.util.HashMap; 25 | import java.util.List; 26 | import java.util.Map; 27 | 28 | /** 29 | * Created by Tamic on 2016-06-15. 30 | * {@link # https://github.com/NeglectedByBoss/Novate 31 | * 32 | * @link # http://blog.csdn.net/sk719887916 33 | * } 34 | */ 35 | public class RequstActivity extends AppCompatActivity { 36 | 37 | String baseUrl = "http://ip.taobao.com/"; 38 | private Novate novate; 39 | private Map parameters = new HashMap(); 40 | private Map headers = new HashMap<>(); 41 | 42 | private Button btn_get, btn_getSting, btn_bitmap, btn_file, 43 | btn_getList; 44 | 45 | 46 | 47 | @Override 48 | protected void onCreate(Bundle savedInstanceState) { 49 | super.onCreate(savedInstanceState); 50 | setContentView(R.layout.activity_requst); 51 | // UI referen 52 | btn_get = (Button) findViewById(R.id.get_Entity); 53 | btn_getSting = (Button) findViewById(R.id.get_String); 54 | btn_bitmap = (Button) findViewById(R.id.get_Bitmap); 55 | btn_file = (Button) findViewById(R.id.get_File); 56 | btn_getList = (Button) findViewById(R.id.get_ListEntity); 57 | 58 | 59 | parameters.put("ip", "21.22.11.33"); 60 | headers.put("Accept", "application/json"); 61 | 62 | novate = new Novate.Builder(this) 63 | .connectTimeout(20) 64 | .writeTimeout(15) 65 | .baseUrl(baseUrl) 66 | .addHeader(headers) 67 | .addLog(true) 68 | .build(); 69 | 70 | 71 | btn_get.setOnClickListener(new View.OnClickListener() { 72 | @Override 73 | public void onClick(View v) { 74 | 75 | performGet(); 76 | 77 | } 78 | 79 | 80 | }); 81 | 82 | btn_getSting.setOnClickListener(new View.OnClickListener() { 83 | @Override 84 | public void onClick(View v) { 85 | 86 | performString(); 87 | } 88 | 89 | 90 | }); 91 | 92 | btn_bitmap.setOnClickListener(new View.OnClickListener() { 93 | @Override 94 | public void onClick(View v) { 95 | performBitmap(); 96 | } 97 | }); 98 | 99 | btn_file.setOnClickListener(new View.OnClickListener() { 100 | @Override 101 | public void onClick(View v) { 102 | performFile(); 103 | 104 | } 105 | }); 106 | btn_getList.setOnClickListener(new View.OnClickListener() { 107 | @Override 108 | public void onClick(View v) { 109 | 110 | performList(); 111 | } 112 | 113 | 114 | }); 115 | 116 | } 117 | 118 | 119 | /** 120 | * 下载字符串 121 | */ 122 | private void performString() { 123 | 124 | novate.rxGet("service/getIpInfo.php", parameters, new RxStringCallback() { 125 | 126 | @Override 127 | public void onNext(Object tag, String response) { 128 | Toast.makeText(RequstActivity.this, response, Toast.LENGTH_SHORT).show(); 129 | } 130 | 131 | @Override 132 | public void onError(Object tag, Throwable e) { 133 | Toast.makeText(RequstActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show(); 134 | } 135 | 136 | @Override 137 | public void onCancel(Object tag, Throwable e) { 138 | 139 | } 140 | 141 | }); 142 | 143 | } 144 | 145 | /** 146 | * 下载集合数组 147 | * List 数组 148 | * 149 | * 150 | * 对应返回数据 ; 151 | * 152 | * { 153 | "data": [ 154 | { 155 | "id": 15, 156 | "createDate": 1496286231000, 157 | "modifyDate": 1496291243000, 158 | "order": 1, 159 | "name": "推荐1", 160 | "treePath": ",13,", 161 | "grade": 1 162 | }, 163 | { 164 | "id": 18, 165 | "createDate": 1496291263000, 166 | "modifyDate": 1496291263000, 167 | "order": 2, 168 | "name": "新手2", 169 | "treePath": ",13,", 170 | "grade": 1 171 | }, 172 | { 173 | "id": 19, 174 | "createDate": 1496291284000, 175 | "modifyDate": 1496291284000, 176 | "order": 3, 177 | "name": "联系3", 178 | "treePath": ",13,", 179 | "grade": 1 180 | }, 181 | { 182 | "id": 20, 183 | "createDate": 1496291300000, 184 | "modifyDate": 1496291300000, 185 | "order": 4, 186 | "name": "热门4", 187 | "treePath": ",13,", 188 | "grade": 1 189 | } 190 | 191 | ], 192 | "code": 100, 193 | "message": "success" 194 | } 195 | * 196 | */ 197 | private void performList() { 198 | //简单数组 199 | novate.rxGet("service/getIpInfo.php", parameters, new RxListCallback>() { 200 | 201 | 202 | @Override 203 | public void onNext(Object tag, int code, String message, List response) { 204 | Toast.makeText(RequstActivity.this, response.size() +"" + ":" + response.get(0).toString(), Toast.LENGTH_SHORT).show(); 205 | } 206 | 207 | 208 | @Override 209 | public void onError(Object tag, Throwable e) { 210 | Toast.makeText(RequstActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show(); 211 | } 212 | 213 | @Override 214 | public void onCancel(Object tag, Throwable e) { 215 | 216 | } 217 | 218 | 219 | }); 220 | 221 | //复杂数组 构造自己的type,加入到RxListCallback中 222 | Type listType = new TypeToken>() {}.getType(); 223 | 224 | novate.rxGet("service/getIpInfo.php", parameters, new RxListCallback>(listType) { 225 | 226 | 227 | @Override 228 | public void onNext(Object tag, int code, String message, List response) { 229 | Toast.makeText(RequstActivity.this, response.size() +"" + ":" + response.get(0).toString(), Toast.LENGTH_SHORT).show(); 230 | } 231 | 232 | 233 | @Override 234 | public void onError(Object tag, Throwable e) { 235 | Toast.makeText(RequstActivity.this, e.getMessage(), Toast.LENGTH_SHORT).show(); 236 | } 237 | 238 | @Override 239 | public void onCancel(Object tag, Throwable e) { 240 | 241 | } 242 | 243 | 244 | }); 245 | 246 | } 247 | 248 | 249 | /** 250 | * 下载File 251 | */ 252 | private void performFile() { 253 | 254 | String downUrl = "http://img06.tooopen.com/images/20161022/tooopen_sy_182719487645.jpg"; 255 | String path = FileUtil.getBasePath(this); 256 | 257 | novate.rxGet(downUrl, null, new RxFileCallBack(path, "my.jpg") { 258 | 259 | 260 | @Override 261 | public void onNext(Object tag, File file) { 262 | Toast.makeText(RequstActivity.this, " file is downloaded", Toast.LENGTH_SHORT).show(); 263 | } 264 | 265 | @Override 266 | public void onProgress(Object tag, float progress, long downloaded, long total) { 267 | Toast.makeText(RequstActivity.this, progress +"" + " downloaded:" + downloaded, Toast.LENGTH_SHORT).show(); 268 | } 269 | 270 | @Override 271 | public void onError(Object tag, Throwable e) { 272 | 273 | } 274 | 275 | @Override 276 | public void onCancel(Object tag, Throwable e) { 277 | 278 | } 279 | 280 | 281 | }); 282 | } 283 | 284 | 285 | 286 | /** 287 | * 下载对象 288 | * performGet 289 | */ 290 | private void performGet() { 291 | 292 | Map parameters = new HashMap(); 293 | parameters.put("ip", "21.22.11.33"); 294 | novate = new Novate.Builder(this) 295 | .addHeader(headers) 296 | //.addParameters(parameters) 297 | .connectTimeout(5) 298 | .baseUrl(baseUrl) 299 | .addCache(false) 300 | .addLog(true) 301 | .build(); 302 | 303 | novate.rxGet("service/getIpInfo.php", parameters, new RxResultCallback() { 304 | 305 | 306 | @Override 307 | public void onError(Object tag, Throwable e) { 308 | 309 | } 310 | 311 | @Override 312 | public void onCancel(Object tag, Throwable e) { 313 | 314 | } 315 | 316 | @Override 317 | public void onNext(Object tag, int code, String message, ResultModel response) { 318 | Toast.makeText(RequstActivity.this, response.toString(), Toast.LENGTH_SHORT).show(); 319 | } 320 | }); 321 | } 322 | 323 | 324 | /** 325 | * 下载图谱 326 | */ 327 | private void performBitmap() { 328 | 329 | novate.rxGet("you path url", parameters, new RxBitmapCallback() { 330 | 331 | 332 | @Override 333 | public void onNext(Object tag, Bitmap response) { 334 | 335 | } 336 | 337 | @Override 338 | public void onError(Object tag, Throwable e) { 339 | 340 | } 341 | 342 | @Override 343 | public void onCancel(Object tag, Throwable e) { 344 | 345 | } 346 | 347 | }); 348 | } 349 | 350 | 351 | } 352 | -------------------------------------------------------------------------------- /example/src/main/java/com/tamic/excemple/model/CityModel.java: -------------------------------------------------------------------------------- 1 | package com.tamic.excemple.model; 2 | 3 | /** 4 | * Created by LIUYONGKUI726 on 2016-07-26. 5 | */ 6 | public class CityModel { 7 | 8 | 9 | /** 10 | * errNum : 0 11 | * retMsg : success 12 | * retData : {"cityName":"北京","provinceName":"北京","cityCode":"101010100","zipCode":"100000","telAreaCode":"010"} 13 | */ 14 | 15 | private int errNum; 16 | private String retMsg; 17 | /** 18 | * cityName : 北京 19 | * provinceName : 北京 20 | * cityCode : 101010100 21 | * zipCode : 100000 22 | * telAreaCode : 010 23 | */ 24 | 25 | private RetDataBean retData; 26 | 27 | public int getErrNum() { 28 | return errNum; 29 | } 30 | 31 | public void setErrNum(int errNum) { 32 | this.errNum = errNum; 33 | } 34 | 35 | public String getRetMsg() { 36 | return retMsg; 37 | } 38 | 39 | public void setRetMsg(String retMsg) { 40 | this.retMsg = retMsg; 41 | } 42 | 43 | public RetDataBean getRetData() { 44 | return retData; 45 | } 46 | 47 | public void setRetData(RetDataBean retData) { 48 | this.retData = retData; 49 | } 50 | 51 | public static class RetDataBean { 52 | private String cityName; 53 | private String provinceName; 54 | private String cityCode; 55 | private String zipCode; 56 | private String telAreaCode; 57 | 58 | public String getCityName() { 59 | return cityName; 60 | } 61 | 62 | public void setCityName(String cityName) { 63 | this.cityName = cityName; 64 | } 65 | 66 | public String getProvinceName() { 67 | return provinceName; 68 | } 69 | 70 | public void setProvinceName(String provinceName) { 71 | this.provinceName = provinceName; 72 | } 73 | 74 | public String getCityCode() { 75 | return cityCode; 76 | } 77 | 78 | public void setCityCode(String cityCode) { 79 | this.cityCode = cityCode; 80 | } 81 | 82 | public String getZipCode() { 83 | return zipCode; 84 | } 85 | 86 | public void setZipCode(String zipCode) { 87 | this.zipCode = zipCode; 88 | } 89 | 90 | public String getTelAreaCode() { 91 | return telAreaCode; 92 | } 93 | 94 | public void setTelAreaCode(String telAreaCode) { 95 | this.telAreaCode = telAreaCode; 96 | } 97 | 98 | @Override 99 | public String toString() { 100 | return "RetDataBean{}"; 101 | } 102 | } 103 | 104 | @Override 105 | public String toString() { 106 | return "CityModel{" + 107 | "errNum=" + errNum + 108 | ", retMsg='" + retMsg + '\'' + 109 | ", retData=" + retData + 110 | '}'; 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /example/src/main/java/com/tamic/excemple/model/IpResult.java: -------------------------------------------------------------------------------- 1 | package com.tamic.excemple.model; 2 | 3 | /** 4 | * Created by LIUYONGKUI726 on 2016-08-10. 5 | */ 6 | public class IpResult { 7 | 8 | /** 9 | * code : 0 10 | * data : {"country":"美国","country_id":"US","area":"","area_id":"","region":"","region_id":"","city":"","city_id":"","county":"","county_id":"","isp":"","isp_id":"","ip":"21.22.11.33"} 11 | */ 12 | 13 | private int code; 14 | /** 15 | * country : 美国 16 | * country_id : US 17 | * area : 18 | * area_id : 19 | * region : 20 | * region_id : 21 | * city : 22 | * city_id : 23 | * county : 24 | * county_id : 25 | * isp : 26 | * isp_id : 27 | * ip : 21.22.11.33 28 | */ 29 | 30 | private DataBean data; 31 | 32 | public int getCode() { 33 | return code; 34 | } 35 | 36 | public void setCode(int code) { 37 | this.code = code; 38 | } 39 | 40 | public DataBean getData() { 41 | return data; 42 | } 43 | 44 | public void setData(DataBean data) { 45 | this.data = data; 46 | } 47 | 48 | public static class DataBean { 49 | private String country; 50 | private String country_id; 51 | private String area; 52 | private String area_id; 53 | private String region; 54 | private String region_id; 55 | private String city; 56 | private String city_id; 57 | private String county; 58 | private String county_id; 59 | private String isp; 60 | private String isp_id; 61 | private String ip; 62 | 63 | public String getCountry() { 64 | return country; 65 | } 66 | 67 | public void setCountry(String country) { 68 | this.country = country; 69 | } 70 | 71 | public String getCountry_id() { 72 | return country_id; 73 | } 74 | 75 | public void setCountry_id(String country_id) { 76 | this.country_id = country_id; 77 | } 78 | 79 | public String getArea() { 80 | return area; 81 | } 82 | 83 | public void setArea(String area) { 84 | this.area = area; 85 | } 86 | 87 | public String getArea_id() { 88 | return area_id; 89 | } 90 | 91 | public void setArea_id(String area_id) { 92 | this.area_id = area_id; 93 | } 94 | 95 | public String getRegion() { 96 | return region; 97 | } 98 | 99 | public void setRegion(String region) { 100 | this.region = region; 101 | } 102 | 103 | public String getRegion_id() { 104 | return region_id; 105 | } 106 | 107 | public void setRegion_id(String region_id) { 108 | this.region_id = region_id; 109 | } 110 | 111 | public String getCity() { 112 | return city; 113 | } 114 | 115 | public void setCity(String city) { 116 | this.city = city; 117 | } 118 | 119 | public String getCity_id() { 120 | return city_id; 121 | } 122 | 123 | public void setCity_id(String city_id) { 124 | this.city_id = city_id; 125 | } 126 | 127 | public String getCounty() { 128 | return county; 129 | } 130 | 131 | public void setCounty(String county) { 132 | this.county = county; 133 | } 134 | 135 | public String getCounty_id() { 136 | return county_id; 137 | } 138 | 139 | public void setCounty_id(String county_id) { 140 | this.county_id = county_id; 141 | } 142 | 143 | public String getIsp() { 144 | return isp; 145 | } 146 | 147 | public void setIsp(String isp) { 148 | this.isp = isp; 149 | } 150 | 151 | public String getIsp_id() { 152 | return isp_id; 153 | } 154 | 155 | public void setIsp_id(String isp_id) { 156 | this.isp_id = isp_id; 157 | } 158 | 159 | public String getIp() { 160 | return ip; 161 | } 162 | 163 | public void setIp(String ip) { 164 | this.ip = ip; 165 | } 166 | } 167 | } 168 | -------------------------------------------------------------------------------- /example/src/main/java/com/tamic/excemple/model/ListData.java: -------------------------------------------------------------------------------- 1 | package com.tamic.excemple.model; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Created by tamic on 2017-06-09. 7 | */ 8 | 9 | public class ListData { 10 | 11 | 12 | public ListData(List musicBookCategoryList) { 13 | this.musicBookCategoryList = musicBookCategoryList; 14 | } 15 | 16 | public ListData() { 17 | } 18 | 19 | /** 20 | * id : 15 21 | * createDate : 1496286231000 22 | * modifyDate : 1496291243000 23 | * order : 1 24 | * name : 推荐1 25 | * treePath : ,13, 26 | * grade : 1 27 | */ 28 | 29 | 30 | 31 | private List musicBookCategoryList; 32 | 33 | public List getMusicBookCategoryList() { 34 | return musicBookCategoryList; 35 | } 36 | 37 | public void setMusicBookCategoryList(List musicBookCategoryList) { 38 | this.musicBookCategoryList = musicBookCategoryList; 39 | } 40 | 41 | public static class MusicBookCategoryListBean { 42 | private int id; 43 | private long createDate; 44 | private long modifyDate; 45 | private int order; 46 | private String name; 47 | private String treePath; 48 | private int grade; 49 | 50 | public MusicBookCategoryListBean() { 51 | } 52 | 53 | public int getId() { 54 | return id; 55 | } 56 | 57 | public void setId(int id) { 58 | this.id = id; 59 | } 60 | 61 | public long getCreateDate() { 62 | return createDate; 63 | } 64 | 65 | public void setCreateDate(long createDate) { 66 | this.createDate = createDate; 67 | } 68 | 69 | public long getModifyDate() { 70 | return modifyDate; 71 | } 72 | 73 | public void setModifyDate(long modifyDate) { 74 | this.modifyDate = modifyDate; 75 | } 76 | 77 | public int getOrder() { 78 | return order; 79 | } 80 | 81 | public void setOrder(int order) { 82 | this.order = order; 83 | } 84 | 85 | public String getName() { 86 | return name; 87 | } 88 | 89 | public void setName(String name) { 90 | this.name = name; 91 | } 92 | 93 | public String getTreePath() { 94 | return treePath; 95 | } 96 | 97 | public void setTreePath(String treePath) { 98 | this.treePath = treePath; 99 | } 100 | 101 | public int getGrade() { 102 | return grade; 103 | } 104 | 105 | public void setGrade(int grade) { 106 | this.grade = grade; 107 | } 108 | 109 | @Override 110 | public String toString() { 111 | return "MusicBookCategoryListBean{" + 112 | "id=" + id + 113 | ", createDate=" + createDate + 114 | ", modifyDate=" + modifyDate + 115 | ", order=" + order + 116 | ", name='" + name + '\'' + 117 | ", treePath='" + treePath + '\'' + 118 | ", grade=" + grade + 119 | '}'; 120 | } 121 | } 122 | 123 | @Override 124 | public String toString() { 125 | return "ListData{" + 126 | "musicBookCategoryList=" + musicBookCategoryList + 127 | '}'; 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /example/src/main/java/com/tamic/excemple/model/MovieModel.java: -------------------------------------------------------------------------------- 1 | package com.tamic.excemple.model; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Created by LIUYONGKUI726 on 2016-07-20. 7 | */ 8 | public class MovieModel { 9 | 10 | 11 | /** 12 | * count : 5 13 | * start : 0 14 | * total : 250 15 | * subjects : [{"rating":{"max":10,"average":9.6,"stars":"50","min":0},"genres":["犯罪","剧情"],"title":"肖申克的救赎","casts":[{"alt":"https://movie.douban.com/celebrity/1054521/","avatars":{"small":"http://img3.douban.com/img/celebrity/small/17525.jpg","large":"http://img3.douban.com/img/celebrity/large/17525.jpg","medium":"http://img3.douban.com/img/celebrity/medium/17525.jpg"},"name":"蒂姆·罗宾斯","id":"1054521"},{"alt":"https://movie.douban.com/celebrity/1054534/","avatars":{"small":"http://img3.douban.com/img/celebrity/small/34642.jpg","large":"http://img3.douban.com/img/celebrity/large/34642.jpg","medium":"http://img3.douban.com/img/celebrity/medium/34642.jpg"},"name":"摩根·弗里曼","id":"1054534"},{"alt":"https://movie.douban.com/celebrity/1041179/","avatars":{"small":"http://img3.doubanio.com/img/celebrity/small/5837.jpg","large":"http://img3.doubanio.com/img/celebrity/large/5837.jpg","medium":"http://img3.doubanio.com/img/celebrity/medium/5837.jpg"},"name":"鲍勃·冈顿","id":"1041179"}],"collect_count":942548,"original_title":"The Shawshank Redemption","subtype":"movie","directors":[{"alt":"https://movie.douban.com/celebrity/1047973/","avatars":{"small":"http://img3.douban.com/img/celebrity/small/230.jpg","large":"http://img3.douban.com/img/celebrity/large/230.jpg","medium":"http://img3.douban.com/img/celebrity/medium/230.jpg"},"name":"弗兰克·德拉邦特","id":"1047973"}],"year":"1994","images":{"small":"http://img3.douban.com/view/movie_poster_cover/ipst/public/p480747492.jpg","large":"http://img3.douban.com/view/movie_poster_cover/lpst/public/p480747492.jpg","medium":"http://img3.douban.com/view/movie_poster_cover/spst/public/p480747492.jpg"},"alt":"https://movie.douban.com/subject/1292052/","id":"1292052"},{"rating":{"max":10,"average":9.4,"stars":"50","min":0},"genres":["剧情","动作","犯罪"],"title":"这个杀手不太冷","casts":[{"alt":"https://movie.douban.com/celebrity/1025182/","avatars":{"small":"http://img3.douban.com/img/celebrity/small/8833.jpg","large":"http://img3.douban.com/img/celebrity/large/8833.jpg","medium":"http://img3.douban.com/img/celebrity/medium/8833.jpg"},"name":"让·雷诺","id":"1025182"},{"alt":"https://movie.douban.com/celebrity/1054454/","avatars":{"small":"http://img3.douban.com/img/celebrity/small/2274.jpg","large":"http://img3.douban.com/img/celebrity/large/2274.jpg","medium":"http://img3.douban.com/img/celebrity/medium/2274.jpg"},"name":"娜塔莉·波特曼","id":"1054454"},{"alt":"https://movie.douban.com/celebrity/1010507/","avatars":{"small":"http://img3.douban.com/img/celebrity/small/104.jpg","large":"http://img3.douban.com/img/celebrity/large/104.jpg","medium":"http://img3.douban.com/img/celebrity/medium/104.jpg"},"name":"加里·奥德曼","id":"1010507"}],"collect_count":910338,"original_title":"Léon","subtype":"movie","directors":[{"alt":"https://movie.douban.com/celebrity/1031876/","avatars":{"small":"http://img3.douban.com/img/celebrity/small/33301.jpg","large":"http://img3.douban.com/img/celebrity/large/33301.jpg","medium":"http://img3.douban.com/img/celebrity/medium/33301.jpg"},"name":"吕克·贝松","id":"1031876"}],"year":"1994","images":{"small":"http://img3.douban.com/view/movie_poster_cover/ipst/public/p511118051.jpg","large":"http://img3.douban.com/view/movie_poster_cover/lpst/public/p511118051.jpg","medium":"http://img3.douban.com/view/movie_poster_cover/spst/public/p511118051.jpg"},"alt":"https://movie.douban.com/subject/1295644/","id":"1295644"},{"rating":{"max":10,"average":9.4,"stars":"50","min":0},"genres":["剧情","爱情"],"title":"阿甘正传","casts":[{"alt":"https://movie.douban.com/celebrity/1054450/","avatars":{"small":"http://img3.douban.com/img/celebrity/small/551.jpg","large":"http://img3.douban.com/img/celebrity/large/551.jpg","medium":"http://img3.douban.com/img/celebrity/medium/551.jpg"},"name":"汤姆·汉克斯","id":"1054450"},{"alt":"https://movie.douban.com/celebrity/1002676/","avatars":{"small":"http://img3.doubanio.com/img/celebrity/small/51737.jpg","large":"http://img3.doubanio.com/img/celebrity/large/51737.jpg","medium":"http://img3.doubanio.com/img/celebrity/medium/51737.jpg"},"name":"罗宾·怀特","id":"1002676"},{"alt":"https://movie.douban.com/celebrity/1031848/","avatars":{"small":"http://img3.douban.com/img/celebrity/small/1345.jpg","large":"http://img3.douban.com/img/celebrity/large/1345.jpg","medium":"http://img3.douban.com/img/celebrity/medium/1345.jpg"},"name":"加里·西尼斯","id":"1031848"}],"collect_count":824734,"original_title":"Forrest Gump","subtype":"movie","directors":[{"alt":"https://movie.douban.com/celebrity/1053564/","avatars":{"small":"http://img3.douban.com/img/celebrity/small/505.jpg","large":"http://img3.douban.com/img/celebrity/large/505.jpg","medium":"http://img3.douban.com/img/celebrity/medium/505.jpg"},"name":"罗伯特·泽米吉斯","id":"1053564"}],"year":"1994","images":{"small":"http://img3.doubanio.com/view/movie_poster_cover/ipst/public/p510876377.jpg","large":"http://img3.doubanio.com/view/movie_poster_cover/lpst/public/p510876377.jpg","medium":"http://img3.doubanio.com/view/movie_poster_cover/spst/public/p510876377.jpg"},"alt":"https://movie.douban.com/subject/1292720/","id":"1292720"},{"rating":{"max":10,"average":9.5,"stars":"50","min":0},"genres":["剧情","爱情","同性"],"title":"霸王别姬","casts":[{"alt":"https://movie.douban.com/celebrity/1003494/","avatars":{"small":"http://img3.doubanio.com/img/celebrity/small/67.jpg","large":"http://img3.doubanio.com/img/celebrity/large/67.jpg","medium":"http://img3.doubanio.com/img/celebrity/medium/67.jpg"},"name":"张国荣","id":"1003494"},{"alt":"https://movie.douban.com/celebrity/1050265/","avatars":{"small":"http://img3.douban.com/img/celebrity/small/10381.jpg","large":"http://img3.douban.com/img/celebrity/large/10381.jpg","medium":"http://img3.douban.com/img/celebrity/medium/10381.jpg"},"name":"张丰毅","id":"1050265"},{"alt":"https://movie.douban.com/celebrity/1035641/","avatars":{"small":"http://img3.doubanio.com/img/celebrity/small/1399268395.47.jpg","large":"http://img3.doubanio.com/img/celebrity/large/1399268395.47.jpg","medium":"http://img3.doubanio.com/img/celebrity/medium/1399268395.47.jpg"},"name":"巩俐","id":"1035641"}],"collect_count":653047,"original_title":"霸王别姬","subtype":"movie","directors":[{"alt":"https://movie.douban.com/celebrity/1023040/","avatars":{"small":"http://img3.douban.com/img/celebrity/small/750.jpg","large":"http://img3.douban.com/img/celebrity/large/750.jpg","medium":"http://img3.douban.com/img/celebrity/medium/750.jpg"},"name":"陈凯歌","id":"1023040"}],"year":"1993","images":{"small":"http://img3.douban.com/view/movie_poster_cover/ipst/public/p1910813120.jpg","large":"http://img3.douban.com/view/movie_poster_cover/lpst/public/p1910813120.jpg","medium":"http://img3.douban.com/view/movie_poster_cover/spst/public/p1910813120.jpg"},"alt":"https://movie.douban.com/subject/1291546/","id":"1291546"},{"rating":{"max":10,"average":9.5,"stars":"50","min":0},"genres":["剧情","喜剧","爱情"],"title":"美丽人生","casts":[{"alt":"https://movie.douban.com/celebrity/1041004/","avatars":{"small":"http://img3.douban.com/img/celebrity/small/26764.jpg","large":"http://img3.douban.com/img/celebrity/large/26764.jpg","medium":"http://img3.douban.com/img/celebrity/medium/26764.jpg"},"name":"罗伯托·贝尼尼","id":"1041004"},{"alt":"https://movie.douban.com/celebrity/1000375/","avatars":{"small":"http://img3.doubanio.com/img/celebrity/small/9548.jpg","large":"http://img3.doubanio.com/img/celebrity/large/9548.jpg","medium":"http://img3.doubanio.com/img/celebrity/medium/9548.jpg"},"name":"尼可莱塔·布拉斯基","id":"1000375"},{"alt":"https://movie.douban.com/celebrity/1000368/","avatars":{"small":"http://img3.douban.com/img/celebrity/small/45590.jpg","large":"http://img3.douban.com/img/celebrity/large/45590.jpg","medium":"http://img3.douban.com/img/celebrity/medium/45590.jpg"},"name":"乔治·坎塔里尼","id":"1000368"}],"collect_count":446567,"original_title":"La vita è bella","subtype":"movie","directors":[{"alt":"https://movie.douban.com/celebrity/1041004/","avatars":{"small":"http://img3.douban.com/img/celebrity/small/26764.jpg","large":"http://img3.douban.com/img/celebrity/large/26764.jpg","medium":"http://img3.douban.com/img/celebrity/medium/26764.jpg"},"name":"罗伯托·贝尼尼","id":"1041004"}],"year":"1997","images":{"small":"http://img3.douban.com/view/movie_poster_cover/ipst/public/p510861873.jpg","large":"http://img3.douban.com/view/movie_poster_cover/lpst/public/p510861873.jpg","medium":"http://img3.douban.com/view/movie_poster_cover/spst/public/p510861873.jpg"},"alt":"https://movie.douban.com/subject/1292063/","id":"1292063"}] 16 | * title : 豆瓣电影Top250 17 | */ 18 | 19 | private int count; 20 | private int start; 21 | private int total; 22 | private String title; 23 | /** 24 | * rating : {"max":10,"average":9.6,"stars":"50","min":0} 25 | * genres : ["犯罪","剧情"] 26 | * title : 肖申克的救赎 27 | * casts : [{"alt":"https://movie.douban.com/celebrity/1054521/","avatars":{"small":"http://img3.douban.com/img/celebrity/small/17525.jpg","large":"http://img3.douban.com/img/celebrity/large/17525.jpg","medium":"http://img3.douban.com/img/celebrity/medium/17525.jpg"},"name":"蒂姆·罗宾斯","id":"1054521"},{"alt":"https://movie.douban.com/celebrity/1054534/","avatars":{"small":"http://img3.douban.com/img/celebrity/small/34642.jpg","large":"http://img3.douban.com/img/celebrity/large/34642.jpg","medium":"http://img3.douban.com/img/celebrity/medium/34642.jpg"},"name":"摩根·弗里曼","id":"1054534"},{"alt":"https://movie.douban.com/celebrity/1041179/","avatars":{"small":"http://img3.doubanio.com/img/celebrity/small/5837.jpg","large":"http://img3.doubanio.com/img/celebrity/large/5837.jpg","medium":"http://img3.doubanio.com/img/celebrity/medium/5837.jpg"},"name":"鲍勃·冈顿","id":"1041179"}] 28 | * collect_count : 942548 29 | * original_title : The Shawshank Redemption 30 | * subtype : movie 31 | * directors : [{"alt":"https://movie.douban.com/celebrity/1047973/","avatars":{"small":"http://img3.douban.com/img/celebrity/small/230.jpg","large":"http://img3.douban.com/img/celebrity/large/230.jpg","medium":"http://img3.douban.com/img/celebrity/medium/230.jpg"},"name":"弗兰克·德拉邦特","id":"1047973"}] 32 | * year : 1994 33 | * images : {"small":"http://img3.douban.com/view/movie_poster_cover/ipst/public/p480747492.jpg","large":"http://img3.douban.com/view/movie_poster_cover/lpst/public/p480747492.jpg","medium":"http://img3.douban.com/view/movie_poster_cover/spst/public/p480747492.jpg"} 34 | * alt : https://movie.douban.com/subject/1292052/ 35 | * id : 1292052 36 | */ 37 | 38 | private List subjects; 39 | 40 | public int getCount() { 41 | return count; 42 | } 43 | 44 | public void setCount(int count) { 45 | this.count = count; 46 | } 47 | 48 | public int getStart() { 49 | return start; 50 | } 51 | 52 | public void setStart(int start) { 53 | this.start = start; 54 | } 55 | 56 | public int getTotal() { 57 | return total; 58 | } 59 | 60 | public void setTotal(int total) { 61 | this.total = total; 62 | } 63 | 64 | public String getTitle() { 65 | return title; 66 | } 67 | 68 | public void setTitle(String title) { 69 | this.title = title; 70 | } 71 | 72 | public List getSubjects() { 73 | return subjects; 74 | } 75 | 76 | public void setSubjects(List subjects) { 77 | this.subjects = subjects; 78 | } 79 | 80 | public static class SubjectsBean { 81 | /** 82 | * max : 10 83 | * average : 9.6 84 | * stars : 50 85 | * min : 0 86 | */ 87 | 88 | private RatingBean rating; 89 | private String title; 90 | private int collect_count; 91 | private String original_title; 92 | private String subtype; 93 | private String year; 94 | /** 95 | * small : http://img3.douban.com/view/movie_poster_cover/ipst/public/p480747492.jpg 96 | * large : http://img3.douban.com/view/movie_poster_cover/lpst/public/p480747492.jpg 97 | * medium : http://img3.douban.com/view/movie_poster_cover/spst/public/p480747492.jpg 98 | */ 99 | 100 | private ImagesBean images; 101 | private String alt; 102 | private String id; 103 | private List genres; 104 | /** 105 | * alt : https://movie.douban.com/celebrity/1054521/ 106 | * avatars : {"small":"http://img3.douban.com/img/celebrity/small/17525.jpg","large":"http://img3.douban.com/img/celebrity/large/17525.jpg","medium":"http://img3.douban.com/img/celebrity/medium/17525.jpg"} 107 | * name : 蒂姆·罗宾斯 108 | * id : 1054521 109 | */ 110 | 111 | private List casts; 112 | /** 113 | * alt : https://movie.douban.com/celebrity/1047973/ 114 | * avatars : {"small":"http://img3.douban.com/img/celebrity/small/230.jpg","large":"http://img3.douban.com/img/celebrity/large/230.jpg","medium":"http://img3.douban.com/img/celebrity/medium/230.jpg"} 115 | * name : 弗兰克·德拉邦特 116 | * id : 1047973 117 | */ 118 | 119 | private List directors; 120 | 121 | public RatingBean getRating() { 122 | return rating; 123 | } 124 | 125 | public void setRating(RatingBean rating) { 126 | this.rating = rating; 127 | } 128 | 129 | public String getTitle() { 130 | return title; 131 | } 132 | 133 | public void setTitle(String title) { 134 | this.title = title; 135 | } 136 | 137 | public int getCollect_count() { 138 | return collect_count; 139 | } 140 | 141 | public void setCollect_count(int collect_count) { 142 | this.collect_count = collect_count; 143 | } 144 | 145 | public String getOriginal_title() { 146 | return original_title; 147 | } 148 | 149 | public void setOriginal_title(String original_title) { 150 | this.original_title = original_title; 151 | } 152 | 153 | public String getSubtype() { 154 | return subtype; 155 | } 156 | 157 | public void setSubtype(String subtype) { 158 | this.subtype = subtype; 159 | } 160 | 161 | public String getYear() { 162 | return year; 163 | } 164 | 165 | public void setYear(String year) { 166 | this.year = year; 167 | } 168 | 169 | public ImagesBean getImages() { 170 | return images; 171 | } 172 | 173 | public void setImages(ImagesBean images) { 174 | this.images = images; 175 | } 176 | 177 | public String getAlt() { 178 | return alt; 179 | } 180 | 181 | public void setAlt(String alt) { 182 | this.alt = alt; 183 | } 184 | 185 | public String getId() { 186 | return id; 187 | } 188 | 189 | public void setId(String id) { 190 | this.id = id; 191 | } 192 | 193 | public List getGenres() { 194 | return genres; 195 | } 196 | 197 | public void setGenres(List genres) { 198 | this.genres = genres; 199 | } 200 | 201 | public List getCasts() { 202 | return casts; 203 | } 204 | 205 | public void setCasts(List casts) { 206 | this.casts = casts; 207 | } 208 | 209 | public List getDirectors() { 210 | return directors; 211 | } 212 | 213 | public void setDirectors(List directors) { 214 | this.directors = directors; 215 | } 216 | 217 | public static class RatingBean { 218 | private int max; 219 | private double average; 220 | private String stars; 221 | private int min; 222 | 223 | public int getMax() { 224 | return max; 225 | } 226 | 227 | public void setMax(int max) { 228 | this.max = max; 229 | } 230 | 231 | public double getAverage() { 232 | return average; 233 | } 234 | 235 | public void setAverage(double average) { 236 | this.average = average; 237 | } 238 | 239 | public String getStars() { 240 | return stars; 241 | } 242 | 243 | public void setStars(String stars) { 244 | this.stars = stars; 245 | } 246 | 247 | public int getMin() { 248 | return min; 249 | } 250 | 251 | public void setMin(int min) { 252 | this.min = min; 253 | } 254 | 255 | @Override 256 | public String toString() { 257 | return "RatingBean{" + 258 | "max=" + max + 259 | ", average=" + average + 260 | ", stars='" + stars + '\'' + 261 | ", min=" + min + 262 | '}'; 263 | } 264 | } 265 | 266 | public static class ImagesBean { 267 | private String small; 268 | private String large; 269 | private String medium; 270 | 271 | public String getSmall() { 272 | return small; 273 | } 274 | 275 | public void setSmall(String small) { 276 | this.small = small; 277 | } 278 | 279 | public String getLarge() { 280 | return large; 281 | } 282 | 283 | public void setLarge(String large) { 284 | this.large = large; 285 | } 286 | 287 | public String getMedium() { 288 | return medium; 289 | } 290 | 291 | public void setMedium(String medium) { 292 | this.medium = medium; 293 | } 294 | 295 | @Override 296 | public String toString() { 297 | return "ImagesBean{" + 298 | "small='" + small + '\'' + 299 | ", large='" + large + '\'' + 300 | ", medium='" + medium + '\'' + 301 | '}'; 302 | } 303 | } 304 | 305 | public static class CastsBean { 306 | private String alt; 307 | /** 308 | * small : http://img3.douban.com/img/celebrity/small/17525.jpg 309 | * large : http://img3.douban.com/img/celebrity/large/17525.jpg 310 | * medium : http://img3.douban.com/img/celebrity/medium/17525.jpg 311 | */ 312 | 313 | private AvatarsBean avatars; 314 | private String name; 315 | private String id; 316 | 317 | public String getAlt() { 318 | return alt; 319 | } 320 | 321 | public void setAlt(String alt) { 322 | this.alt = alt; 323 | } 324 | 325 | public AvatarsBean getAvatars() { 326 | return avatars; 327 | } 328 | 329 | public void setAvatars(AvatarsBean avatars) { 330 | this.avatars = avatars; 331 | } 332 | 333 | public String getName() { 334 | return name; 335 | } 336 | 337 | public void setName(String name) { 338 | this.name = name; 339 | } 340 | 341 | public String getId() { 342 | return id; 343 | } 344 | 345 | public void setId(String id) { 346 | this.id = id; 347 | } 348 | 349 | public static class AvatarsBean { 350 | private String small; 351 | private String large; 352 | private String medium; 353 | 354 | public String getSmall() { 355 | return small; 356 | } 357 | 358 | public void setSmall(String small) { 359 | this.small = small; 360 | } 361 | 362 | public String getLarge() { 363 | return large; 364 | } 365 | 366 | public void setLarge(String large) { 367 | this.large = large; 368 | } 369 | 370 | public String getMedium() { 371 | return medium; 372 | } 373 | 374 | public void setMedium(String medium) { 375 | this.medium = medium; 376 | } 377 | 378 | @Override 379 | public String toString() { 380 | return "AvatarsBean{" + 381 | "small='" + small + '\'' + 382 | ", large='" + large + '\'' + 383 | ", medium='" + medium + '\'' + 384 | '}'; 385 | } 386 | } 387 | 388 | @Override 389 | public String toString() { 390 | return "CastsBean{" + 391 | "alt='" + alt + '\'' + 392 | ", avatars=" + avatars + 393 | ", name='" + name + '\'' + 394 | ", id='" + id + '\'' + 395 | '}'; 396 | } 397 | } 398 | 399 | public static class DirectorsBean { 400 | private String alt; 401 | /** 402 | * small : http://img3.douban.com/img/celebrity/small/230.jpg 403 | * large : http://img3.douban.com/img/celebrity/large/230.jpg 404 | * medium : http://img3.douban.com/img/celebrity/medium/230.jpg 405 | */ 406 | 407 | private AvatarsBean avatars; 408 | private String name; 409 | private String id; 410 | 411 | public String getAlt() { 412 | return alt; 413 | } 414 | 415 | public void setAlt(String alt) { 416 | this.alt = alt; 417 | } 418 | 419 | public AvatarsBean getAvatars() { 420 | return avatars; 421 | } 422 | 423 | public void setAvatars(AvatarsBean avatars) { 424 | this.avatars = avatars; 425 | } 426 | 427 | public String getName() { 428 | return name; 429 | } 430 | 431 | public void setName(String name) { 432 | this.name = name; 433 | } 434 | 435 | public String getId() { 436 | return id; 437 | } 438 | 439 | public void setId(String id) { 440 | this.id = id; 441 | } 442 | 443 | public static class AvatarsBean { 444 | private String small; 445 | private String large; 446 | private String medium; 447 | 448 | public String getSmall() { 449 | return small; 450 | } 451 | 452 | public void setSmall(String small) { 453 | this.small = small; 454 | } 455 | 456 | public String getLarge() { 457 | return large; 458 | } 459 | 460 | public void setLarge(String large) { 461 | this.large = large; 462 | } 463 | 464 | public String getMedium() { 465 | return medium; 466 | } 467 | 468 | public void setMedium(String medium) { 469 | this.medium = medium; 470 | } 471 | 472 | @Override 473 | public String toString() { 474 | return "AvatarsBean{" + 475 | "small='" + small + '\'' + 476 | ", large='" + large + '\'' + 477 | ", medium='" + medium + '\'' + 478 | '}'; 479 | } 480 | } 481 | 482 | @Override 483 | public String toString() { 484 | return "DirectorsBean{" + 485 | "alt='" + alt + '\'' + 486 | ", avatars=" + avatars + 487 | ", name='" + name + '\'' + 488 | ", id='" + id + '\'' + 489 | '}'; 490 | } 491 | } 492 | 493 | @Override 494 | public String toString() { 495 | return "SubjectsBean{" + 496 | "rating=" + rating + 497 | ", title='" + title + '\'' + 498 | ", collect_count=" + collect_count + 499 | ", original_title='" + original_title + '\'' + 500 | ", subtype='" + subtype + '\'' + 501 | ", year='" + year + '\'' + 502 | ", images=" + images + 503 | ", alt='" + alt + '\'' + 504 | ", id='" + id + '\'' + 505 | ", genres=" + genres + 506 | ", casts=" + casts + 507 | ", directors=" + directors + 508 | '}'; 509 | } 510 | } 511 | 512 | 513 | @Override 514 | public String toString() { 515 | return "MovieModel{" + 516 | "count=" + count + 517 | ", start=" + start + 518 | ", total=" + total + 519 | ", title='" + title + '\'' + 520 | ", subjects=" + subjects + 521 | '}'; 522 | } 523 | } 524 | -------------------------------------------------------------------------------- /example/src/main/java/com/tamic/excemple/model/MusicBookCategory.java: -------------------------------------------------------------------------------- 1 | package com.tamic.excemple.model; 2 | 3 | /** 4 | * Created by tamic on 2017-06-09. 5 | */ 6 | 7 | public class MusicBookCategory { 8 | 9 | 10 | public MusicBookCategory() { 11 | } 12 | 13 | 14 | 15 | /** 16 | * id : 15 17 | * createDate : 1496286231000 18 | * modifyDate : 1496291243000 19 | * order : 1 20 | * name : 推荐1 21 | * treePath : ,13, 22 | * grade : 1 23 | */ 24 | 25 | private int id; 26 | private long createDate; 27 | private long modifyDate; 28 | private int order; 29 | private String name; 30 | private String treePath; 31 | private int grade; 32 | 33 | public int getId() { 34 | return id; 35 | } 36 | 37 | public void setId(int id) { 38 | this.id = id; 39 | } 40 | 41 | public long getCreateDate() { 42 | return createDate; 43 | } 44 | 45 | public void setCreateDate(long createDate) { 46 | this.createDate = createDate; 47 | } 48 | 49 | public long getModifyDate() { 50 | return modifyDate; 51 | } 52 | 53 | public void setModifyDate(long modifyDate) { 54 | this.modifyDate = modifyDate; 55 | } 56 | 57 | public int getOrder() { 58 | return order; 59 | } 60 | 61 | public void setOrder(int order) { 62 | this.order = order; 63 | } 64 | 65 | public String getName() { 66 | return name; 67 | } 68 | 69 | public void setName(String name) { 70 | this.name = name; 71 | } 72 | 73 | public String getTreePath() { 74 | return treePath; 75 | } 76 | 77 | public void setTreePath(String treePath) { 78 | this.treePath = treePath; 79 | } 80 | 81 | public int getGrade() { 82 | return grade; 83 | } 84 | 85 | public void setGrade(int grade) { 86 | this.grade = grade; 87 | } 88 | 89 | 90 | @Override 91 | public String toString() { 92 | return "MusicBookCategory{" + 93 | "id=" + id + 94 | ", createDate=" + createDate + 95 | ", modifyDate=" + modifyDate + 96 | ", order=" + order + 97 | ", name='" + name + '\'' + 98 | ", treePath='" + treePath + '\'' + 99 | ", grade=" + grade + 100 | '}'; 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /example/src/main/java/com/tamic/excemple/model/ResultModel.java: -------------------------------------------------------------------------------- 1 | package com.tamic.excemple.model; 2 | 3 | /** 4 | * 实际项目中你可以把这个类删除 5 | * Created by Tamic on 2016-06-03. 6 | */ 7 | public class ResultModel { 8 | private String country; 9 | private String country_id; 10 | private String area; 11 | private String area_id; 12 | private String region; 13 | private String region_id; 14 | private String city; 15 | private String city_id; 16 | private String county; 17 | private String county_id; 18 | private String isp; 19 | private String isp_id; 20 | private String ip; 21 | 22 | public String getCountry() { 23 | return country; 24 | } 25 | 26 | public void setCountry(String country) { 27 | this.country = country; 28 | } 29 | 30 | public String getCountry_id() { 31 | return country_id; 32 | } 33 | 34 | public void setCountry_id(String country_id) { 35 | this.country_id = country_id; 36 | } 37 | 38 | public String getArea() { 39 | return area; 40 | } 41 | 42 | public void setArea(String area) { 43 | this.area = area; 44 | } 45 | 46 | public String getArea_id() { 47 | return area_id; 48 | } 49 | 50 | public void setArea_id(String area_id) { 51 | this.area_id = area_id; 52 | } 53 | 54 | public String getRegion() { 55 | return region; 56 | } 57 | 58 | public void setRegion(String region) { 59 | this.region = region; 60 | } 61 | 62 | public String getRegion_id() { 63 | return region_id; 64 | } 65 | 66 | public void setRegion_id(String region_id) { 67 | this.region_id = region_id; 68 | } 69 | 70 | public String getCity() { 71 | return city; 72 | } 73 | 74 | public void setCity(String city) { 75 | this.city = city; 76 | } 77 | 78 | public String getCity_id() { 79 | return city_id; 80 | } 81 | 82 | public void setCity_id(String city_id) { 83 | this.city_id = city_id; 84 | } 85 | 86 | public String getCounty() { 87 | return county; 88 | } 89 | 90 | public void setCounty(String county) { 91 | this.county = county; 92 | } 93 | 94 | public String getCounty_id() { 95 | return county_id; 96 | } 97 | 98 | public void setCounty_id(String county_id) { 99 | this.county_id = county_id; 100 | } 101 | 102 | public String getIsp() { 103 | return isp; 104 | } 105 | 106 | public void setIsp(String isp) { 107 | this.isp = isp; 108 | } 109 | 110 | public String getIsp_id() { 111 | return isp_id; 112 | } 113 | 114 | public void setIsp_id(String isp_id) { 115 | this.isp_id = isp_id; 116 | } 117 | 118 | public String getIp() { 119 | return ip; 120 | } 121 | 122 | public void setIp(String ip) { 123 | this.ip = ip; 124 | } 125 | 126 | @Override 127 | public String toString() { 128 | return "DataBean{" + 129 | "country='" + country + '\'' + 130 | ", country_id='" + country_id + '\'' + 131 | ", area='" + area + '\'' + 132 | ", area_id='" + area_id + '\'' + 133 | ", region='" + region + '\'' + 134 | ", region_id='" + region_id + '\'' + 135 | ", city='" + city + '\'' + 136 | ", city_id='" + city_id + '\'' + 137 | ", county='" + county + '\'' + 138 | ", county_id='" + county_id + '\'' + 139 | ", isp='" + isp + '\'' + 140 | ", isp_id='" + isp_id + '\'' + 141 | ", ip='" + ip + '\'' + 142 | '}'; 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /example/src/main/java/com/tamic/excemple/model/SouguBean.java: -------------------------------------------------------------------------------- 1 | package com.tamic.excemple.model; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Created by Tamic on 2016-08-09. 7 | */ 8 | public class SouguBean { 9 | private String error; 10 | private String message; 11 | private String charge_time; 12 | private String charge_moeny; 13 | private String charge_else_moeny; 14 | private String contract_moeny; 15 | private String ad_time; 16 | private String ad_on; 17 | private String ad_url; 18 | private String theme_url; 19 | private String session; 20 | 21 | private List app_top_img; 22 | 23 | public String getError() { 24 | return error; 25 | } 26 | 27 | public void setError(String error) { 28 | this.error = error; 29 | } 30 | 31 | public String getMessage() { 32 | return message; 33 | } 34 | 35 | public void setMessage(String message) { 36 | this.message = message; 37 | } 38 | 39 | public String getCharge_time() { 40 | return charge_time; 41 | } 42 | 43 | public void setCharge_time(String charge_time) { 44 | this.charge_time = charge_time; 45 | } 46 | 47 | public String getCharge_moeny() { 48 | return charge_moeny; 49 | } 50 | 51 | public void setCharge_moeny(String charge_moeny) { 52 | this.charge_moeny = charge_moeny; 53 | } 54 | 55 | public String getCharge_else_moeny() { 56 | return charge_else_moeny; 57 | } 58 | 59 | public void setCharge_else_moeny(String charge_else_moeny) { 60 | this.charge_else_moeny = charge_else_moeny; 61 | } 62 | 63 | public String getContract_moeny() { 64 | return contract_moeny; 65 | } 66 | 67 | public void setContract_moeny(String contract_moeny) { 68 | this.contract_moeny = contract_moeny; 69 | } 70 | 71 | public String getAd_time() { 72 | return ad_time; 73 | } 74 | 75 | public void setAd_time(String ad_time) { 76 | this.ad_time = ad_time; 77 | } 78 | 79 | public String getAd_on() { 80 | return ad_on; 81 | } 82 | 83 | public void setAd_on(String ad_on) { 84 | this.ad_on = ad_on; 85 | } 86 | 87 | public String getAd_url() { 88 | return ad_url; 89 | } 90 | 91 | public void setAd_url(String ad_url) { 92 | this.ad_url = ad_url; 93 | } 94 | 95 | public String getTheme_url() { 96 | return theme_url; 97 | } 98 | 99 | public void setTheme_url(String theme_url) { 100 | this.theme_url = theme_url; 101 | } 102 | 103 | public String getSession() { 104 | return session; 105 | } 106 | 107 | public void setSession(String session) { 108 | this.session = session; 109 | } 110 | 111 | public List getApp_top_img() { 112 | return app_top_img; 113 | } 114 | 115 | public void setApp_top_img(List app_top_img) { 116 | this.app_top_img = app_top_img; 117 | } 118 | 119 | public static class AppTopImgBean { 120 | private String IMG_URL; 121 | private String IMG_NAME; 122 | private String IMG_HTTP; 123 | 124 | public String getIMG_URL() { 125 | return IMG_URL; 126 | } 127 | 128 | public void setIMG_URL(String IMG_URL) { 129 | this.IMG_URL = IMG_URL; 130 | } 131 | 132 | public String getIMG_NAME() { 133 | return IMG_NAME; 134 | } 135 | 136 | public void setIMG_NAME(String IMG_NAME) { 137 | this.IMG_NAME = IMG_NAME; 138 | } 139 | 140 | public String getIMG_HTTP() { 141 | return IMG_HTTP; 142 | } 143 | 144 | public void setIMG_HTTP(String IMG_HTTP) { 145 | this.IMG_HTTP = IMG_HTTP; 146 | } 147 | } 148 | 149 | @Override 150 | public String toString() { 151 | return "SouguBean{" + 152 | "error='" + error + '\'' + 153 | ", message='" + message + '\'' + 154 | ", charge_time='" + charge_time + '\'' + 155 | ", charge_moeny='" + charge_moeny + '\'' + 156 | ", charge_else_moeny='" + charge_else_moeny + '\'' + 157 | ", contract_moeny='" + contract_moeny + '\'' + 158 | ", ad_time='" + ad_time + '\'' + 159 | ", ad_on='" + ad_on + '\'' + 160 | ", ad_url='" + ad_url + '\'' + 161 | ", theme_url='" + theme_url + '\'' + 162 | ", session='" + session + '\'' + 163 | ", app_top_img=" + app_top_img + 164 | '}'; 165 | } 166 | } 167 | -------------------------------------------------------------------------------- /example/src/main/java/com/tamic/excemple/model/wetherModel.java: -------------------------------------------------------------------------------- 1 | package com.tamic.excemple.model; 2 | 3 | /** 4 | * Created by LIUYONGKUI726 on 2016-08-11. 5 | */ 6 | public class wetherModel { 7 | 8 | 9 | /** 10 | * errNum : 0 11 | * errMsg : success 12 | * retData : {"city":"上海","pinyin":"shanghai","citycode":"101020100","date":"16-08-11","time":"11:00","postCode":"200000","longitude":121.445,"latitude":31.213,"altitude":"19","weather":"多云","temp":"35","l_tmp":"28","h_tmp":"35","WD":"东风","WS":"微风(<10km/h)","sunrise":"05:17","sunset":"18:41"} 13 | */ 14 | 15 | private int errNum; 16 | private String errMsg; 17 | /** 18 | * city : 上海 19 | * pinyin : shanghai 20 | * citycode : 101020100 21 | * date : 16-08-11 22 | * time : 11:00 23 | * postCode : 200000 24 | * longitude : 121.445 25 | * latitude : 31.213 26 | * altitude : 19 27 | * weather : 多云 28 | * temp : 35 29 | * l_tmp : 28 30 | * h_tmp : 35 31 | * WD : 东风 32 | * WS : 微风(<10km/h) 33 | * sunrise : 05:17 34 | * sunset : 18:41 35 | */ 36 | 37 | private RetDataBean retData; 38 | 39 | public int getErrNum() { 40 | return errNum; 41 | } 42 | 43 | public void setErrNum(int errNum) { 44 | this.errNum = errNum; 45 | } 46 | 47 | public String getErrMsg() { 48 | return errMsg; 49 | } 50 | 51 | public void setErrMsg(String errMsg) { 52 | this.errMsg = errMsg; 53 | } 54 | 55 | public RetDataBean getRetData() { 56 | return retData; 57 | } 58 | 59 | public void setRetData(RetDataBean retData) { 60 | this.retData = retData; 61 | } 62 | 63 | public static class RetDataBean { 64 | private String city; 65 | private String pinyin; 66 | private String citycode; 67 | private String date; 68 | private String time; 69 | private String postCode; 70 | private double longitude; 71 | private double latitude; 72 | private String altitude; 73 | private String weather; 74 | private String temp; 75 | private String l_tmp; 76 | private String h_tmp; 77 | private String WD; 78 | private String WS; 79 | private String sunrise; 80 | private String sunset; 81 | 82 | public String getCity() { 83 | return city; 84 | } 85 | 86 | public void setCity(String city) { 87 | this.city = city; 88 | } 89 | 90 | public String getPinyin() { 91 | return pinyin; 92 | } 93 | 94 | public void setPinyin(String pinyin) { 95 | this.pinyin = pinyin; 96 | } 97 | 98 | public String getCitycode() { 99 | return citycode; 100 | } 101 | 102 | public void setCitycode(String citycode) { 103 | this.citycode = citycode; 104 | } 105 | 106 | public String getDate() { 107 | return date; 108 | } 109 | 110 | public void setDate(String date) { 111 | this.date = date; 112 | } 113 | 114 | public String getTime() { 115 | return time; 116 | } 117 | 118 | public void setTime(String time) { 119 | this.time = time; 120 | } 121 | 122 | public String getPostCode() { 123 | return postCode; 124 | } 125 | 126 | public void setPostCode(String postCode) { 127 | this.postCode = postCode; 128 | } 129 | 130 | public double getLongitude() { 131 | return longitude; 132 | } 133 | 134 | public void setLongitude(double longitude) { 135 | this.longitude = longitude; 136 | } 137 | 138 | public double getLatitude() { 139 | return latitude; 140 | } 141 | 142 | public void setLatitude(double latitude) { 143 | this.latitude = latitude; 144 | } 145 | 146 | public String getAltitude() { 147 | return altitude; 148 | } 149 | 150 | public void setAltitude(String altitude) { 151 | this.altitude = altitude; 152 | } 153 | 154 | public String getWeather() { 155 | return weather; 156 | } 157 | 158 | public void setWeather(String weather) { 159 | this.weather = weather; 160 | } 161 | 162 | public String getTemp() { 163 | return temp; 164 | } 165 | 166 | public void setTemp(String temp) { 167 | this.temp = temp; 168 | } 169 | 170 | public String getL_tmp() { 171 | return l_tmp; 172 | } 173 | 174 | public void setL_tmp(String l_tmp) { 175 | this.l_tmp = l_tmp; 176 | } 177 | 178 | public String getH_tmp() { 179 | return h_tmp; 180 | } 181 | 182 | public void setH_tmp(String h_tmp) { 183 | this.h_tmp = h_tmp; 184 | } 185 | 186 | public String getWD() { 187 | return WD; 188 | } 189 | 190 | public void setWD(String WD) { 191 | this.WD = WD; 192 | } 193 | 194 | public String getWS() { 195 | return WS; 196 | } 197 | 198 | public void setWS(String WS) { 199 | this.WS = WS; 200 | } 201 | 202 | public String getSunrise() { 203 | return sunrise; 204 | } 205 | 206 | public void setSunrise(String sunrise) { 207 | this.sunrise = sunrise; 208 | } 209 | 210 | public String getSunset() { 211 | return sunset; 212 | } 213 | 214 | public void setSunset(String sunset) { 215 | this.sunset = sunset; 216 | } 217 | } 218 | } 219 | -------------------------------------------------------------------------------- /example/src/main/res/layout/activity_exemple.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 |