Retrofit2+Rxjava2 okhttp RxBus 使用记录
学习 博客 http://blog.csdn.net/r17171709/article/details/51149350
@Query 后面跟要添加的字段
@Path 连接url里面{userId} @Path("userId") String userId
RxJava2 浅析
http://www.jcodecraeer.com/a/anzhuokaifa/androidkaifa/2016/0907/6604.html
RxJava2+Retrofit2网络框架封装
http://blog.csdn.net/gesanri/article/details/52701651
Log打印参数封装类
http://www.jianshu.com/p/2b0aeb6b6b61/
public static Retrofit create() {
OkHttpClient.Builder builder = new OkHttpClient().newBuilder();
builder.readTimeout(10, TimeUnit.SECONDS);
builder.connectTimeout(9, TimeUnit.SECONDS);
/**添加log注释**/
if (BuildConfig.DEBUG) {
/***这里默认使用Log Debug模式打印**/
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
builder.addInterceptor(interceptor);
builder.addNetworkInterceptor(new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.HEADERS));
builder.addNetworkInterceptor(new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BASIC));
}
return new Retrofit.Builder().baseUrl(SERVER_URL)
.client(builder.build())
.addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.build();
}
Retrofit网络安全的了解:
http://www.jianshu.com/p/16994e49e2f6
学习Https ssl证书,如何生成自签名的证书。
http://blog.csdn.net/u013424496/article/details/51161647
HTTPS 和 SSL 确保安全
https://developer.android.google.cn/training/articles/security-ssl.html
Retrofit2实现访问Https
http://blog.csdn.net/PengFFF/article/details/70682494
http://www.jianshu.com/p/16994e49e2f6
RxBus
http://www.jianshu.com/p/7f4a709d2be5
http://reactivex.io/RxJava/2.x/javadoc/io/reactivex/subjects/PublishSubject.html
Class PublishSubject<T>
- java.lang.Object
- io.reactivex.Observable<T>
- io.reactivex.subjects.Subject<T>
- io.reactivex.subjects.PublishSubject<T>
- Type Parameters:
T- the type of items observed and emitted by the Subject
- All Implemented Interfaces:
- ObservableSource<T>, Observer<T>

-
PublishSubject<Object> subject = PublishSubject.create();
// observer1 will receive all onNext and onComplete events
subject.subscribe(observer1);
subject.onNext("one");
subject.onNext("two");
// observer2 will only receive "three" and onComplete
subject.subscribe(observer2);
subject.onNext("three");
subject.onComplete();http://reactivex.io/RxJava/2.x/javadoc/io/reactivex/subjects/BehaviorSubject.html
io.reactivex.subjectsClass BehaviorSubject<T>
- java.lang.Object
- io.reactivex.Observable<T>
- io.reactivex.subjects.Subject<T>
- io.reactivex.subjects.BehaviorSubject<T>
- Type Parameters:
T- the type of item expected to be observed by the Subject
- All Implemented Interfaces:
- ObservableSource<T>, Observer<T>

-
Example usage: // observer will receive all 4 events (including "default").
BehaviorSubject<Object> subject = BehaviorSubject.createDefault("default");
subject.subscribe(observer);
subject.onNext("one");
subject.onNext("two");
subject.onNext("three"); // observer will receive the "one", "two" and "three" events, but not "zero"
BehaviorSubject<Object> subject = BehaviorSubject.create();
subject.onNext("zero");
subject.onNext("one");
subject.subscribe(observer);
subject.onNext("two");
subject.onNext("three"); // observer will receive only onComplete
BehaviorSubject<Object> subject = BehaviorSubject.create();
subject.onNext("zero");
subject.onNext("one");
subject.onComplete();
subject.subscribe(observer); // observer will receive only onError
BehaviorSubject<Object> subject = BehaviorSubject.create();
subject.onNext("zero");
subject.onNext("one");
subject.onError(new RuntimeException("error"));
subject.subscribe(observer);
http://reactivex.io/RxJava/2.x/javadoc/io/reactivex/subjects/ReplaySubject.html
Class ReplaySubject<T>
- java.lang.Object
- io.reactivex.Observable<T>
- io.reactivex.subjects.Subject<T>
- io.reactivex.subjects.ReplaySubject<T>
- Type Parameters:
T- the value type
- All Implemented Interfaces:
- ObservableSource<T>, Observer<T>

