W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
WEEX和圖片庫完全解耦,WEEX的圖片加載,都是通過調(diào)用公共接口,由實現(xiàn)類決定調(diào)用哪個圖片庫
IWXImgLoaderAdapter
?: 根據(jù)url,load圖片給某個viewIDrawableLoader
?(可選): 根據(jù)url,load圖片給某個drawable.public interface IWXImgLoaderAdapter {
void setImage(String url, ImageView view, WXImageQuality quality, WXImageStrategy strategy);
}
WXImageQuality
? 圖片質(zhì)量的設(shè)置參數(shù),有 ?LOW
?, ?NORMAL
?, ?HIGH
?, ?ORIGINAL
? 幾種質(zhì)量,默認(rèn)為?LOW
?.WXImageStrategy
? 是一個擴(kuò)展類參數(shù),配置圖像是否可以剪切?isClipping
?、銳化?isSharpen
?以及配置占位符?placeHolder
? interface DrawableTarget {
}
interface StaticTarget extends DrawableTarget{
void setDrawable(@Nullable Drawable drawable, boolean resetBounds);
}
interface AnimatedTarget extends DrawableTarget{
void setAnimatedDrawable(@Nullable Drawable drawable);
}
void setDrawable(String url, DrawableTarget drawableTarget, DrawableStrategy drawableStrategy);
}
同?ImageAdapter
?,WEEX和網(wǎng)絡(luò)庫也是解耦的,通過接口形式調(diào)用,由實現(xiàn)類決定調(diào)用哪個網(wǎng)絡(luò)庫。
public interface IWXHttpAdapter {
void sendRequest(WXRequest request, OnHttpListener listener);
}
paramMap
?(Map<String, String>): http自定義請求參數(shù),比如(?a=1&b=2);url
?(String): http請求的目標(biāo)urlmethod
?(String): http請求方法 "post","get"body
?(String): http請求bodytimeoutMs
?(int): 請求超時時間,默認(rèn)是3sinstanceId
?(String): (頁面)idinterface OnHttpListener {
/**
* 開始請求
*/
void onHttpStart();
/**
* 收到http header內(nèi)容
*/
void onHeadersReceived(int statusCode,Map<String,List<String>> headers);
/**
*
* @param 上傳進(jìn)度
*/
void onHttpUploadProgress(int uploadProgress);
/**
*
* @param loadedLength 接收到的數(shù)據(jù)長度
*/
void onHttpResponseProgress(int loadedLength);
/**
* 請求結(jié)束
* @param response 返回的response
*/
void onHttpFinish(WXResponse response);
}
打點相關(guān),如果關(guān)注weex的打點,需要實現(xiàn)這個adapter
public interface IWXUserTrackAdapter {
void commit(Context context, String eventId, String type, WXPerformance perf, Map<String, Serializable> params);
}
?WXNavigatorModule
?的實現(xiàn)依賴這個接口,用來操作navigation.
使用方式:
WXSDKEngine.setActivityNavBarSetter(new IActivityNavBarSetter(){});
WXStorageModule實現(xiàn)依賴這個接口,用來實現(xiàn)數(shù)據(jù)的存、取默認(rèn)使用DefaultWXStorage實現(xiàn)
WEEX的異常上報接口,包括
public interface IWXJSExceptionAdapter {
void onJSException(WXJSExceptionInfo exception);
}
使用方式:
WXSDKEngine.setJSExcetptionAdapter(new TestExceptionAdapter());
若要在APP中使用混淆,請在相應(yīng)的配置文件中添加如下規(guī)則:
-keep class com.taobao.weex.WXDebugTool{*;}
-keep class com.taobao.weex.devtools.common.LogUtil{*;}
-keepclassmembers class ** {
@com.taobao.weex.ui.component.WXComponentProp public *;
}
-keep class com.taobao.weex.bridge.**{*;}
-keep class com.taobao.weex.dom.**{*;}
-keep class com.taobao.weex.adapter.**{*;}
-keep class com.taobao.weex.common.**{*;}
-keep class * implements com.taobao.weex.IWXObject{*;}
-keep class com.taobao.weex.ui.**{*;}
-keep class com.taobao.weex.ui.component.**{*;}
-keep class com.taobao.weex.utils.**{
public <fields>;
public <methods>;
}
-keep class com.taobao.weex.view.**{*;}
-keep class com.taobao.weex.module.**{*;}
-keep public class * extends com.taobao.weex.common.WXModule{*;}
-keep public class * extends com.taobao.weex.ui.component.WXComponent{*;}
-keep class * implements com.taobao.weex.ui.IExternalComponentGetter{*;}
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: