歌尔基办 v2.7.0版本的 MD5 值为:921fd7c85ec097e8cab7f049269b36e4
以下内容为反编译后的 ApiTranslateAudioFactory.java 源代码,内容仅作参考
package com.bjz.comm.net.factory;
import com.bjz.comm.net.BuildVars;
import com.bjz.comm.net.api.ApiTranslate;
import com.bjz.comm.net.base.MyGsonConverterFactory;
import com.bjz.comm.net.interceptor.HeaderInterceptor;
import java.util.concurrent.TimeUnit;
import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
public class ApiTranslateAudioFactory {
private static ApiTranslateAudioFactory mInstance;
private ApiTranslate mApiTranslate;
private final Retrofit mRetrofit;
public static ApiTranslateAudioFactory getInstance() {
if (mInstance == null) {
synchronized (ApiTranslateAudioFactory.class) {
if (mInstance == null) {
mInstance = new ApiTranslateAudioFactory();
}
}
}
return mInstance;
}
private ApiTranslateAudioFactory() {
OkHttpClient.Builder newBuilder = new OkHttpClient().newBuilder();
newBuilder.connectTimeout(10L, TimeUnit.SECONDS);
newBuilder.writeTimeout(20L, TimeUnit.SECONDS);
newBuilder.readTimeout(10L, TimeUnit.SECONDS);
newBuilder.addInterceptor(new HeaderInterceptor());
if (BuildVars.DEBUG_VERSION) {
HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor();
httpLoggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
newBuilder.addInterceptor(httpLoggingInterceptor);
}
this.mRetrofit = new Retrofit.Builder().baseUrl("https://vop.baidu.com/").client(newBuilder.build()).addConverterFactory(MyGsonConverterFactory.create()).addCallAdapterFactory(RxJava2CallAdapterFactory.create()).build();
}
public ApiTranslate getApiTranslate() {
if (this.mApiTranslate == null) {
this.mApiTranslate = (ApiTranslate) this.mRetrofit.create(ApiTranslate.class);
}
return this.mApiTranslate;
}
}