use of com.eros.framework.extend.adapter.DefaultTypefaceAdapter in project WeexErosFramework by bmfe.
the class TypeFaceHandler method load.
public static void load(String url, IWXHttpAdapter.OnHttpListener listener) {
Uri parse = Uri.parse(url);
listener.onHttpStart();
DefaultTypefaceAdapter typefaceAdapter = BMWXApplication.getWXApplication().getTypefaceAdapter();
if (typefaceAdapter == null) {
Log.e(TAG, "未找到支持bmLocal的adapter");
return;
}
if ("bmlocal".equalsIgnoreCase(parse.getScheme())) {
// bmlocal
if (typefaceAdapter.isInterceptor()) {
// load local
File iconDir = typefaceAdapter.getTypefaceDir();
if (!iconDir.exists())
return;
File localIcon = new File(iconDir, parse.getPath());
if (!localIcon.exists()) {
// local icon not exists
WXResponse response = new WXResponse();
response.statusCode = "404";
if (listener != null) {
listener.onHttpFinish(response);
}
return;
}
loadLocalIncon(localIcon, listener);
} else {
// fetch on Js server
String iconDownloadUrl = typefaceAdapter.getJsServer() + "/dist";
if (TextUtils.isEmpty(iconDownloadUrl))
return;
String fetchUrl = iconDownloadUrl + "/" + parse.getHost() + parse.getPath();
fetchIcon(fetchUrl, listener);
}
} else if ("http".equalsIgnoreCase(parse.getScheme()) || "https".equalsIgnoreCase(parse.getScheme())) {
// http
WXRequest wxRequest = new WXRequest();
wxRequest.url = url;
wxRequest.method = "GET";
requestRemoteIcon(wxRequest, listener);
}
}
use of com.eros.framework.extend.adapter.DefaultTypefaceAdapter in project WeexErosFramework by bmfe.
the class BMWXEngine method initPlatformConfig.
private static void initPlatformConfig(Application context) {
BMWXEnvironment.mPlatformConfig = CustomerEnvOptionManager.initPlatformConfig(context);
BMWXEnvironment.mApplicationContext = context;
BMWXApplication.getWXApplication().setTypefaceAdapter(new DefaultTypefaceAdapter(context));
}
Aggregations