我无法设置超时以进行改造。以下代码不适用于毕加索。我得到一个空白的屏幕,数据和图像没有加载。如何用gradle修复它:
compile 'com.squareup.picasso:picasso:2.3.2'
compile 'com.squareup.retrofit:retrofit:1.9.0'
代码:
final OkHttpClient okHttpClient = new OkHttpClient();
okHttpClient.setReadTimeout(60, TimeUnit.SECONDS);
okHttpClient.setConnectTimeout(60, TimeUnit.SECONDS);
RestAdapter restAdapter = new RestAdapter.Builder()
.setClient(new OkClient(okHttpClient))
.setEndpoint(URL).build();
myapi myapi_rest = restAdapter.create(myapi.class);
myapi_rest.my_call(
sno,
new Callback<Response>() {
@Override
public void success(Response result, Response response) {
}
@Override
public void failure(RetrofitError error) {
// Log.i("Failure", "Error"+error.getMessage());
}
});
摇篮:
compile 'com.squareup.picasso:picasso:2.3.2'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile "com.squareup.okhttp:okhttp:1.6.0"
compile "com.squareup.okhttp:okhttp-urlconnection:1.6.0"
答案 0 :(得分:1)
要将OkHttpClient与Picasso一起使用,您需要使用以下代码。
// Create the downloader for Picasso to use
OkHttpDownloader downloader = new OkHttpDownloader(okHttpClient);
Picasso picasso = new Picasso.Builder(context).downloader(downloader).build();
指定您为其指定超时的OkHttpClient。