Search in sources :

Example 31 with WXSDKInstance

use of com.taobao.weex.WXSDKInstance in project weex-example by KalicyZhou.

the class WXPageActivity method loadWXfromService.

private void loadWXfromService(final String url) {
    mProgressBar.setVisibility(View.VISIBLE);
    if (mInstance != null) {
        mInstance.destroy();
    }
    RenderContainer renderContainer = new RenderContainer(this);
    mContainer.addView(renderContainer);
    mInstance = new WXSDKInstance(this);
    mInstance.setRenderContainer(renderContainer);
    mInstance.registerRenderListener(this);
    mInstance.setNestedInstanceInterceptor(this);
    mInstance.setBundleUrl(url);
    mInstance.setTrackComponent(true);
    WXHttpTask httpTask = new WXHttpTask();
    httpTask.url = url;
    httpTask.requestListener = new WXRequestListener() {

        @Override
        public void onSuccess(WXHttpTask task) {
            Log.i(TAG, "into--[http:onSuccess] url:" + url);
            try {
                mConfigMap.put("bundleUrl", url);
                mInstance.render(TAG, new String(task.response.data, "utf-8"), mConfigMap, null, ScreenUtil.getDisplayWidth(WXPageActivity.this), ScreenUtil.getDisplayHeight(WXPageActivity.this), WXRenderStrategy.APPEND_ASYNC);
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
        }

        @Override
        public void onError(WXHttpTask task) {
            Log.i(TAG, "into--[http:onError]");
            mProgressBar.setVisibility(View.GONE);
            Toast.makeText(getApplicationContext(), "network error!", Toast.LENGTH_SHORT).show();
        }
    };
    WXHttpManager.getInstance().sendRequest(httpTask);
}
Also used : WXSDKInstance(com.taobao.weex.WXSDKInstance) RenderContainer(com.taobao.weex.RenderContainer) WXHttpTask(com.alibaba.weex.https.WXHttpTask) UnsupportedEncodingException(java.io.UnsupportedEncodingException) WXRequestListener(com.alibaba.weex.https.WXRequestListener)

Example 32 with WXSDKInstance

use of com.taobao.weex.WXSDKInstance in project WeexErosFramework by bmfe.

the class AbstractWeexActivity method createWXInstance.

protected void createWXInstance() {
    if (mWXInstance != null) {
        destroyWXInstance();
    }
    RenderContainer renderContainer = new RenderContainer(this);
    mContainer.addView(renderContainer);
    mWXInstance = new WXSDKInstance(this);
    mWXInstance.registerRenderListener(this);
    mWXInstance.setRenderContainer(renderContainer);
}
Also used : WXSDKInstance(com.taobao.weex.WXSDKInstance) RenderContainer(com.taobao.weex.RenderContainer)

Example 33 with WXSDKInstance

use of com.taobao.weex.WXSDKInstance in project WeexErosFramework by bmfe.

the class PushManager method handlePush.

public void handlePush(Context context, String data) {
    // 判断当前应用是在前台还是后台
    boolean isForeground = BaseCommonUtil.isAPPRunningForeground(context);
    ParseManager parseManager = ManagerFactory.getManagerService(ParseManager.class);
    NotificationBean bean = parseManager.parseObject(data, NotificationBean.class);
    if (isForeground) {
        // 在前台 通知js
        Activity activity = RouterTracker.peekActivity();
        if (activity instanceof AbstractWeexActivity) {
            WXSDKInstance instance = ((AbstractWeexActivity) activity).getWXSDkInstance();
            GlobalEventManager.pushMessage(instance, getParams(bean, false));
        }
    } else {
        // 在后台  显示通知
        showNotification(context, bean);
    }
}
Also used : NotificationBean(com.benmu.framework.model.NotificationBean) WXSDKInstance(com.taobao.weex.WXSDKInstance) ResultActivity(com.benmu.framework.activity.ResultActivity) AbstractWeexActivity(com.benmu.framework.activity.AbstractWeexActivity) Activity(android.app.Activity) AbstractWeexActivity(com.benmu.framework.activity.AbstractWeexActivity)

Aggregations

WXSDKInstance (com.taobao.weex.WXSDKInstance)33 IWXRenderTask (com.taobao.weex.ui.IWXRenderTask)10 Activity (android.app.Activity)3 RenderContainer (com.taobao.weex.RenderContainer)3 WXDomObject (com.taobao.weex.dom.WXDomObject)3 Spacing (com.taobao.weex.dom.flex.Spacing)3 WXComponent (com.taobao.weex.ui.component.WXComponent)3 Before (org.junit.Before)3 Rect (android.graphics.Rect)2 NotificationBean (com.benmu.framework.model.NotificationBean)2 Intent (android.content.Intent)1 Uri (android.net.Uri)1 ArrayMap (android.support.v4.util.ArrayMap)1 ViewGroup (android.view.ViewGroup)1 JSONObject (com.alibaba.fastjson.JSONObject)1 WXHttpTask (com.alibaba.weex.https.WXHttpTask)1 WXRequestListener (com.alibaba.weex.https.WXRequestListener)1 AbstractWeexActivity (com.benmu.framework.activity.AbstractWeexActivity)1 ResultActivity (com.benmu.framework.activity.ResultActivity)1 WXSDKInstanceTest (com.taobao.weex.WXSDKInstanceTest)1