毕加索在覆盖 OkHttpDownloader.load() 后工作不正常

Picasso working incorrectly after overriding OkHttpDownloader.load()

我对图片下载有以下要求:

我尝试调整 Picasso 2.4.0 来做到这一点,下面是我的方法:

   public static Picasso getPicasso(Context context) {
    /* an OkHttpClient that ignores SSL errors */
    final OkHttpClient client = getUnsafeOkHttpClient();

    return new Picasso.Builder(context)
            .downloader(new OkHttpDownloader(client) {
                @Override
                public Response load(Uri uri, boolean localCacheOnly) throws IOException {

                    final String RESPONSE_SOURCE_ANDROID = "X-Android-Response-Source";
                    final String RESPONSE_SOURCE_OKHTTP = "OkHttp-Response-Source";

                    HttpURLConnection connection = openConnection(uri);
                    connection.setRequestProperty("Cookie", getCookieHandler().
                            getCookieStore().getCookies().get(0).toString());
                    connection.setUseCaches(true);
                    if (localCacheOnly)
                        connection.setRequestProperty("Cache-Control", "only-if-cached,max-age=" + Integer.MAX_VALUE);

                    int responseCode = connection.getResponseCode();

                    if (responseCode == 401)
                        relogin();
                    else if (responseCode >= 300) {
                        connection.disconnect();
                        throw new ResponseException(responseCode + " " + connection.getResponseMessage());
                    }
                    String responseSource = connection.getHeaderField(RESPONSE_SOURCE_OKHTTP);
                    if (responseSource == null)
                        responseSource = connection.getHeaderField(RESPONSE_SOURCE_ANDROID);

                    long contentLength = connection.getHeaderFieldInt("Content-Length", -1);
                    boolean fromCache = parseResponseSourceHeader(responseSource);

                    return new Response(connection.getInputStream(), fromCache, contentLength);
                }

            }).build();
}

我对原始来源的唯一更改是为 HttpURLConnection 添加了 Cookie。我还复制(未更改)parseResponseSourceHeader() 方法,因为它具有私有访问权限。

请注意,给定的方法 here 不起作用(响应代码 401)。

图片加载基本正常,但存在主要问题:

A/Looper﹕ Could not create wake pipe. errno=24

 A/Looper﹕ Could not create epoll instance.  errno=24

无论我是否仅使用 ImageView.

的自定义 Target,都会出现所描述的问题

我似乎通过重写 OkHttpDownloaderload() 方法破坏了一些 Picasso 机制,但我没有发现什么问题,因为我做了很少的改动。任何建议表示赞赏。

万一有人有类似的问题:那真是我的一个蹩脚错误。我正在创建多个 Picasso 实例,这完全是胡说八道。在使用助手 class 确保单例模式后 returns 单个 Picasso 实例一切正常。