コード例 #1
0
 public final void setMainPage(String pageId, String animation) {
   Options options = Options.create();
   options.setCloseMenu(true);
   JavaScriptObject jsAnimation = null;
   String msg = "";
   if (animation != null) {
     if (OnsenUi.ANIMATION_NATIVE_PUSH.equals(animation)) {
       jsAnimation = getPushAnimationImpl();
       msg = " WITH NATIVE PUSH ANIMATION";
     } else if (OnsenUi.ANIMATION_NATIVE_POP.equals(animation)) {
       jsAnimation = getPopAnimationImpl();
       msg = " WITH NATIVE POP ANIMATION";
     }
   }
   PhgUtils.log("PUSHING PAGE " + pageId + " " + msg + " " + JSONUtils.stringify(options));
   setMainPageImpl(pageId, options, jsAnimation);
 }
コード例 #2
0
  /**
   * PER CONTROLLARE LA CORRETTEZZA DEL B64 UTILIZZARE:
   *
   * <p>http://www.motobit.com/util/base64-decoder-encoder.asp
   */
  public static void readFromLocalhost(String uri, final Delegate<String> imageDelegate) {
    RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, uri);
    rb.setHeader("Content-Type", "application/base64");
    try {
      rb.sendRequest(
          null,
          new RequestCallback() {
            public void onResponseReceived(Request request, Response response) {
              if (200 == response.getStatusCode()) {
                //          String imgB64 =
                // Base64UtilsClient.toBase64(response.getText().getBytes());
                //          String imgB64 = PhgUtils.btoa(response.getText());
                String imgB64 = response.getText();

                /*
                imgB64 = GwtUtils.replaceEx(imgB64, "_", "/");
                imgB64 = GwtUtils.replaceEx(imgB64, "$", "+");
                */

                PhgUtils.log("RECEIVED " + imgB64);
                imageDelegate.execute(imgB64);
              } else {
                PhgUtils.log(
                    "status code error "
                        + response.getStatusCode()
                        + " - "
                        + response.getStatusText());
              }
            }

            @Override
            public void onError(Request request, Throwable exception) {
              PhgUtils.log("response error");
            }
          });
    } catch (RequestException ex) {
      PhgUtils.log("request error");
    }
  }
コード例 #3
0
 private void iterateDataFiles(
     final int it, final List<Timbro> results, final Delegate<List<Timbro>> endDelegate) {
   if (it < NUMBER_OF_ITEMS) {
     if (OsDetectionUtils.isDesktop()) {
       readFromLocalhost(
           "http://127.0.0.1:8888/.image?name=timbro" + it + ".jpg",
           new Delegate<String>() {
             public void execute(String imgData) {
               results.add(createTimbro(it, imgData));
               iterateDataFiles(it + 1, results, endDelegate);
             }
           });
     } else {
       if (FileSystemPlugin.isInstalled()) {
         String fileName = "timbro" + it + ".jpg";
         FileSystemPlugin.readApplicationFileAsEncodedData(
             dataPath + "/" + fileName,
             new Delegate<String>() {
               public void execute(String imgData) {
                 if (imgData == null) {
                   PhgUtils.log("RESULT NULL");
                 } else {
                   PhgUtils.log("READ: " + imgData.substring(0, 200));
                 }
                 results.add(createTimbro(it, imgData));
                 iterateDataFiles(it + 1, results, endDelegate);
               }
             });
       } else {
         PhgUtils.log("FILE SYSTEM PLUGIN NOT INSTALLED!");
       }
     }
   } else {
     endDelegate.execute(results);
   }
 }
コード例 #4
0
 public final void setMenuPage(String pageId) {
   Options options = Options.create();
   PhgUtils.log("MENU PAGE " + pageId);
   setMenuPageImpl(pageId, options);
 }
コード例 #5
0
 public DOMImplWebkitPatched() {
   super();
   PhgUtils.log("Using DOMImplWebkitPatched");
 }