android:Retrofit+LoganSquare的简单用法

来源:互联网 发布:hyper v配置nat网络 编辑:程序博客网 时间:2024/06/01 15:04

先放上一张对比图



这个速度 简直让人爽到不行


首先需要在你的根项目下的build.gradle的dependencies中添加

classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' 
随后在app的build.gradle中添加:
apply plugin: 'com.neenbedankt.android-apt'
dependencies中添加
apt 'com.bluelinelabs:logansquare-compiler:1.3.7'//LoganSquare解析compile 'com.bluelinelabs:logansquare:1.3.7'compile "com.github.aurae.retrofit2:converter-logansquare:1.4.1"
添加好依赖之后  就需要把他添加到retrofit中了,用法如下图,或者参考GIT:https://github.com/aurae/retrofit-logansquare

剩下的 也是最重要的一步 把模型层添加上注解
类的注解是@JsonObject   属性的注解是@JsonField
当然还有一种写法是
添加注解很麻烦   所以在这里推荐AS的一个插件

用了之后你会发现  很方便,速度也是杠杠的


0 0