コード例 #1
0
 protected void refreshOldStyleRow() {
   TableViewRowProxy rp = getRowProxy();
   if (!rp.hasProperty(TiC.PROPERTY_TOUCH_ENABLED)) {
     rp.setProperty(TiC.PROPERTY_TOUCH_ENABLED, false);
   }
   if (views == null) {
     views = new ArrayList<TiUIView>();
     views.add(new TiUILabel(rp));
   }
   TiUILabel t = (TiUILabel) views.get(0);
   t.setProxy(rp);
   t.processProperties(filterProperties(rp.getProperties()));
   View v = t.getNativeView();
   if (v.getParent() == null) {
     TiCompositeLayout.LayoutParams params = (TiCompositeLayout.LayoutParams) t.getLayoutParams();
     params.optionLeft = new TiDimension(5, TiDimension.TYPE_LEFT);
     params.optionRight = new TiDimension(5, TiDimension.TYPE_RIGHT);
     params.autoFillsWidth = true;
     content.addView(v, params);
   }
 }
コード例 #2
0
 @Override
 public Drawable getSelectorDrawable() {
   TableViewRowProxy rowProxy = getRowProxy();
   if (selectorDrawable == null && selectorSource != null) {
     if (rowProxy.hasProperty(TiC.PROPERTY_BACKGROUND_SELECTED_IMAGE)) {
       String path =
           TiConvert.toString(rowProxy.getProperty(TiC.PROPERTY_BACKGROUND_SELECTED_IMAGE));
       String url = rowProxy.getTiContext().resolveUrl(null, path);
       selectorDrawable = loadDrawable(url);
     } else if (rowProxy.hasProperty(TiC.PROPERTY_BACKGROUND_SELECTED_COLOR)) {
       int color =
           TiConvert.toColor(rowProxy.getProperties(), TiC.PROPERTY_BACKGROUND_SELECTED_COLOR);
       selectorDrawable = new TiTableViewColorSelector(color);
     }
   }
   return selectorDrawable;
 }
コード例 #3
0
 public void setRowData(Item item) {
   this.item = item;
   TableViewRowProxy rp = getRowProxy();
   rp.setTableViewItem(this);
   setRowData(rp);
 }
コード例 #4
0
  public void setRowData(TableViewRowProxy rp) {
    KrollDict props = rp.getProperties();
    hasControls = rp.hasControls();

    Object newSelectorSource = null;
    if (rp.hasProperty(TiC.PROPERTY_BACKGROUND_SELECTED_IMAGE)) {
      newSelectorSource = rp.getProperty(TiC.PROPERTY_BACKGROUND_SELECTED_IMAGE);
    } else if (rp.hasProperty(TiC.PROPERTY_BACKGROUND_SELECTED_COLOR)) {
      newSelectorSource = rp.getProperty(TiC.PROPERTY_BACKGROUND_SELECTED_COLOR);
    }
    if (newSelectorSource == null
        || selectorSource != null && !selectorSource.equals(newSelectorSource)) {
      selectorDrawable = null;
    }
    selectorSource = newSelectorSource;
    if (selectorSource != null) {
      rp.getTable().getTableView().getTableView().enableCustomSelector();
    }

    setBackgroundFromProperties(props);
    // Handle right image
    boolean clearRightImage = true;
    // It's one or the other, check or child.  If you set them both, child's gonna win.
    if (props.containsKey(TiC.PROPERTY_HAS_CHECK)) {
      if (TiConvert.toBoolean(props, TiC.PROPERTY_HAS_CHECK)) {
        if (hasCheckDrawable == null) {
          hasCheckDrawable = createHasCheckDrawable();
        }
        rightImage.setImageDrawable(hasCheckDrawable);
        rightImage.setVisibility(VISIBLE);
        clearRightImage = false;
      }
    }
    if (props.containsKey(TiC.PROPERTY_HAS_CHILD)) {
      if (TiConvert.toBoolean(props, TiC.PROPERTY_HAS_CHILD)) {
        if (hasChildDrawable == null) {
          hasChildDrawable = createHasChildDrawable();
        }
        rightImage.setImageDrawable(hasChildDrawable);
        rightImage.setVisibility(VISIBLE);
        clearRightImage = false;
      }
    }
    if (props.containsKey(TiC.PROPERTY_RIGHT_IMAGE)) {
      String path = TiConvert.toString(props, TiC.PROPERTY_RIGHT_IMAGE);
      String url = tiContext.resolveUrl(null, path);
      Drawable d = loadDrawable(url);
      if (d != null) {
        rightImage.setImageDrawable(d);
        rightImage.setVisibility(VISIBLE);
        clearRightImage = false;
      }
    }

    if (clearRightImage) {
      rightImage.setImageDrawable(null);
      rightImage.setVisibility(GONE);
    }

    // Handle left image
    if (props.containsKey(TiC.PROPERTY_LEFT_IMAGE)) {
      String path = TiConvert.toString(props, TiC.PROPERTY_LEFT_IMAGE);
      String url = tiContext.resolveUrl(null, path);

      Drawable d = loadDrawable(url);
      if (d != null) {
        leftImage.setImageDrawable(d);
        leftImage.setVisibility(VISIBLE);
      }
    } else {
      leftImage.setImageDrawable(null);
      leftImage.setVisibility(GONE);
    }

    if (props.containsKey(TiC.PROPERTY_HEIGHT)) {
      if (!props.get(TiC.PROPERTY_HEIGHT).equals(TiC.SIZE_AUTO)) {
        height =
            TiConvert.toTiDimension(
                TiConvert.toString(props, TiC.PROPERTY_HEIGHT), TiDimension.TYPE_HEIGHT);
      }
    }

    if (props.containsKey(TiC.PROPERTY_LAYOUT)) {
      content.setLayoutArrangement(TiConvert.toString(props, TiC.PROPERTY_LAYOUT));
    }

    if (rp.hasControls()) {
      refreshControls();
    } else {
      refreshOldStyleRow();
    }
  }