Ejemplo n.º 1
0
 @Override
 public void receiveCommand(ReactViewGroup root, int commandId, @Nullable ReadableArray args) {
   switch (commandId) {
     case CMD_HOTSPOT_UPDATE:
       {
         if (args == null || args.size() != 2) {
           throw new JSApplicationIllegalArgumentException(
               "Illegal number of arguments for 'updateHotspot' command");
         }
         if (Build.VERSION.SDK_INT >= 21) {
           root.getLocationOnScreen(sLocationBuf);
           float x = PixelUtil.toPixelFromDIP(args.getDouble(0)) - sLocationBuf[0];
           float y = PixelUtil.toPixelFromDIP(args.getDouble(1)) - sLocationBuf[1];
           root.drawableHotspotChanged(x, y);
         }
         break;
       }
     case CMD_SET_PRESSED:
       {
         if (args == null || args.size() != 1) {
           throw new JSApplicationIllegalArgumentException(
               "Illegal number of arguments for 'setPressed' command");
         }
         root.setPressed(args.getBoolean(0));
         break;
       }
   }
 }
Ejemplo n.º 2
0
 @ReactProp(name = "nativeBackgroundAndroid")
 public void setNativeBackground(ReactViewGroup view, @Nullable ReadableMap bg) {
   view.setTranslucentBackgroundDrawable(
       bg == null
           ? null
           : ReactDrawableHelper.createDrawableFromJSDescription(view.getContext(), bg));
 }
Ejemplo n.º 3
0
 @Override
 public void removeAllViews(ReactViewGroup parent) {
   boolean removeClippedSubviews = parent.getRemoveClippedSubviews();
   if (removeClippedSubviews) {
     parent.removeAllViewsWithSubviewClippingEnabled();
   } else {
     parent.removeAllViews();
   }
 }
Ejemplo n.º 4
0
 @Override
 public View getChildAt(ReactViewGroup parent, int index) {
   boolean removeClippedSubviews = parent.getRemoveClippedSubviews();
   if (removeClippedSubviews) {
     return parent.getChildAtWithSubviewClippingEnabled(index);
   } else {
     return parent.getChildAt(index);
   }
 }
Ejemplo n.º 5
0
 @Override
 public int getChildCount(ReactViewGroup parent) {
   boolean removeClippedSubviews = parent.getRemoveClippedSubviews();
   if (removeClippedSubviews) {
     return parent.getAllChildrenCount();
   } else {
     return parent.getChildCount();
   }
 }
Ejemplo n.º 6
0
 @Override
 public void addView(ReactViewGroup parent, View child, int index) {
   boolean removeClippedSubviews = parent.getRemoveClippedSubviews();
   if (removeClippedSubviews) {
     parent.addViewWithSubviewClippingEnabled(child, index);
   } else {
     parent.addView(child, index);
   }
 }
Ejemplo n.º 7
0
 @Override
 public void removeViewAt(ReactViewGroup parent, int index) {
   boolean removeClippedSubviews = parent.getRemoveClippedSubviews();
   if (removeClippedSubviews) {
     View child = getChildAt(parent, index);
     if (child.getParent() != null) {
       parent.removeView(child);
     }
     parent.removeViewWithSubviewClippingEnabled(child);
   } else {
     parent.removeViewAt(index);
   }
 }
Ejemplo n.º 8
0
 @Override
 public void onLayoutChange(
     View v,
     int left,
     int top,
     int right,
     int bottom,
     int oldLeft,
     int oldTop,
     int oldRight,
     int oldBottom) {
   if (mParent.getRemoveClippedSubviews()) {
     mParent.updateSubviewClipStatus(v);
   }
 }
Ejemplo n.º 9
0
 @ReactProp(name = ViewProps.BORDER_WIDTH, defaultFloat = CSSConstants.UNDEFINED)
 public void setBorderWidth(ReactViewGroup view, float width) {
   if (!CSSConstants.isUndefined(width)) {
     width = PixelUtil.toPixelFromDIP(width);
   }
   view.setBorderWidth(Spacing.ALL, width);
 }
Ejemplo n.º 10
0
 @ReactProp(name = "pointerEvents")
 public void setPointerEvents(ReactViewGroup view, @Nullable String pointerEventsStr) {
   if (pointerEventsStr != null) {
     PointerEvents pointerEvents =
         PointerEvents.valueOf(pointerEventsStr.toUpperCase(Locale.US).replace("-", "_"));
     view.setPointerEvents(pointerEvents);
   }
 }
Ejemplo n.º 11
0
 @ReactPropGroup(
     names = {
       "borderColor",
       "borderLeftColor",
       "borderRightColor",
       "borderTopColor",
       "borderBottomColor"
     },
     customType = "Color")
 public void setBorderColor(ReactViewGroup view, int index, Integer color) {
   view.setBorderColor(
       SPACING_TYPES[index], color == null ? CSSConstants.UNDEFINED : (float) color);
 }
Ejemplo n.º 12
0
 @ReactPropGroup(
     names = {
       ViewProps.BORDER_WIDTH,
       ViewProps.BORDER_LEFT_WIDTH,
       ViewProps.BORDER_RIGHT_WIDTH,
       ViewProps.BORDER_TOP_WIDTH,
       ViewProps.BORDER_BOTTOM_WIDTH,
     },
     defaultFloat = CSSConstants.UNDEFINED)
 public void setBorderWidth(ReactViewGroup view, int index, float width) {
   if (!CSSConstants.isUndefined(width)) {
     width = PixelUtil.toPixelFromDIP(width);
   }
   view.setBorderWidth(SPACING_TYPES[index], width);
 }
Ejemplo n.º 13
0
 @ReactProp(name = "accessible")
 public void setAccessible(ReactViewGroup view, boolean accessible) {
   view.setFocusable(accessible);
 }
Ejemplo n.º 14
0
 @ReactProp(name = ViewProps.NEEDS_OFFSCREEN_ALPHA_COMPOSITING)
 public void setNeedsOffscreenAlphaCompositing(
     ReactViewGroup view, boolean needsOffscreenAlphaCompositing) {
   view.setNeedsOffscreenAlphaCompositing(needsOffscreenAlphaCompositing);
 }
Ejemplo n.º 15
0
 @ReactProp(name = "borderRadius")
 public void setBorderRadius(ReactViewGroup view, float borderRadius) {
   view.setBorderRadius(PixelUtil.toPixelFromDIP(borderRadius));
 }
Ejemplo n.º 16
0
 @ReactProp(name = ReactClippingViewGroupHelper.PROP_REMOVE_CLIPPED_SUBVIEWS)
 public void setRemoveClippedSubviews(ReactViewGroup view, boolean removeClippedSubviews) {
   view.setRemoveClippedSubviews(removeClippedSubviews);
 }
Ejemplo n.º 17
0
 @ReactProp(name = "borderStyle")
 public void setBorderStyle(ReactViewGroup view, @Nullable String borderStyle) {
   view.setBorderStyle(borderStyle);
 }