Android 推荐引入的库与基本使用
来源:互联网 发布:室内手机手绘软件 编辑:程序博客网 时间:2024/06/06 05:41
推荐使用的库(直接看gradle文件吧):
apply plugin: 'com.android.library'apply plugin: 'me.tatarka.retrolambda'apply plugin: 'com.neenbedankt.android-apt'android { compileSdkVersion 23 buildToolsVersion "23.0.3" defaultConfig { minSdkVersion 16 targetSdkVersion 23 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 }}dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:23.2.1' compile 'com.github.bumptech.glide:glide:3.7.0' compile 'com.android.support:multidex:1.0.1' compile 'com.nineoldandroids:library:2.4.0' compile 'com.android.support:recyclerview-v7:23.2.1' compile 'io.reactivex:rxandroid:1.0.1' compile 'io.reactivex:rxjava:1.0.17' compile 'com.jakewharton:butterknife:8.4.0' provided 'org.greenrobot:eventbus:3.0.0' compile 'com.alibaba:fastjson:1.2.18' compile 'com.google.dagger:dagger:2.2' apt 'com.google.dagger:dagger-compiler:2.2'}
一些基本使用:
FastJson:
import com.alibaba.fastjson.JSON;import com.alibaba.fastjson.JSONObject;import com.alibaba.fastjson.TypeReference;import com.alibaba.fastjson.serializer.SerializerFeature;import java.util.List;import java.util.Map;/** * Created by yaphetzhao on 2016/10/19. * JsonUtil * alibaba fastjson */public class JsonUtil {// 序列化:// String jsonString = JSON.toJSONString(obj);// 反序列化:// VO vo = JSON.parseObject("...", VO.class);// 泛型反序列化:// import com.alibaba.fastjson.TypeReference;// List<VO> list = JSON.parseObject("...", new TypeReference<List<VO>>() {}); /** * 把JSON数据转换成普通字符串列表 * * @param jsonData JSON数据 * @throws Exception */ public static List<String> getStringList(String jsonData) throws Exception { return JSON.parseArray(jsonData, String.class); } /** * 把JSON数据转换成指定的java对象 * * @param jsonData JSON数据 * @param clazz 指定的java对象 * @throws Exception */ public static <T> T getSingleBean(String jsonData, Class<T> clazz) throws Exception { return JSON.parseObject(jsonData, clazz); } /** * 把JSON数据转换成指定的java对象列表 * * @param jsonData JSON数据 * @param clazz 指定的java对象 * @throws Exception */ public static <T> List<T> getBeanList(String jsonData, Class<T> clazz) throws Exception { return JSON.parseArray(jsonData, clazz); } /** * 把JSON数据转换成较为复杂的java对象列表 * * @param jsonData JSON数据 * @throws Exception */ public static List<Map<String, Object>> getBeanMapList(String jsonData) throws Exception { return JSON.parseObject(jsonData, new TypeReference<List<Map<String, Object>>>() { }); } /** * 将网络请求下来的数据用fastjson处理空的情况,并将时间戳转化为标准时间格式 * * @param result */ public static String dealResponseResult(String result) { result = JSONObject.toJSONString(result, SerializerFeature.WriteClassName, SerializerFeature.WriteMapNullValue, SerializerFeature.WriteNullBooleanAsFalse, SerializerFeature.WriteNullListAsEmpty, SerializerFeature.WriteNullNumberAsZero, SerializerFeature.WriteNullStringAsEmpty, SerializerFeature.WriteDateUseDateFormat, SerializerFeature.WriteEnumUsingToString, SerializerFeature.WriteSlashAsSpecial, SerializerFeature.WriteTabAsSpecial); return result; }}
其他:
懒得写
0 0
- Android 推荐引入的库与基本使用
- Semantic UI 的基本使用(一):下载与引入
- Semantic UI 的基本使用:下载与引入
- Android Studio的使用——引入库如:引入PullToRefresh的library
- android studio使用依赖引入第三方库的路径
- Android Service 的介绍与基本使用
- Android 字体库的使用。引入外部字体
- Android点9图的使用与制作工具推荐
- php推荐使用的文件名声明与SQL的基本语句汇总
- 推荐使用的Android特效
- Android 推荐使用的数据结构
- Android基本界面元素的使用与讲解
- Android中ListView的基本使用与优化
- Android 基本控件的使用五(ListView 与 ArrayAdapter)
- Android相机的基本使用与自定义相机
- Android控件系列之RadioButton与RadioGroup的基本使用
- Android--Animation动画的基本使用与介绍
- Android--Glide图片加载框架的基本使用与介绍
- 区分 #{} 和 ${}的不同应用场景
- Java语言程序设计基础篇原书第十版第二章编程练习题答案
- jsp(out对象可以向html页面中输出)
- 如何在wampserver添加多个本地网站
- android studio 修改包名
- Android 推荐引入的库与基本使用
- linux 中安装nginx 的虚拟主机
- 基于Red5的流媒体实时视频系统的设计与实现
- AAC raw包增加ADTS头
- Parcelable、序列化
- Kali 2016版本 open-vm-tools 安装
- super关键字的使用
- jQuery开发插件的两个方法
- Linux知识笔记----文件属性