예제 #1
0
 public void oscyloskop(final int e) {
   webview.post(
       new Runnable() {
         @Override
         public void run() {
           webview.loadUrl("javascript:sendToDraw('" + e + "');");
         }
       });
 }
예제 #2
0
 public void onError(final Throwable t) {
   appView.post(
       new Runnable() {
         @Override
         public void run() {
           appView.loadUrl(buildJavaScriptData(EVENT_ON_ERROR, t.getMessage()));
         }
       });
 }
예제 #3
0
 public void onClose() {
   appView.post(
       new Runnable() {
         @Override
         public void run() {
           appView.loadUrl(buildJavaScriptData(EVENT_ON_CLOSE, BLANK_MESSAGE));
         }
       });
 }
 @Override
 public void onOpen(ServerHandshake handshakedata) {
   appView.post(
       new Runnable() {
         @Override
         public void run() {
           appView.loadUrl(buildJavaScriptData(EVENT_ON_OPEN, BLANK_MESSAGE));
         }
       });
 }
 @Override
 public void onClose(int code, String reason, boolean remote) {
   appView.post(
       new Runnable() {
         @Override
         public void run() {
           appView.loadUrl(buildJavaScriptData(EVENT_ON_CLOSE, BLANK_MESSAGE));
         }
       });
 }
예제 #6
0
 public void oscyloskop_interval() {
   webview.post(
       new Runnable() {
         @Override
         public void run() {
           String url = "javascript:sendToDraw();void(0);";
           webview.loadUrl(url);
         }
       });
 }
예제 #7
0
 // when a message is received
 public void onMessage(final String msg) {
   // post a new thread to View
   appView.post(
       new Runnable() {
         @Override
         public void run() {
           appView.loadUrl(buildJavaScriptData(EVENT_ON_MESSAGE, msg));
         }
       });
 }
 @Override
 public void onMessage(final String message) {
   appView.post(
       new Runnable() {
         @Override
         public void run() {
           String sanitizedMessage = message.replace("\n", "\\n").replace("\0", "\\0");
           appView.loadUrl(buildJavaScriptData(EVENT_ON_MESSAGE, sanitizedMessage));
         }
       });
 }
 public void onClose() {
   appView.post(
       new Runnable() {
         public void run() {
           appView.loadUrl(buildJavaScriptData(EVENT_ON_CLOSE, BLANK_MESSAGE));
           if (keyboardIsShowing) {
             handler.sendEmptyMessage(3);
           }
         }
       });
 }
 public void onOpen() {
   Log.v("websocket", "Connected!");
   appView.post(
       new Runnable() {
         public void run() {
           appView.loadUrl(buildJavaScriptData(EVENT_ON_OPEN, BLANK_MESSAGE));
           if (keyboardIsShowing) {
             handler.sendEmptyMessage(3);
           }
         }
       });
 }
예제 #11
0
  @Override
  public void initLogic() {
    actItem = (ActivityItem) getActivity().getIntent().getSerializableExtra("item");
    wvUrl.post(
        new Runnable() {

          @Override
          public void run() {
            wvUrl.loadUrl(actItem.url);
          }
        });
  }
 public void onError(Throwable t) {
   final String msg = t.getMessage();
   Log.v("websocket", "Error: " + msg);
   t.printStackTrace();
   appView.post(
       new Runnable() {
         public void run() {
           appView.loadUrl(buildJavaScriptData(EVENT_ON_ERROR, msg));
           if (keyboardIsShowing) {
             handler.sendEmptyMessage(3);
           }
         }
       });
 }
예제 #13
0
 private void dispatchMessage(final String jsonStr) {
   webView.post(
       new Runnable() {
         @Override
         public void run() {
           webView.loadUrl(
               "javascript: "
                   + JS_BRIDGE
                   + "."
                   + JS_BRIDGE_SEND_NATIVE_QUEUE
                   + "('"
                   + jsonStr
                   + "');");
         }
       });
 }
 /**
  * Called when an entire text frame has been recieved.
  *
  * @param msg Message from websocket server
  */
 public void onMessage(String msg) {
   final String data = msg;
   Log.v("websocket", "Received a message: " + msg);
   appView.post(
       new Runnable() {
         public void run() {
           if (keyboardIsShowing) {
             Message message = new Message();
             message.obj = buildJavaScriptData(EVENT_ON_MESSAGE, data);
             message.what = 3;
             handler.sendMessage(message);
           } else {
             appView.loadUrl(buildJavaScriptData(EVENT_ON_MESSAGE, data));
           }
         }
       });
 }
예제 #15
0
 public void runJs(final String method, final String... args) {
   webview.post(
       new Runnable() {
         @Override
         public void run() {
           String callargs = "";
           for (int i = 0; i < args.length; ++i) {
             callargs += "'" + addSlashes(args[i]) + "'";
             if (i < args.length - 1) {
               callargs += ",";
             }
           }
           String url = "javascript:" + method + "(" + callargs + ");void(0);";
           Log.d("+URL", url);
           webview.loadUrl(url);
         }
       });
 }
예제 #16
0
 private static JSONObject callAPICallbackComplete(
     final WebView wv, JSONObject inJsonObj, final JSONObject outJsonObj) {
   final String callbackID = JSBridge.getString(inJsonObj, "callbackID");
   if (callbackID != null) {
     String str = JSBridge.getString(inJsonObj, "removeAfterExecute");
     if (str == null) str = "true";
     final String removeAfterExecute = str;
     wv.post(
         new Runnable() {
           @Override
           public void run() {
             wv.loadUrl(
                 "javascript: JSBridge._invokeJSCallback('"
                     + callbackID
                     + "',"
                     + removeAfterExecute
                     + ",'"
                     + outJsonObj.toString()
                     + "');");
           }
         });
   }
   return outJsonObj;
 }