Search in sources :

Example 1 with DefaultTypefaceAdapter

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);
    }
}
Also used : Uri(android.net.Uri) File(java.io.File) DefaultTypefaceAdapter(com.eros.framework.extend.adapter.DefaultTypefaceAdapter) WXRequest(com.taobao.weex.common.WXRequest) WXResponse(com.taobao.weex.common.WXResponse)

Example 2 with DefaultTypefaceAdapter

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));
}
Also used : DefaultTypefaceAdapter(com.eros.framework.extend.adapter.DefaultTypefaceAdapter)

Aggregations

DefaultTypefaceAdapter (com.eros.framework.extend.adapter.DefaultTypefaceAdapter)2 Uri (android.net.Uri)1 WXRequest (com.taobao.weex.common.WXRequest)1 WXResponse (com.taobao.weex.common.WXResponse)1 File (java.io.File)1