注: 本文只適用於自我複習,初學者請移步 連接html
經常使用模板java
rxjava2+retrofit2api
public static void main(String[] args) { String BASE_URL = " http://www.izaodao.com/Api/"; okhttp3.OkHttpClient.Builder builder = new OkHttpClient.Builder(); builder.connectTimeout(5, TimeUnit.SECONDS); Retrofit retrofit = new Retrofit.Builder() .client(builder.build()) .addConverterFactory(GsonConverterFactory.create()) .baseUrl(BASE_URL) .addCallAdapterFactory(RxJava2CallAdapterFactory.create()) .build(); MyApiEndpointInterface apiService = retrofit.create(MyApiEndpointInterface.class); Observable<RetrofitEntity> observable = apiService.getAllVedioBy(true); observable.subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new DisposableObserver<RetrofitEntity>() { @Override public void onComplete() { } @Override public void onError(Throwable e) { } @Override public void onNext(RetrofitEntity retrofitEntity) { System.out.println(retrofitEntity.toString()); } }); }
mvp+rxjava: 連接ide
Retrofit2 源碼分析:連接post
Okhttp3 源碼分析:連接ui
rxjava操做符大全:連接spa
empty:建立一個不發射任何數據可是正常終止的Observable.net
never:建立一個不發射數據也不終止的Observable3d
error:建立一個不發射數據以一個錯誤終止的Observable
一塊兒造一個rxjava:連接