@Override
 public void processProperties(KrollDict d) {
   // TODO Auto-generated method stub
   super.processProperties(d);
   if (d.containsKey(TiC.PROPERTY_TITLE)) {
     actionBar.setTitle(d.getString(TiC.PROPERTY_TITLE));
   }
   if (d.containsKey(TiC.PROPERTY_SWIPEABLE)) {
     swipeable = d.getBoolean(TiC.PROPERTY_SWIPEABLE);
   }
 }
示例#2
0
  private void handleBackgroundImage(KrollDict d) {
    String bg = d.getString(TiC.PROPERTY_BACKGROUND_IMAGE);
    String bgSelected = d.getString(TiC.PROPERTY_BACKGROUND_SELECTED_IMAGE);
    String bgFocused = d.getString(TiC.PROPERTY_BACKGROUND_FOCUSED_IMAGE);
    String bgDisabled = d.getString(TiC.PROPERTY_BACKGROUND_DISABLED_IMAGE);

    String bgColor = d.getString(TiC.PROPERTY_BACKGROUND_COLOR);
    String bgSelectedColor = d.getString(TiC.PROPERTY_BACKGROUND_SELECTED_COLOR);
    String bgFocusedColor = d.getString(TiC.PROPERTY_BACKGROUND_FOCUSED_COLOR);
    String bgDisabledColor = d.getString(TiC.PROPERTY_BACKGROUND_DISABLED_COLOR);

    if (bg != null) {
      bg = resolveImageUrl(bg);
    }
    if (bgSelected != null) {
      bgSelected = resolveImageUrl(bgSelected);
    }
    if (bgFocused != null) {
      bgFocused = resolveImageUrl(bgFocused);
    }
    if (bgDisabled != null) {
      bgDisabled = resolveImageUrl(bgDisabled);
    }

    if (bg != null
        || bgSelected != null
        || bgFocused != null
        || bgDisabled != null
        || bgColor != null
        || bgSelectedColor != null
        || bgFocusedColor != null
        || bgDisabledColor != null) {
      if (background == null) {
        applyCustomBackground(false);
      }

      Drawable bgDrawable =
          TiUIHelper.buildBackgroundDrawable(
              bg,
              d.getBoolean(TiC.PROPERTY_BACKGROUND_REPEAT),
              bgColor,
              bgSelected,
              bgSelectedColor,
              bgDisabled,
              bgDisabledColor,
              bgFocused,
              bgFocusedColor);

      background.setBackgroundDrawable(bgDrawable);
    }
  }
示例#3
0
  @Override
  public void processProperties(KrollDict d) {
    TiImageView view = getView();
    View parentView = getParentView();

    if (view == null) {
      return;
    }

    if (d.containsKey(TiC.PROPERTY_WIDTH)) {
      if (TiC.LAYOUT_FILL.equals(d.getString(TiC.PROPERTY_WIDTH)) && parentView != null) {
        // Use the parent's width when it's fill
        requestedWidth =
            TiConvert.toTiDimension(parentView.getMeasuredWidth(), TiDimension.TYPE_WIDTH);
      } else {
        requestedWidth = TiConvert.toTiDimension(d, TiC.PROPERTY_WIDTH, TiDimension.TYPE_WIDTH);
      }
    }
    if (d.containsKey(TiC.PROPERTY_HEIGHT)) {
      // Use the parent's height when it's fill
      if (TiC.LAYOUT_FILL.equals(d.getString(TiC.PROPERTY_HEIGHT)) && parentView != null) {
        requestedHeight =
            TiConvert.toTiDimension(parentView.getMeasuredHeight(), TiDimension.TYPE_HEIGHT);
      } else {
        requestedHeight = TiConvert.toTiDimension(d, TiC.PROPERTY_HEIGHT, TiDimension.TYPE_HEIGHT);
      }
    }

    if (d.containsKey(TiC.PROPERTY_IMAGES)) {
      setImageSource(d.get(TiC.PROPERTY_IMAGES));
      setImages();
    } else if (d.containsKey(TiC.PROPERTY_URL)) {
      Log.w(TAG, "The url property of ImageView is deprecated, use image instead.");
      if (!d.containsKey(TiC.PROPERTY_IMAGE)) {
        d.put(TiC.PROPERTY_IMAGE, d.get(TiC.PROPERTY_URL));
      }
    }
    if (d.containsKey(TiC.PROPERTY_CAN_SCALE)) {
      view.setCanScaleImage(TiConvert.toBoolean(d, TiC.PROPERTY_CAN_SCALE));
    }
    if (d.containsKey(TiC.PROPERTY_ENABLE_ZOOM_CONTROLS)) {
      view.setEnableZoomControls(TiConvert.toBoolean(d, TiC.PROPERTY_ENABLE_ZOOM_CONTROLS));
    }
    if (d.containsKey(TiC.PROPERTY_DEFAULT_IMAGE)) {
      Object defaultImage = d.get(TiC.PROPERTY_DEFAULT_IMAGE);
      try {
        Object image = d.get(TiC.PROPERTY_IMAGE);

        if (image instanceof String) {
          String imageUrl = TiUrl.getCleanUri((String) image).toString();
          URI imageUri = new URI(imageUrl);
          if (URLUtil.isNetworkUrl(imageUrl) && !TiResponseCache.peek(imageUri)) {
            setDefaultImageSource(defaultImage);
          }

        } else if (image == null) {
          setDefaultImageSource(defaultImage);
        }

      } catch (URISyntaxException e) {
        setDefaultImageSource(defaultImage);
      } catch (NullPointerException e) {
        setDefaultImageSource(defaultImage);
      }
    }
    if (d.containsKey(TiC.PROPERTY_IMAGE)) {
      // processProperties is also called from TableView, we need check if we changed before
      // re-creating the
      // bitmap
      boolean changeImage = true;
      Object newImage = d.get(TiC.PROPERTY_IMAGE);
      TiDrawableReference source = makeImageSource(newImage);

      // Check for orientation only if they specified an image
      if (d.containsKey(TiC.PROPERTY_AUTOROTATE)) {
        source.setAutoRotate(d.getBoolean(TiC.PROPERTY_AUTOROTATE));
      }

      if (imageSources != null && imageSources.size() == 1) {
        if (imageSources.get(0).equals(source)) {
          changeImage = false;
        }
      }

      if (changeImage) {
        setImageSource(source);
        firedLoad = false;
        setImage(false);
      }

    } else {
      if (!d.containsKey(TiC.PROPERTY_IMAGES)) {
        getProxy().setProperty(TiC.PROPERTY_IMAGE, null);
        if (defaultImageSource != null) {
          setDefaultImage();
        }
      }
    }

    super.processProperties(d);
  }
