类com.squareup.okhttp.Dispatcher源码实例Demo

下面列出了怎么用com.squareup.okhttp.Dispatcher的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: dropbox-sdk-java   文件: OkHttpRequestorTest.java
@Test
public void testCustomDispatcher() {
    OkHttpClient client = new OkHttpClient();

    // should be fine with default Dispatcher
    new OkHttpRequestor(client);

    // should also be fine with other common executors that run on separate threads
    client.setDispatcher(new Dispatcher(Executors.newSingleThreadExecutor()));
    new OkHttpRequestor(client);

    client.setDispatcher(new Dispatcher(Executors.newCachedThreadPool()));
    new OkHttpRequestor(client);

    client.setDispatcher(new Dispatcher(Executors.newFixedThreadPool(3)));
    new OkHttpRequestor(client);
}
 
源代码2 项目: OkVolley   文件: OkHttpStack.java
/**
 * set dispatcher to OkHttpClient
 * @param dispatcher {@link OkHttpClient}.setDispatcher({@link Dispatcher})
 */
public void setDispatcher(Dispatcher dispatcher) {
    if (dispatcher == null) {
        return;
    }
    this.mClient.setDispatcher(dispatcher);
}
 
源代码3 项目: dropbox-sdk-java   文件: OkHttpRequestorTest.java
@Test(expectedExceptions={ IllegalArgumentException.class })
public void testSameThreadDispatcher() {
    OkHttpClient client = new OkHttpClient();

    // should fail for same-thread executors
    client.setDispatcher(new Dispatcher(MoreExecutors.newDirectExecutorService()));
    new OkHttpRequestor(client);
}
 
源代码4 项目: OkVolley   文件: OkVolley.java
public void setDispatcher(Dispatcher dispatcher) {
    if (dispatcher == null) {
        return;
    }
    getDefaultHttpStack().setDispatcher(dispatcher);
}
 
 类所在包
 同包方法