-
ReplaySubject<Object> subject = new ReplaySubject<>();
subject.onNext("one");
subject.onNext("two");
subject.onNext("three");
subject.onComplete(); // both of the following will get the onNext/onComplete calls from above
subject.subscribe(observer1);
subject.subscribe(observer2);
Retrofit2+Rxjava2 okhttp RxBus 使用记录的更多相关文章
- Retrofit2+Rxjava+OkHttp的使用和网络请求
Retrofit2+Rxjava+OkHttp的使用和网络请求 https://blog.csdn.net/huandroid/article/details/79883895 加入Rxjava 如果 ...
- Android 从零开始搭建一个主流项目框架—RxJava2.0+Retrofit2.0+OkHttp
我这里的网络请求是用的装饰者模式去写的,什么是装饰者模式呢?在不必改变原类文件和使用继承的情况下,动态地扩展一个对象的功能.它是通过创建一个包装对象,也就是装饰来包裹真实的对象.我的理解就是一个接口, ...
- 使用Retrofit2+RxJava2+ProtoBuf实现网络请求
引言 Retrofit 是一个用于 Android 和 Java 平台的类型安全的,底层使用OkHttp实现网络请求框架.Retrofit 通过将 API 抽象成 Java 接口而让我们连接到 RES ...
- Retrofit2.0+OkHttp设置统一的请求头(request headers)
有时候要求Retrofit2的接口中每个都要增加上headers,又不想做重复的事情,可以使用这种方法来为每个request请求都设置上相同的请求头header. 修改请求头request heade ...
- Retrofit2+Rxjava2的用法
近几年,Retrofit犹如燎原之火搬席卷了整个Android界.要是不懂Retrofit,简直不好意思出门... 由于近几个项目都没用到Retrofit,无奈只能业余时间自己撸一下,写的不好的地方, ...
- 浅谈Retrofit2+Rxjava2
近几年,Retrofit犹如燎原之火搬席卷了整个Android界.要是不懂Retrofit,简直不好意思出门...由于近几个项目都没用到Retrofit,无奈只能业余时间自己撸一下,写的不好的地方,还 ...
- MVP实战心得—封装Retrofit2.0+RxAndroid+RxBus
响应式编程框架,rxjava的扩展,很爽的链式编程 魅力在于对数据的处理,与线程切换的灵活性. 用来处理异步操作(Lambda表达式不会用.用Lambda表达式代码会更少,但不会的人会看不懂代码.不是 ...
- Retrofit2.0+OkHttp打印Request URL(请求地址参数)
学习了Retrofit中的拦截器功能:实现日志中打印请求头内容 Retrofit 2+ 是基于OKHttp进行封装的,那么也就是说想进行请求拦截然后进行打印出来的话,就必须要从OkHttp进行入手. ...
- retrofit2+rxjava+okhttp网络请求实现
第一步:添加依赖: compile 'io.reactivex:rxandroid:1.2.0' compile 'com.squareup.retrofit2:adapter-rxjava:2.1. ...
随机推荐
- maven教程基础
一.Maven介绍 我们在开发项目的过程中,会使用一些开源框架.第三方的工具等等,这些都是以jar包的方式被项目所引用,并且有些jar包还会依赖其他的jar包,我们同样需要添加到项目中,所有这些相关的 ...
- css-inline-block和float的布局二者择其一?
几个月前,带着不甘和忐忑毅然决然的在亚马逊离职了,当时不知道对我来说是好是坏,现在看来,当初的选择还是蛮不错的.感觉在亚马逊的几个月貌似接触最多的就是wiki和tt了,怀着对技术热忱离开,拒绝了腾讯, ...
- Hadoop高级培训课程大纲-管理员版
一.课程概述 本次培训课程主要面向大数据系统管理人员和开发设计人员,基于开源社区大数据应用最活跃的Hadoop和HBase技术框架.围绕分布式文件存储(HDFS).分布式并行计算(Map/Recue) ...
- 蓝桥杯 算法训练 ALGO-116 最大的算式
算法训练 最大的算式 时间限制:1.0s 内存限制:256.0MB 问题描述 题目很简单,给出N个数字,不改变它们的相对位置,在中间加入K个乘号和N-K-1个加号,(括号随便加)使最终结果尽量 ...
- bzoj 3768: spoj 4660 Binary palindrome二进制回文串
Description 给定k个长度不超过L的01串,求有多少长度为n的01串S满足: 1.该串是回文串 2.该串不存在两个不重叠的子串,在给定的k个串中. 即不存在a<=b<c<= ...
- 在win7/WINDOWS SERVER 2008 R2上安装 vmware POWERcli 6.5
安装.NET Framework 4.6.2下载NDP462-KB3151800-x86-x64-AllOS-ENU.exe,安装安装PowerShell 4.0(5.0依赖4.0)下载Windows ...
- Sqoop+mysql+Hive+ Ozzie数据仓库案例
mysql 数据库脚本为: /*==============================================================*/ /* DBMS name: MySQL ...
- MySQL数据库InnoDB存储引擎
MySQL数据库InnoDB存储引擎Log漫游 http://blog.163.com/zihuan_xuan/blog/static/1287942432012366293667/
- url的命名与反向解析
url命名和反向解析 1. 命名 # url(r'^press_list/$', views.press_list,name='press_list'), url(r'^pre/$', ...
- django中使用Ajax
内容: 1.Ajax原理与基本使用 2.Ajax发送get请求 3.Ajax发送post请求 4.Ajax上传文件 5.Ajax设置csrf_token 6.django序列化 参考:https:// ...