use of mockwebserver3.Dispatcher in project dropbox-sdk-java by dropbox.
the class OkHttp3RequestorTest method testCustomDispatcher.
@Test
public void testCustomDispatcher() {
OkHttpClient.Builder client = new OkHttpClient.Builder();
// should be fine with default Dispatcher
new OkHttp3Requestor(client.build());
// should also be fine with other common executors that run on separate threads
client.dispatcher(new Dispatcher(Executors.newSingleThreadExecutor()));
new OkHttp3Requestor(client.build());
client.dispatcher(new Dispatcher(Executors.newCachedThreadPool()));
new OkHttp3Requestor(client.build());
client.dispatcher(new Dispatcher(Executors.newFixedThreadPool(3)));
new OkHttp3Requestor(client.build());
}
use of mockwebserver3.Dispatcher in project MVP by yuchengren.
the class OkHttpUtil method getQueuedAndRunningCallList.
public List<Call> getQueuedAndRunningCallList() {
Dispatcher dispatcher = mOkHttpClient.dispatcher();
List<Call> callList = new ArrayList<>();
callList.addAll(dispatcher.queuedCalls());
callList.addAll(dispatcher.runningCalls());
return callList;
}
use of mockwebserver3.Dispatcher in project MVP by yuchengren.
the class OkHttpUtil method getQueuedAndRunningCallList.
public List<Call> getQueuedAndRunningCallList() {
Dispatcher dispatcher = mOkHttpClient.dispatcher();
List<Call> callList = new ArrayList<>();
callList.addAll(dispatcher.queuedCalls());
callList.addAll(dispatcher.runningCalls());
return callList;
}
use of mockwebserver3.Dispatcher in project CubedPay-Java by MelonDevelopment.
the class CubedPayAPI method shutdown.
default void shutdown() throws InterruptedException {
Dispatcher dispatcher = DispatcherMap.dispatcherMap.remove(this);
dispatcher.cancelAll();
dispatcher.executorService().shutdown();
dispatcher.executorService().awaitTermination(10, TimeUnit.SECONDS);
for (ExecutorService executor : EventMap.eventMap.values()) {
executor.shutdown();
executor.awaitTermination(10, TimeUnit.SECONDS);
}
}
use of mockwebserver3.Dispatcher in project CubedPay-Java by MelonDevelopment.
the class CubedPayAPI method create.
static CubedPayAPI create(String appID, String accessToken, String apiUrl) {
Dispatcher dispatcher = new Dispatcher();
CubedPayAPI api = new Retrofit.Builder().baseUrl(apiUrl).addConverterFactory(new Converter.Factory() {
@Override
public Converter<ResponseBody, ?> responseBodyConverter(Type type, Annotation[] annotations, Retrofit retrofit) {
return super.responseBodyConverter(type, annotations, retrofit);
}
}).addConverterFactory(new APIEnvelopeTransformerConverterFactory(GsonConverterFactory.create())).addCallAdapterFactory(Java8CallAdapterFactory.create()).client(new OkHttpClient.Builder().addInterceptor(chain -> chain.proceed(chain.request().newBuilder().addHeader("app-id", appID).url(chain.request().url().newBuilder().addQueryParameter("access_token", accessToken).build()).build())).dispatcher(dispatcher).build()).build().create(CubedPayAPI.class);
DispatcherMap.dispatcherMap.put(api, dispatcher);
return api;
}
Aggregations