【问题标题】:Picture lazy loading in androidandroid中的图片延迟加载
【发布时间】:2015-08-25 15:10:19
【问题描述】:

我正在开发一个拥有大量 ListView 的应用程序。在每个 ListView 项上,都有一张图片。为了从服务器加载图片,考虑到:

  • 基本身份验证。
  • SSL 认证。

我想知道最好的方法是什么。我尝试制作一个使用 Volley Library 中的 ImageRequest 的递归方法,但它似乎有点阻塞 UI 线程...... 我也尝试过 Picasso,它允许异步加载图片,这要归功于 ImageView 和请求之间的关联,无法使用基本身份验证并忽略 SSL 认证。 Here is my not solved problem

我正在寻找其他解决方案...所以如果有人有想法,将不胜感激...

提前致谢!

【问题讨论】:

    标签: android ssl lazy-loading basic-authentication ui-thread


    【解决方案1】:

    毕加索是一个上帝的解决方案。要添加自定义标题,只需使用您自己的下载器。

    OkHttpClient picassoClient = client.clone();
    picassoClient.interceptors().add(new MyInterceptor());
    // ...
    new Picasso.Builder(context).downloader(new OkHttpDownloader(picassoClient)).build();
    

    在本期阅读相关内容:https://github.com/square/picasso/issues/900

    您也可以通过 OkHttp 使用 Fresco (https://github.com/facebook/fresco):http://frescolib.org/docs/using-other-network-layers.html

    Context context;
    OkHttpClient okHttpClient; // build on your own
    ImagePipelineConfig config = OkHttpImagePipelineConfigFactory
        .newBuilder(context, okHttpClient)
        . // other setters
        . // setNetworkFetcher is already called for you
        .build();
    Fresco.initialize(context, config);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多