簡體   English   中英

圖片在Android中延遲加載

[英]Picture lazy loading in android

我正在開發一個有很多ListViews的應用程序。 在每個ListView項上都有一張圖片。 為了從服務器加載圖片,請考慮以下因素:

  • 基本身份驗證。
  • SSL認證。

我想知道什么是最好的方法。 我嘗試制作一種使用Volley Library中的ImageRequest的遞歸方法,但似乎有點阻塞了UI線程...我嘗試了Picasso,由於ImageView之間的關聯,它也允許異步加載圖片並且該請求不能通過基本身份驗證和忽略SSL認證來使其生效。 這是我未解決的問題

我正在尋找其他解決方案...所以,如果有人有想法,將不勝感激...

提前致謝 !

畢加索是上帝的解決方案。 要添加自定義標頭,只需使用自己的下載器即可。

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);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM