在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 教程/ Android/ 自定義網絡加載
進度條
在JAVA代碼中使用Drawees
Drawee的各種效果配置
緩存
一些陷阱
關于在Android Studio中編譯
多圖請求及圖片復用
自定義網絡加載
支持的URIs
可關閉的引用
監(jiān)聽下載事件
修改圖片
引入Fresco
縮放
圓角和圓圈
配置Image Pipeline
縮放和旋轉圖片
(圖片請求)Image Requests
自定義View
使用ControllerBuilder
在XML中使用Drawees
開始使用 Fresco
關鍵概念
Image Pipeline介紹
漸進式JPEG圖
數據源和數據訂閱者
直接使用Image Pipeline
動畫圖(gif)
使用其他的Image Loader

自定義網絡加載

本教程內容來源于:http://fresco-cn.org
采用 知識共享 署名 4.0 國際 許可協議 進行許可

Image pipeline 默認使用HttpURLConnection。應用可以根據自己需求使用不同的網絡庫。

OkHttp

OkHttp 是一個流行的開源網絡請求庫。Image pipeline有一個使用OkHttp替換掉了Android默認的網絡請求的補充。

如果需要使用OkHttp, 不要使用這個下載頁面的gradle依賴配置,應該使用下面的依賴配置

dependencies {
  // your project's other dependencies
  compile: "com.facebook.fresco:drawee:0.1.0+"
  compile: "com.facebook.fresco:imagepipeline-okhttp:0.1.0+"
}

配置Image pipeline這時也有一些不同,不再使用ImagePipelineConfig.newBuilder,而是使用OkHttpImagePipelineConfigFactory:

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

使用自定的網絡層

For complete control on how the networking layer should behave, you can provide one for your app. You must subclass 為了完全控制網絡層的行為,你可以自定義網絡層。繼承NetworkFetchProducer, 這個類包含了網絡通信。

你也可以選擇性地繼承NfpRequestState, 這個類是請求時的數據結構描述。

默認的 HttpURLConnection 可以作為一個參考. 源碼在這 its source code.

配置Image pipeline時,把producer傳遞給Image pipeline。

ImagePipelineConfig config = ImagePipelineConfig.newBuilder()
  .setNetworkFetchProducer(myNetworkFetchProducer);
  . // other setters
  .build();
Fresco.initialize(context, config);