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. ...
随机推荐
- js jquery 设置cookie
转自http://yaoqianglilan.blog.163.com/blog/static/70978316201091810435251/ 本人亲测setcookie() getcookie() ...
- bzoj4161: Shlw loves matrixI
Description 给定数列 {hn}前k项,其后每一项满足 hn = a1*h(n-1) + a2*h(n-2) + ... + ak*h(n-k) 其中 a1,a2...ak 为给定数列.请计 ...
- python2.7中出现TypeError: must be type, not classobj
class Person: def __init__(self,name,age): self._name = name self._age = age class Student(Person): ...
- 5.验证用户名是否已经被注册:AJAXC请求
首先在 web.xml 文件中添加配置信息 <!-- 配置全局的字符集 --> <context-param> <param-name>encode</par ...
- 学习笔记之Kubernetes
Kubernetes | Production-Grade Container Orchestration https://kubernetes.io/ Kubernetes is an open-s ...
- 【转载】CSS + DIV 实现整理布局
HTML CSS + DIV实现整体布局 1.技术目标: 开发符合W3C标准的Web页面 理解盒子模型 实现DIV+CSS整体布局 2.什么是W3C标准? W3C:World Wide Web Con ...
- Vmware 安装CentOS 6.5
转自:http://www.centoscn.com/image-text/install/2014/1209/4281.html 其实通过VM安装虚拟机还是蛮简单的,只不过有个别选项可能导致大家安装 ...
- tcp_tw_recycle和tcp_timestamps导致connect失败问题
把服务里面的net.ipv4.tcp_timestamps这个参数设置为0后已经可以正常telnet通了. 具体设置方法: 在/etc/sysctl.conf 里面加入 net.ipv4.tcp_t ...
- flume系统使用以及与storm的初步整合
Flume NG的简单使用可以参考介绍文档:http://blog.csdn.net/pelick/article/details/18193527,图片也来源此blog: 下载完fl ...
- xgboost的遗传算法调参
遗传算法适应度的选择: 机器学习的适应度可以是任何性能指标 —准确度,精确度,召回率,F1分数等等.根据适应度值,我们选择表现最佳的父母(“适者生存”),作为幸存的种群. 交配: 存活下来的群体中的父 ...