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); TiContext tiContext = getProxy().getTiContext(); if (bg != null) { bg = tiContext.resolveUrl(null, bg); } if (bgSelected != null) { bgSelected = tiContext.resolveUrl(null, bgSelected); } if (bgFocused != null) { bgFocused = tiContext.resolveUrl(null, bgFocused); } if (bgDisabled != null) { bgDisabled = tiContext.resolveUrl(null, 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( tiContext, bg, bgColor, bgSelected, bgSelectedColor, bgDisabled, bgDisabledColor, bgFocused, bgFocusedColor); background.setBackgroundDrawable(bgDrawable); } }
public void setBackgroundImageProperty(TiDict d, String property) { String path = TiConvert.toString(d, property); String url = tiContext.resolveUrl(null, path); TiBaseFile file = TiFileFactory.createTitaniumFile(tiContext, new String[] {url}, false); try { setBackgroundDrawable(new BitmapDrawable(TiUIHelper.createBitmap(file.getInputStream()))); } catch (IOException e) { Log.e(LCAT, "Error creating background image from path: " + path.toString(), e); } }