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

io.reactivex.subjects

Class 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.subjects

    Class 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

io.reactivex.subjects

Class 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);
原文地址:https://www.cnblogs.com/liyanli-mu640065/p/7070131.html