目前分類:Retrofit (4)

瀏覽方式: 標題列表 簡短摘要

Android網路三大框架為

1.okHttp

JBLin 發表在 痞客邦 留言(0) 人氣()

RetrofitModule<->DaggerComponent<->MainActivity

RetrofitModule

JBLin 發表在 痞客邦 留言(0) 人氣()

okHttp

implementation "com.squareup.okhttp3:logging-interceptor:4.0.0"
public static OkHttpClient getOkHttpClient() {
        HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor();
        loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
        OkHttpClient.Builder builder = new OkHttpClient.Builder()
                .connectTimeout(CONNECT_TIMEOUT, TimeUnit.SECONDS)
                .writeTimeout(WRITE_TIMEOUT, TimeUnit.SECONDS)
                .readTimeout(READ_TIMEOUT, TimeUnit.SECONDS)
                .addNetworkInterceptor(loggingInterceptor);
    return builder.build();
}

Retrofit(使用gsonConver)

JBLin 發表在 痞客邦 留言(0) 人氣()

@Path為網址中的變動參數=>http://test/api/{newsId

exampl:

JBLin 發表在 痞客邦 留言(0) 人氣()