@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; }
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(); } }