You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by ha...@apache.org on 2018/05/21 05:41:35 UTC

[1/2] incubator-weex-site git commit: update code in doc

Repository: incubator-weex-site
Updated Branches:
  refs/heads/master fd7249d44 -> 18f5cf01a


update code in doc

update code in doc

Project: http://git-wip-us.apache.org/repos/asf/incubator-weex-site/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex-site/commit/d0b89241
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex-site/tree/d0b89241
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex-site/diff/d0b89241

Branch: refs/heads/master
Commit: d0b89241d3d901bc0a2b89d6f97ced9da49d4d2d
Parents: 1114e03
Author: listen <li...@gmail.com>
Authored: Fri May 4 11:06:47 2018 +0800
Committer: GitHub <no...@github.com>
Committed: Fri May 4 11:06:47 2018 +0800

----------------------------------------------------------------------
 source/guide/integrate-devtool-to-android.md | 75 ++++++++++++++---------
 1 file changed, 46 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex-site/blob/d0b89241/source/guide/integrate-devtool-to-android.md
----------------------------------------------------------------------
diff --git a/source/guide/integrate-devtool-to-android.md b/source/guide/integrate-devtool-to-android.md
index 7138b6e..c81e16c 100644
--- a/source/guide/integrate-devtool-to-android.md
+++ b/source/guide/integrate-devtool-to-android.md
@@ -1,4 +1,4 @@
----
+# ---
 title: Integrate Devtool to Android
 type: guide
 group: Develop
@@ -77,29 +77,42 @@ You can find detail and suitable way of initialize inspector in `Playground`.
 You can control a state of debug mode via the `WXEnvironment.sRemoteDebugMode`, but you need reset Weex runtime if you changed a state of debug mode.
 
 ```java
-private void launchInspector(boolean remoteDebug) {
-  if (WXEnvironment.isApkDebugable()) {
-    try {
-      if (mWxDebugProxy != null) {
-        mWxDebugProxy.stop();
-      }
-      HackedClass<Object> debugProxyClass = WXHack.into("com.taobao.weex.devtools.debug.DebugServerProxy");
-      mWxDebugProxy = (IWXDebugProxy) debugProxyClass.constructor(Context.class, WXBridgeManager.class)
-              .getInstance(WXEnvironment.getApplication(), WXBridgeManager.this);
-      if (mWxDebugProxy != null) {
-        mWxDebugProxy.start();
-        if (remoteDebug) {
-          mWXBridge = mWxDebugProxy.getWXBridge();
-        } else {
-          if (mWXBridge != null && !(mWXBridge instanceof WXBridge)) {
-            mWXBridge = null;
+private void initWXBridge(boolean remoteDebug) {
+    if (remoteDebug && WXEnvironment.isApkDebugable()) {
+      WXEnvironment.sDebugServerConnectable = true;
+    }
+
+    if (mWxDebugProxy != null) {
+      mWxDebugProxy.stop(false);
+    }
+    if (WXEnvironment.sDebugServerConnectable && (WXEnvironment.isApkDebugable() || WXEnvironment.sForceEnableDevTool)) {
+      if (WXEnvironment.getApplication() != null) {
+        try {
+          Class clazz = Class.forName("com.taobao.weex.devtools.debug.DebugServerProxy");
+          if (clazz != null) {
+            Constructor constructor = clazz.getConstructor(Context.class, WXBridgeManager.class);
+            if (constructor != null) {
+              mWxDebugProxy = (IWXDebugProxy) constructor.newInstance(
+                      WXEnvironment.getApplication(), WXBridgeManager.this);
+              if (mWxDebugProxy != null) {
+                mWxDebugProxy.start(new WXJsFunctions());
+              }
+            }
           }
+        } catch (Throwable e) {
+          //Ignore, It will throw Exception on Release environment
         }
+        WXServiceManager.execAllCacheJsService();
+      } else {
+        WXLogUtils.e("WXBridgeManager", "WXEnvironment.sApplication is null, skip init Inspector");
+        WXLogUtils.w("WXBridgeManager", new Throwable("WXEnvironment.sApplication is null when init Inspector"));
       }
-    } catch (HackAssertionException e) {
-      WXLogUtils.e("launchInspector HackAssertionException ", e);
     }
-  }
+    if (remoteDebug && mWxDebugProxy != null) {
+      mWXBridge = mWxDebugProxy.getWXBridge();
+    } else {
+      mWXBridge = new WXBridge();
+    }
 }
 ```
 
@@ -111,18 +124,22 @@ In this way, You can control the debug mode flexibly.
 
 ```java
 public class RefreshBroadcastReceiver extends BroadcastReceiver {
-  @Override
-  public void onReceive(Context context, Intent intent) {
-    if (IWXDebugProxy.ACTION_DEBUG_INSTANCE_REFRESH.equals(intent.getAction())) {
-      if (mUri != null) {
-        if (TextUtils.equals(mUri.getScheme(), "http") || TextUtils.equals(mUri.getScheme(), "https")) {
-          loadWXfromService(mUri.toString());
-        } else {
-          loadWXfromLocal(true);
+    @Override
+    public void onReceive(Context context, Intent intent) {
+      if (IWXDebugProxy.ACTION_INSTANCE_RELOAD.equals(intent.getAction()) ||
+              IWXDebugProxy.ACTION_DEBUG_INSTANCE_REFRESH.equals(intent.getAction())) {
+        Log.v(TAG, "connect to debug server success");
+        if (mUri != null) {
+          if (TextUtils.equals(mUri.getScheme(), "http") || TextUtils.equals(mUri.getScheme(), "https")) {
+            String weexTpl = mUri.getQueryParameter(Constants.WEEX_TPL_KEY);
+            String url = TextUtils.isEmpty(weexTpl) ? mUri.toString() : weexTpl;
+            loadWXfromService(url);
+          } else {
+            loadWXfromLocal(true);
+          }
         }
       }
     }
-  }
 }
 ```
 


[2/2] incubator-weex-site git commit: update code in doc (#148)

Posted by ha...@apache.org.
update code in doc (#148)


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex-site/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex-site/commit/18f5cf01
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex-site/tree/18f5cf01
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex-site/diff/18f5cf01

Branch: refs/heads/master
Commit: 18f5cf01ae07a858dbc1b771b709d7b52a63cb4c
Parents: fd7249d d0b8924
Author: Hanks <zh...@gmail.com>
Authored: Mon May 21 13:41:16 2018 +0800
Committer: Hanks <zh...@gmail.com>
Committed: Mon May 21 13:41:16 2018 +0800

----------------------------------------------------------------------
 source/guide/integrate-devtool-to-android.md | 75 ++++++++++++++---------
 1 file changed, 46 insertions(+), 29 deletions(-)
----------------------------------------------------------------------