/** * Specifies the path of the button's image. * * <p>See {@link MediaUtil#determineMediaSource} for information about what a path can be. * * @param path the path of the button's image */ @DesignerProperty(editorType = PropertyTypeConstants.PROPERTY_TYPE_ASSET, defaultValue = "") @SimpleProperty( description = "Specifies the path of the button's image. " + "If there is both an Image and a BackgroundColor, only the Image will be " + "visible.") public void Image(String path) { // If it's the same as on the prior call and the prior load was successful, // do nothing. if (path.equals(imagePath) && backgroundImageDrawable != null) { return; } imagePath = (path == null) ? "" : path; // Clear the prior background image. backgroundImageDrawable = null; // Load image from file. if (imagePath.length() > 0) { try { backgroundImageDrawable = MediaUtil.getBitmapDrawable(container.$form(), imagePath); } catch (IOException ioe) { // TODO(user): Maybe raise Form.ErrorOccurred. Log.e(LOG_TAG, "Unable to load " + imagePath); // Fall through with a value of null for backgroundImageDrawable. } } // Update the appearance based on the new value of backgroundImageDrawable. updateAppearance(); }
/** * Specifies the path of the background image. * * <p>See {@link MediaUtil#determineMediaSource} for information about what a path can be. * * @param path the path of the background image */ @DesignerProperty(editorType = DesignerProperty.PROPERTY_TYPE_ASSET, defaultValue = "") @SimpleProperty( category = PropertyCategory.APPEARANCE, description = "The screen background image.") public void BackgroundImage(String path) { backgroundImagePath = (path == null) ? "" : path; try { backgroundDrawable = MediaUtil.getBitmapDrawable(this, backgroundImagePath); } catch (IOException ioe) { Log.e(LOG_TAG, "Unable to load " + backgroundImagePath); backgroundDrawable = null; } ViewUtil.setBackgroundImage(frameLayout, backgroundDrawable); frameLayout.invalidate(); }