public class Ads
ImplementsAnimation, Editable, HTMLCallback, Iterable<Component>, ParserCallback, StyleListener
BannerAd from the modern advertising API
(see AdManager) instead.Fields
public static final int ERROR_CSS_ATTRIBUTE_NOT_SUPPORTED = 200 | Error code denoting that an unsupported CSS attribute (by XHTML-MP 1.0 standards) was found in the HTML or external CSS files |
public static final int ERROR_CSS_ATTIBUTE_VALUE_INVALID = 201 | Error code denoting that an invalid attribute value was found in the CSS |
public static final int ERROR_CSS_NOT_FOUND = 202 | Error code denoting that a CSS file referenced from the HTML or from another external CSS file was not found |
public static final int ERROR_CSS_NO_BASE_URL = 203 | Error code denoting that a relative URL was referenced from a document with no base URL (A document that was loaded via setBody/setHTML/setDOM and not via setPage) In this case the return value of parsingError is not considered - parsing co… |
Constructors
public Ads() | Default constructor for GUI builder |
public Ads(String appId) | Simple constructor to create an Ad Component |
public Ads(String appId, boolean refreshAd) |
Methods
public void initComponent() | Allows subclasses to bind functionality that relies on fully initialized and “ready for action” component state |
protected void deinitialize() | Invoked to indicate that the component initialization is being reversed since the component was detached from the container hierarchy. |
public boolean animate() | Allows the animation to reduce “repaint” calls when it returns false. |
public void keyReleased(int code) | If this Component is focused, the key released event will call this method |
public void pointerReleased(int x, int y) | If this Component is focused, the pointer released event will call this method |
public String getAd() | HTML ad received from the server |
public void setAd(String ad) | HTML ad received from the server |
public int getUpdateDuration() | The amount of time needed to update the ad |
public void setUpdateDuration(int updateDuration) | The amount of time needed to update the ad |
public void titleUpdated(HTMLComponent htmlC, String title) | Called when the page’s title is updated |
public void pageStatusChanged(HTMLComponent htmlC, int status, String url) | Called when the page status has been changed |
public String fieldSubmitted(HTMLComponent htmlC, TextArea ta, String actionURL, String id, String value, int type, String errorMsg) | Called whenever a field is submitted to a form. |
public String getAutoComplete(HTMLComponent htmlC, String actionURL, String id) | Called on form creation and enabled implementations of this method to return a value to preset in a form field. |
public int getLinkProperties(HTMLComponent htmlC, String url) | Returns properties about the given link to indicate to HTMLComponent how to render it Note that this method is always called NOT on the EDT thread. |
public boolean linkClicked(HTMLComponent htmlC, String url) | Called when a link is clicked. |
public void actionPerformed(ActionEvent evt, HTMLComponent htmlC, HTMLElement element) | Called whenever an ActionEvent is triggered in one of the controls in the HTMLComponent For example, button press, checkbox/radiobutton check etc. This method will be called only if HTMLComponent.isEventsEnabled() is true |
public void focusGained(Component cmp, HTMLComponent htmlC, HTMLElement element) | Called when one of the controls in the HTMLComponent obtained focus This method will be called only if HTMLComponent.isEventsEnabled() is true |
public void focusLost(Component cmp, HTMLComponent htmlC, HTMLElement element) | Called when one of the controls in the HTMLComponent lost focus This method will be called only if HTMLComponent.isEventsEnabled() is true |
public void dataChanged(int type, int index, HTMLComponent htmlC, TextField textField, HTMLElement element) | Called when the user types in a TextField inside the HTMLComponent This method will be called only if HTMLComponent.isEventsEnabled() is true |
public boolean parsingError(int errorId, String tag, String attribute, String value, String description) | Called when encountering an error while parsing the XML document. |
public void selectionChanged(int oldSelected, int newSelected, HTMLComponent htmlC, List list, HTMLElement element) | Called when the user selects an item in a List inside the HTMLComponent Note: Selection is traversing through the items - once the user has actually decided, an ActionEvent will be sent as well This method will be called only if HTMLCompone… |
public void setHeight(int height) | Sets the Component height, this method is exposed for the purpose of external layout managers and should not be invoked directly. |
public String getAppID() | Simple getter of the unique identifier of the app on the ads service network. |
public void setAppID(String appId) | Simple setter of the unique identifier of the app on the ads service network, no need to manually use this the createAdsService uses this. |
public String getAge() | Users age |
public void setAge(String age) | Sets the users age |
public String getGender() | The user gender can be: M/m, F/f, Male, Female. |
public void setGender(String gender) | Sets Gender if applicable can be one of the following: ‘F’, ‘f’, ‘M’, ’m’, ‘Female’, ‘female’, ‘Male’, ‘male’ |
public String[] getKeywords() | Keywords relevant to this user specific session |
public void setKeywords(String[] keywords) | Keywords relevant to this user specific session |
public String getCategory() | Category is a single word description of the application. |
public void setCategory(String category) | Category is a single word description of the application. |
public String getLocation() | Location string is a comma separated list of country, state/province, city For example: US, NY, NY |
public void setLocation(String location) | Location string is a comma separated list of country, state/province, city For example: US, NY, NY |
public String[] getPropertyNames() | A component may expose mutable property names for a UI designer to manipulate, this API is designed for usage internally by the GUI builder code |
public Class[] getPropertyTypes() | Matches the property names method (see that method for further details). |
public String[] getPropertyTypeNames() | This method is here to workaround an XMLVM array type bug where property types aren’t identified properly, it returns the names of the types using the following type names: String,int,double,long,byte,short,char,String[],String[][],byte[],I… |
public Object getPropertyValue(String name) | Returns the current value of the property name, this method is used by the GUI builder |
public String setPropertyValue(String name, Object value) | Sets a new value to the given property, returns an error message if failed and null if successful. |
Inherited fields
From Component
DEFAULT_CURSOR, CROSSHAIR_CURSOR, TEXT_CURSOR, WAIT_CURSOR, SW_RESIZE_CURSOR, SE_RESIZE_CURSOR, NW_RESIZE_CURSOR, NE_RESIZE_CURSOR, N_RESIZE_CURSOR, S_RESIZE_CURSOR, W_RESIZE_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, MOVE_CURSOR, DRAG_REGION_NOT_DRAGGABLE, DRAG_REGION_POSSIBLE_DRAG_X, DRAG_REGION_POSSIBLE_DRAG_Y, DRAG_REGION_POSSIBLE_DRAG_XY, DRAG_REGION_LIKELY_DRAG_X, DRAG_REGION_LIKELY_DRAG_Y, DRAG_REGION_LIKELY_DRAG_XY, DRAG_REGION_IMMEDIATELY_DRAG_X, DRAG_REGION_IMMEDIATELY_DRAG_Y, DRAG_REGION_IMMEDIATELY_DRAG_XY, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_CENTER_OFFSET, BRB_OTHER, CENTER, TOP, LEFT, BOTTOM, RIGHT, BASELINE
From HTMLCallback
ERROR_CONNECTING, ERROR_IMAGE_NOT_FOUND, ERROR_IMAGE_BAD_FORMAT, ERROR_NO_BASE_URL, ERROR_INVALID_TAG_HIERARCHY, STATUS_NONE, STATUS_ERROR, STATUS_CANCELLED, STATUS_REQUESTED, STATUS_CONNECTED, STATUS_PARSED, STATUS_DISPLAYED, STATUS_COMPLETED, STATUS_REDIRECTED, FIELD_TEXT, FIELD_PASSWORD, LINK_REGULAR, LINK_VISTED, LINK_FORBIDDEN
Inherited methods
From Container
encloseIn, encloseIn, initLaf, getUIManager, setUIManager, isSurface, add, addAll, add, add, add, add, add, getLeadComponent, setLeadComponent, getLeadParent, keyPressed, getLayout, setLayout, invalidate, setShouldLayout, setShouldCalcPreferredSize, getLayoutWidth, getLayoutHeight, applyRTL, constrainWidthWhenScrollable, constrainHeightWhenScrollable, addComponent, addComponent, addComponent, addComponent, replaceAndWait, replaceAndWait, replace, replaceAndWait, replace, createReplaceTransition, isEnabled, setEnabled, removeComponent, cancelRepaints, flushReplace, removeAll, revalidateWithAnimationSafety, revalidate, revalidateLater, forceRevalidate, clearClientProperties, paint, paintGlass, layoutContainer, isSafeArea, setSafeArea, isSafeAreaRoot, getSafeAreaRoot, setSafeAreaRoot, getComponentCount, getComponentAt, getComponentIndex, contains, scrollComponentToVisible, getClosestComponentTo, getResponderAt, getComponentAt, findDropTargetAt, pointerPressed, calcPreferredSize, paramString, refreshTheme, isScrollableX, setScrollableX, isScrollableY, setScrollableY, getSideGap, getBottomGap, setScrollable, setCellRenderer, getScrollIncrement, setScrollIncrement, findFirstFocusable, dragInitiated, fireClicked, isSelectableInteraction, getGridPosY, paintComponentBackground, getGridPosX, animateHierarchyAndWait, createAnimateHierarchy, animateHierarchy, animateHierarchyFadeAndWait, createAnimateHierarchyFade, animateHierarchyFade, animateLayoutFadeAndWait, createAnimateLayoutFadeAndWait, animateLayoutFade, createAnimateLayoutFade, animateLayoutAndWait, animateLayout, updateTabIndices, createAnimateLayout, drop, createAnimateMotion, morph, morphAndWait, animateUnlayout, animateUnlayoutAndWait, createAnimateUnlayout, getChildrenAsList, iterator, iterator
From Component
setSameSize, isSetCursorSupported, parsePreferredSize, getDefaultDragTransparency, setDefaultDragTransparency, getEditingDelegate, setEditingDelegate, getCursor, setCursor, showNativeOverlay, hideNativeOverlay, updateNativeOverlay, getNativeOverlay, getAllStyles, getSameWidth, setSameWidth, getSameHeight, setSameHeight, getX, setX, getOuterX, getInnerX, getY, setY, getOuterY, getInnerY, isVisible, setVisible, getClientProperty, stripMarginAndPadding, putClientProperty, getDirtyRegion, setDirtyRegion, isOpaque, setOpaque, getWidth, setWidth, getOuterWidth, getInnerWidth, getHeight, getOuterHeight, getInnerHeight, isDragRegion, getDragRegionStatus, getBaseline, getBaselineResizeBehavior, getPreferredSizeStr, setPreferredSizeStr, getPreferredSize, setPreferredSize, getScrollDimension, calcScrollSize, setScrollSize, getPreferredW, setPreferredW, getPreferredH, setPreferredH, getOuterPreferredH, getInnerPreferredH, getOuterPreferredW, getInnerPreferredW, setSize, getUIID, setUIID, setUIIDFinal, setUIID, getInlineAllStyles, setInlineAllStyles, getInlineSelectedStyles, setInlineSelectedStyles, getInlineUnselectedStyles, setInlineUnselectedStyles, getInlineDisabledStyles, setInlineDisabledStyles, getInlinePressedStyles, setInlinePressedStyles, remove, getParent, getOwner, setOwner, isOwnedBy, containsOrOwns, addFocusListener, removeFocusListener, addScrollListener, removeScrollListener, getSelectCommandText, setSelectCommandText, getLabelForComponent, setLabelForComponent, focusGained, focusLost, paintBackgrounds, paintShadows, getAbsoluteX, getAbsoluteY, isInClippingRegion, paintIntersectingComponentsAbove, paintScrollbars, paintScrollbarX, getScrollOpacity, getSelectedRect, paintScrollbarY, paintComponent, paintComponent, getBorder, getScrollable, paintBackground, isScrollable, getScrollX, setScrollX, getScrollY, setScrollY, onScrollX, onScrollY, getDraggedx, getDraggedy, contains, visibleBoundsContains, hasFixedPreferredSize, getBounds, getBounds, getVisibleBounds, getVisibleBounds, isFocusable, setFocusable, onSetFocusable, resetFocusable, getTabIndex, setTabIndex, getPreferredTabIndex, setPreferredTabIndex, isTraversable, setTraversable, handlesInput, setHandlesInput, consumesRawTextInput, hasFocus, setFocus, getComponentForm, getTopLevelContainer, repaint, repaint, longKeyPress, keyRepeated, registerForAnimation, deregisterFromAnimation, getAnimationManager, getScrollAnimationSpeed, setScrollAnimationSpeed, isBlockLead, setBlockLead, isIgnorePointerEvents, setIgnorePointerEvents, isRippleEffect, setRippleEffect, getInlineStylesTheme, setInlineStylesTheme, shouldRenderComponentSelection, isHideInLandscape, setHideInLandscape, createStyleAnimation, isSmoothScrolling, setSmoothScrolling, pointerHover, stopScrollMomentum, pointerHoverReleased, pointerHoverPressed, pinch, pinchReleased, pinch, rotation, isPinchBlocksDragAndDrop, setPinchBlocksDragAndDrop, pointerDragged, getDragImage, getDragTransparency, setDragTransparency, toImage, drawDraggedImage, draggingOver, dragEnter, dragExit, addPullToRefresh, setPullToRefresh, respondsToPointerEvents, pointerDragged, isStickyDrag, pointerPressed, isDragAndDropOperation, pointerReleased, longPointerPress, setVerticalScrollBounds, setHorizontalScrollBounds, isVScrollThumbGrabbed, isHScrollThumbGrabbed, isVScrollThumbHover, isHScrollThumbHover, isTensileDragEnabled, setTensileDragEnabled, getTextSelectionSupport, addDropListener, removeDropListener, addDragOverListener, removeDragOverListener, isNativeDragSource, setNativeDragSource, getNativeDragOperation, setNativeDragOperation, createNativeDragOperation, isNativeDropTarget, setNativeDropTarget, getAcceptedDropMimeTypes, setAcceptedDropMimeTypes, getAcceptedDropActions, setAcceptedDropActions, canAcceptNativeDrop, nativeDragEnter, nativeDragOver, nativeDragExit, nativeDrop, addNativeDropListener, removeNativeDropListener, addNativeDragOverListener, removeNativeDragOverListener, dragFinished, addDragFinishedListener, addStateChangeListener, removeStateChangeListener, addPointerPressedListener, addLongPressListener, addContextMenuListener, removeContextMenuListener, addMouseWheelListener, removeMouseWheelListener, addStylusListener, removeStylusListener, mouseWheel, paintRippleOverlay, removePointerPressedListener, removeLongPressListener, removeDragFinishedListener, addPointerReleasedListener, removePointerReleasedListener, addPointerDraggedListener, removePointerDraggedListener, getDragSpeed, getStyle, getPressedStyle, setPressedStyle, initUnselectedStyle, initPressedStyle, initDisabledStyle, initSelectedStyle, getUnselectedStyle, setUnselectedStyle, getSelectedStyle, setSelectedStyle, getDisabledStyle, setDisabledStyle, installDefaultPainter, requestFocus, toString, refreshTheme, refreshTheme, isDragActivated, scrollRectToVisible, scrollRectToVisible, paintBorder, paintBorderBackground, isCellRenderer, isScrollVisible, setScrollVisible, setIsScrollVisible, startEditingAsync, stopEditing, isEditing, isEditable, laidOut, isInitialized, setInitialized, styleChanged, getNextFocusDown, setNextFocusDown, getNextFocusUp, setNextFocusUp, getNextFocusLeft, setNextFocusLeft, getNextFocusRight, setNextFocusRight, getName, setName, initCustomStyle, deinitializeCustomStyle, isRTL, setRTL, isTactileTouch, isTactileTouch, setTactileTouch, paintLockRelease, paintLock, isSnapToGrid, setSnapToGrid, shouldBlockSideSwipe, shouldBlockSideSwipeLeft, shouldBlockSideSwipeRight, blocksSideSwipe, isFlatten, setFlatten, getTensileLength, setTensileLength, isGrabsPointerEvents, setGrabsPointerEvents, getScrollOpacityChangeSpeed, setScrollOpacityChangeSpeed, growShrink, isAlwaysTensile, setAlwaysTensile, isDraggable, setDraggable, isDropTarget, setDropTarget, isChildOf, isHideInPortrait, setHideInPortrait, getBindablePropertyNames, getBindablePropertyTypes, bindProperty, unbindProperty, getBoundPropertyValue, setBoundPropertyValue, getCloudBoundProperty, setCloudBoundProperty, getCloudDestinationProperty, setCloudDestinationProperty, getComponentState, setComponentState, setHidden, isHidden, setHidden, isHidden, announceForAccessibility, getAccessibilityText, setAccessibilityText, getSemantics, getAccessibilityNode, accessibilityChanged, accessibilityChanged, getTooltip, setTooltip
Field details
ERROR_CSS_ATTRIBUTE_NOT_SUPPORTED
public static final int ERROR_CSS_ATTRIBUTE_NOT_SUPPORTED = 200ERROR_CSS_ATTIBUTE_VALUE_INVALID
public static final int ERROR_CSS_ATTIBUTE_VALUE_INVALID = 201ERROR_CSS_NOT_FOUND
public static final int ERROR_CSS_NOT_FOUND = 202ERROR_CSS_NO_BASE_URL
public static final int ERROR_CSS_NO_BASE_URL = 203Constructor details
Ads
public Ads()Ads
public Ads(String appId)Parameters
appIdString- unique identifier of the app, to gain an appId please refer to http://console.inner-active.com/iamp/publisher/register?ref_id=affiliate_CodenameOne
Ads
public Ads(String appId, boolean refreshAd)Parameters
appIdString- unique identifier of the app, to gain an appId please refer to http://console.inner-active.com/iamp/publisher/register?ref_id=affiliate_CodenameOne
refreshAdboolean- if true this Component will refresh the Ad every 60 seconds, if false no refresh will occur
Method details
initComponent
public void initComponent()deinitialize
protected void deinitialize()animate
public boolean animate()com.codename1.ui.Display class.Returns
keyReleased
public void keyReleased(int code)Parameters
codeint- the key code value to indicate a physical key.
pointerReleased
public void pointerReleased(int x, int y)Parameters
xint- the pointer x coordinate
yint- the pointer y coordinate
getAd
public String getAd()Returns
setAd
public void setAd(String ad)Parameters
adString- the ad to set
getUpdateDuration
public int getUpdateDuration()Returns
setUpdateDuration
public void setUpdateDuration(int updateDuration)Parameters
updateDurationint- the updateDuration to set
titleUpdated
public void titleUpdated(HTMLComponent htmlC, String title)Parameters
htmlCHTMLComponent- The HTMLComponent that triggered the event
titleString- The new title
pageStatusChanged
public void pageStatusChanged(HTMLComponent htmlC, int status, String url)Parameters
htmlCHTMLComponent- The HTMLComponent in which the status change occured
statusint- The new status, one of the STATUS_* constants
urlString- The URL of the page
fieldSubmitted
public String fieldSubmitted(HTMLComponent htmlC, TextArea ta, String actionURL, String id, String value, int type, String errorMsg)Parameters
htmlCHTMLComponent- The HTMLComponent in which this event occured
taTextArea- The TextArea/TextField of this field
actionURLString- The action URL of the form
idString- The ID of the field
valueString- The value entered
typeint- The type of the field, one of the FIELD_* constants
errorMsgString- The error message if any error occured (i.e. input validation error) or null if no error occured
Returns
getAutoComplete
public String getAutoComplete(HTMLComponent htmlC, String actionURL, String id)Parameters
htmlCHTMLComponent- The HTMLComponent in which this event occured
actionURLString- The action URL of the form
idString- The ID of the field
Returns
getLinkProperties
public int getLinkProperties(HTMLComponent htmlC, String url)Parameters
htmlCHTMLComponent- The HTMLComponent
urlString- The Link URL
Returns
linkClicked
public boolean linkClicked(HTMLComponent htmlC, String url)Parameters
htmlCHTMLComponent- The HTMLComponent
urlString- The Link URL
Returns
actionPerformed
public void actionPerformed(ActionEvent evt, HTMLComponent htmlC, HTMLElement element)Parameters
evtActionEvent- The event triggered, the component can be extracted using getSource
htmlCHTMLComponent- The HTMLComponent
elementHTMLElement- The element associated with the component that triggered the event
focusGained
public void focusGained(Component cmp, HTMLComponent htmlC, HTMLElement element)Parameters
cmpComponent- The component that triggered the event
htmlCHTMLComponent- The HTMLComponent
elementHTMLElement- The element associated with the component that triggered the event
focusLost
public void focusLost(Component cmp, HTMLComponent htmlC, HTMLElement element)Parameters
cmpComponent- The component that triggered the event
htmlCHTMLComponent- The HTMLComponent
elementHTMLElement- The element associated with the component that triggered the event
dataChanged
public void dataChanged(int type, int index, HTMLComponent htmlC, TextField textField, HTMLElement element)Parameters
typeint- the type data change; REMOVED, ADDED or CHANGED
indexint- item index in a list model
htmlCHTMLComponent- The HTMLComponent
textFieldTextField- The TextField that triggerd the event
elementHTMLElement- The element associated with the component that triggered the event (Should be TAG_INPUT with type text/password)
parsingError
public boolean parsingError(int errorId, String tag, String attribute, String value, String description)Parameters
errorIdint- The error ID, one of the ERROR_* constants
tagString- The tag in which the error occured (Can be null for non-tag related errors)
attributeString- The attribute in which the error occured (Can be null for non-attribute related errors)
valueString- The value in which the error occured (Can be null for non-value related errors)
descriptionString- A verbal description of the error
Returns
selectionChanged
public void selectionChanged(int oldSelected, int newSelected, HTMLComponent htmlC, List list, HTMLElement element)Parameters
oldSelectedint- old selected index in list model
newSelectedint- new selected index in list model
htmlCHTMLComponent- The HTMLComponent
listList- The list that triggered the event (Usually a ComboBox but not always)
elementHTMLElement- The element associated with the component that triggered the event (Should be TAG_SELECT)
setHeight
public void setHeight(int height)Sets the Component height, this method is exposed for the purpose of external layout managers and should not be invoked directly.
If a user wishes to affect the component size, setPreferredSize should be used.
Parameters
heightint- the height of the component
getAppID
public String getAppID()Returns
setAppID
public void setAppID(String appId)Parameters
appIdString- unique identifier of the app, to gain an appId please refer to http://console.inner-active.com/iamp/publisher/register?ref_id=affiliate_CodenameOne
getAge
public String getAge()Returns
setAge
public void setAge(String age)getGender
public String getGender()setGender
public void setGender(String gender)getKeywords
public String[] getKeywords()setKeywords
public void setKeywords(String[] keywords)getCategory
public String getCategory()Returns
setCategory
public void setCategory(String category)getLocation
public String getLocation()setLocation
public void setLocation(String location)getPropertyNames
public String[] getPropertyNames()Returns
getPropertyTypes
public Class[] getPropertyTypes()Returns
getPropertyTypeNames
public String[] getPropertyTypeNames()Returns
getPropertyValue
public Object getPropertyValue(String name)Parameters
nameString- the name of the property
Returns
setPropertyValue
public String setPropertyValue(String name, Object value)Parameters
nameString- the name of the property
valueObject- new value for the property