private void setImage(final Bitmap bitmap) {
   if (!TiApplication.isUIThread()) {
     TiMessenger.sendBlockingMainMessage(handler.obtainMessage(SET_IMAGE), bitmap);
   } else {
     handleSetImage(bitmap);
   }
 }
Ejemplo n.º 2
0
  @Kroll.method
  public void remove(TiViewProxy child) {
    if (child == null) {
      Log.w(LCAT, "add called with null child");

      return;
    }

    if (peekView() != null) {
      if (TiApplication.isUIThread()) {
        handleRemove(child);
        return;
      }

      TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_REMOVE_CHILD), child);

    } else {
      if (children != null) {
        children.remove(child);
        if (child.parent != null && child.parent.get() == this) {
          child.parent = null;
        }
      }
    }
  }
Ejemplo n.º 3
0
 @Kroll.getProperty
 @Kroll.method
 public KrollDict getCenter() {
   return (KrollDict)
       TiMessenger.sendBlockingMainMessage(
           getMainHandler().obtainMessage(MSG_GETCENTER), getActivity());
 }
Ejemplo n.º 4
0
  @Kroll.method
  public void add(TiViewProxy child) {
    if (child == null) {
      Log.w(LCAT, "add called with null child");
      return;
    }

    if (children == null) {
      children = new ArrayList<TiViewProxy>();
    }

    if (peekView() != null) {
      if (TiApplication.isUIThread()) {
        handleAdd(child);
        return;
      }

      TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_ADD_CHILD), child);

    } else {
      children.add(child);
      child.parent = new WeakReference<TiViewProxy>(this);
    }
    // TODO zOrder
  }
Ejemplo n.º 5
0
 @Kroll.method
 public void appendItems(Object data) {
   if (TiApplication.isUIThread()) {
     handleAppendItems(data);
   } else {
     TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_APPEND_ITEMS), data);
   }
 }
Ejemplo n.º 6
0
 @Kroll.method
 @Kroll.setProperty
 public void setItems(Object data) {
   if (TiApplication.isUIThread()) {
     handleSetItems(data);
   } else {
     TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_SET_ITEMS), data);
   }
 }
Ejemplo n.º 7
0
 @Kroll.method
 @Kroll.getProperty
 public Object[] getItems() {
   if (TiApplication.isUIThread()) {
     return itemProperties.toArray();
   } else {
     return (Object[])
         TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_GET_ITEMS));
   }
 }
Ejemplo n.º 8
0
 @Kroll.method
 public KrollDict getItemAt(int index) {
   if (TiApplication.isUIThread()) {
     return handleGetItemAt(index);
   } else {
     return (KrollDict)
         TiMessenger.sendBlockingMainMessage(
             getMainHandler().obtainMessage(MSG_GET_ITEM_AT), index);
   }
 }
Ejemplo n.º 9
0
  @Kroll.method
  public KrollDict toImage() {
    if (TiApplication.isUIThread()) {
      return handleToImage();

    } else {
      return (KrollDict)
          TiMessenger.sendBlockingMainMessage(
              getMainHandler().obtainMessage(MSG_TOIMAGE), getActivity());
    }
  }
Ejemplo n.º 10
0
  public TiUIView getOrCreateView() {
    if (activity == null || view != null) {
      return view;
    }

    if (TiApplication.isUIThread()) {
      return handleGetView();
    }

    return (TiUIView)
        TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_GETVIEW), 0);
  }
Ejemplo n.º 11
0
 @Kroll.method
 public boolean canGoForward() {
   if (peekView() != null) {
     if (TiApplication.isUIThread()) {
       return getWebView().canGoForward();
     } else {
       return (Boolean)
           TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_CAN_GO_FORWARD));
     }
   }
   return false;
 }
Ejemplo n.º 12
0
 @Kroll.method
 @Kroll.getProperty
 public String getUserAgent() {
   TiUIWebView currWebView = getWebView();
   if (currWebView != null) {
     if (TiApplication.isUIThread()) {
       return currWebView.getUserAgentString();
     } else {
       return (String)
           TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_GET_USER_AGENT));
     }
   }
   return "";
 }
Ejemplo n.º 13
0
  @Kroll.method
  public void updateItemAt(int index, Object data) {
    if (!isIndexValid(index) || !(data instanceof HashMap)) {
      return;
    }

    if (TiApplication.isUIThread()) {
      handleUpdateItemAt(index, new Object[] {data});
    } else {
      KrollDict d = new KrollDict();
      d.put(TiC.EVENT_PROPERTY_INDEX, index);
      d.put(TiC.PROPERTY_DATA, new Object[] {data});
      TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_UPDATE_ITEM_AT), d);
    }
  }
Ejemplo n.º 14
0
  @Kroll.method
  public void deleteItemsAt(int index, int count) {
    if (!isIndexValid(index)) {
      return;
    }

    if (TiApplication.isUIThread()) {
      handleDeleteItemsAt(index, count);
    } else {
      KrollDict d = new KrollDict();
      d.put(TiC.EVENT_PROPERTY_INDEX, index);
      d.put(TiC.PROPERTY_COUNT, count);
      TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_DELETE_ITEMS_AT), d);
    }
  }
Ejemplo n.º 15
0
  @Kroll.method
  public void insertItemsAt(int index, Object data) {
    if (!isIndexValid(index)) {
      return;
    }

    if (TiApplication.isUIThread()) {
      handleInsertItemsAt(index, data);
    } else {
      KrollDict d = new KrollDict();
      d.put(TiC.PROPERTY_DATA, data);
      d.put(TiC.EVENT_PROPERTY_INDEX, index);
      TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_INSERT_ITEMS_AT), d);
    }
  }
Ejemplo n.º 16
0
  @Kroll.method
  public TiBlob getFilteredScreenshot(HashMap options) {
    if (options != null) {
      if (options.containsKey("callback")) {
        KrollFunction callback = (KrollFunction) options.get("callback");
        if (callback != null) {
          (new FilterScreenShotTask()).execute(options);
          return null;
        }
      }
    }

    //        View view = TiApplication.getAppCurrentActivity().getWindow()
    //                .getDecorView();
    View view =
        TiApplication.getAppCurrentActivity()
            .getWindow()
            .getDecorView()
            .findViewById(android.R.id.content);
    if (view == null) {
      return null;
    }

    Bitmap bitmap = null;
    try {
      if (TiApplication.isUIThread()) {
        bitmap = TiUIHelper.viewToBitmap(null, view);
      } else {
        bitmap =
            (Bitmap)
                TiMessenger.sendBlockingMainMessage(
                    getMainHandler().obtainMessage(MSG_GETVIEWIMAGE), view);
      }
      //            Rect statusBar = new Rect();
      //            view.getWindowVisibleDisplayFrame(statusBar);
      //            bitmap = Bitmap.createBitmap(bitmap, 0, statusBar.top,
      //                    bitmap.getWidth(), bitmap.getHeight() - statusBar.top,
      //                    null, true);
    } catch (Exception e) {
      bitmap = null;
    }
    return getFilteredImage(bitmap, options);
  }