示例#4
0
  public static TiAnnotation fromDict(final KrollDict dict) {
    TiAnnotation a = null;
    if (dict.containsKeyAndNotNull(TiC.PROPERTY_ID)) {
      a = new TiAnnotation(dict.getString(TiC.PROPERTY_ID));
    } else {
      a = new TiAnnotation();
      dict.put(TiC.PROPERTY_ID, a.getId());
    }

    if (dict.containsKeyAndNotNull(TiC.PROPERTY_TITLE)) {
      a.setTitle(dict.getString(TiC.PROPERTY_TITLE));
    }
    if (dict.containsKeyAndNotNull(TiC.PROPERTY_SUBTITLE)) {
      a.setSubtitle(dict.getString(TiC.PROPERTY_SUBTITLE));
    }

    if (dict.containsKeyAndNotNull(TiC.PROPERTY_LATITUDE)) {
      a.setLatitude(dict.getDouble(TiC.PROPERTY_LATITUDE));
    }
    if (dict.containsKeyAndNotNull(TiC.PROPERTY_LONGITUDE)) {
      a.setLongitude(dict.getDouble(TiC.PROPERTY_LONGITUDE));
    }

    if (dict.containsKeyAndNotNull(TiC.PROPERTY_IMAGE)
        || dict.containsKeyAndNotNull(TiC.PROPERTY_PIN_IMAGE)) {
      a.setImage(dict.getString(TiC.PROPERTY_IMAGE));
      if (a.getImage() == null) {
        a.setImage(dict.getString(TiC.PROPERTY_PIN_IMAGE));
      }
    }

    if (dict.containsKeyAndNotNull(TiC.PROPERTY_PINCOLOR)) {
      Object pinColor = dict.get(TiC.PROPERTY_PINCOLOR);
      if (pinColor instanceof String) {
        a.setPinColor((String) pinColor);
      } else {
        a.setPinColor(dict.getInt(TiC.PROPERTY_PINCOLOR));
      }
    }

    if (dict.containsKeyAndNotNull(TiC.PROPERTY_LEFT_BUTTON)) {
      a.setLeftButton(TiConvert.toString(dict, TiC.PROPERTY_LEFT_BUTTON));
    }
    if (dict.containsKeyAndNotNull(TiC.PROPERTY_RIGHT_BUTTON)) {
      a.setRightButton(TiConvert.toString(dict, TiC.PROPERTY_RIGHT_BUTTON));
    }

    if (dict.containsKeyAndNotNull(TiC.PROPERTY_LEFT_VIEW)) {
      Object leftView = dict.get(TiC.PROPERTY_LEFT_VIEW);
      if (leftView instanceof TiViewProxy) {
        a.setLeftView((TiViewProxy) leftView);
      }
    }
    if (dict.containsKeyAndNotNull(TiC.PROPERTY_RIGHT_VIEW)) {
      Object rightView = dict.get(TiC.PROPERTY_RIGHT_VIEW);
      if (rightView instanceof TiViewProxy) {
        a.setRightView((TiViewProxy) rightView);
      }
    }

    if (dict.containsKeyAndNotNull(TiC.PROPERTY_ANIMATE)) {
      a.setAnimate(dict.getBoolean(TiC.PROPERTY_ANIMATE));
    } else {
      a.setAnimate(Boolean.FALSE);
    }

    if (dict.containsKeyAndNotNull(TiC.PROPERTY_CENTER)) {
      a.setCenter(dict.getBoolean(TiC.PROPERTY_CENTER));
    } else {
      a.setCenter(Boolean.TRUE);
    }
    return a;
  }