YorkShen closed pull request #1824: [Android] fix WXpageActivity class on 
playground app
URL: https://github.com/apache/incubator-weex/pull/1824
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/android/playground/app/src/main/java/com/alibaba/weex/WXPageActivity.java 
b/android/playground/app/src/main/java/com/alibaba/weex/WXPageActivity.java
index 8a5408daf8..28a36e3b0c 100644
--- a/android/playground/app/src/main/java/com/alibaba/weex/WXPageActivity.java
+++ b/android/playground/app/src/main/java/com/alibaba/weex/WXPageActivity.java
@@ -70,6 +70,8 @@
 import java.net.URL;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 
 public class WXPageActivity extends WXBaseActivity implements 
IWXRenderListener, Handler.Callback, WXSDKInstance.NestedInstanceInterceptor {
@@ -270,14 +272,28 @@ public void onError(WXHttpTask task) {
    */
   private void startHotRefresh() {
     try {
-      String host = new URL(mUri.toString()).getHost();
-      String wsUrl = "ws://" + host + ":8082";
+      URL url = new URL(mUri.toString());
+      String host = url.getHost();
+      String query = url.getQuery();
+      String wsport = getUrlParam("wsport", query);
+      String wsUrl = "ws://" + host + ":" + (wsport.equals("") ? "8082" : 
wsport) ;
       mWXHandler.obtainMessage(Constants.HOT_REFRESH_CONNECT, 0, 0, 
wsUrl).sendToTarget();
     } catch (MalformedURLException e) {
       e.printStackTrace();
     }
   }
 
+  private String getUrlParam(String key, String queryString) {
+    String regex = "[?|&]?" + key + "=([^&]+)";
+    Pattern p = Pattern.compile(regex);
+    Matcher matcher = p.matcher(queryString);
+    if (matcher.find()) {
+      return matcher.group(1);
+    } else {
+      return "";
+    }
+  }
+
   private void addOnListener() {
 
   }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to