Class NetworkEvent
-
Nested Class Summary
Nested classes/interfaces inherited from class ActionEvent
ActionEvent.TypeModifier and TypeClassDescriptionstatic enumThe event type, as declared when the event is created. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intIndicates that the connection request has completedstatic final intIndicates that a new request is initializing its connectionstatic final intIndicates the value for the current input stream readingstatic final intIndicates the value for the current output stream writing -
Constructor Summary
ConstructorsConstructorDescriptionNetworkEvent(ConnectionRequest request, int progressType) Constructs a network status update event used to update progress indicators and application logic of the current state in the NetworkManagerNetworkEvent(ConnectionRequest request, int responseCode, String message) Constructs a response code evenNetworkEvent(ConnectionRequest source, Exception error) Constructs an event for an error messageNetworkEvent(ConnectionRequest request, Object metaData) Constructs a callback event from a connection request with some arbitrary associated meta data -
Method Summary
Modifier and TypeMethodDescriptionEquivalent to getSource() casted to connection requestgetError()Returns
intReturns the length of the download event or the upload event in case it is known.Returns
Returns
intReturns the percentage of progress for a download operation assuming length is knownintIndicates the type of progres indication for this eventintIndicates the response code sent by the response code listenerintReturns the amount of data received up to this event or sent up to this event (depending on the event type).voidParameters
Methods inherited from class ActionEvent
consume, getActualComponent, getCommand, getComponent, getDraggedComponent, getDropTarget, getEventType, getKeyEvent, getProgress, getSource, getX, getY, isConsumed, isLongEvent, isPointerPressedDuringDrag, setPointerPressedDuringDragModifier and TypeMethodDescriptionvoidconsume()Consume the event indicating that it was handled thus preventing other action listeners from handling/receiving the eventIdentical toActionEvent#getComponent()except for the fact that a lead component will be returned if such a lead component is available.If this event was sent as a result of a command action this method returns that commandReturns the component that generated the event.Set in the case of a drop listener, returns the component being draggedSet in the case of a drop listener, returns the component on which the drop occursReturns the type of the given event allowing us to have more generic event handling code and useful for debuggingintIf this event was triggered by a key press this method will return the appropriate keycodeintReturns the numeric progress of native browser loading on AndroidThe element that triggered the action event, useful for decoupling event handling codeintgetX()The X position if this is a pointer event otherwise undefinedintgetY()The Y position if this is a pointer event otherwise undefinedbooleanReturns true if the event was consumed thus indicating that it was handled.booleanReturns true for long click or long pointer eventbooleanOnly used for pointer dragged events.voidsetPointerPressedDuringDrag(boolean pressed) Only used for pointer dragged events.Methods inherited from class Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitModifier and TypeMethodDescriptionprotected Objectclone()booleanIndicates whether some other object is "equal to" this one.final ClassgetClass()Returns the runtime class of an object.inthashCode()Returns a hash code value for the object.final voidnotify()Wakes up a single thread that is waiting on this object's monitor.final voidWakes up all threads that are waiting on this object's monitor.toString()Returns a string representation of the object.final voidwait()Causes current thread to wait until another thread invokes the method or the method for this object.final voidwait(long timeout) Causes current thread to wait until either another thread invokes the method or the method for this object, or a specified amount of time has elapsed.final voidwait(long timeout, int nanos) Causes current thread to wait until another thread invokes the method or the method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.
-
Field Details
-
PROGRESS_TYPE_INITIALIZING
public static final int PROGRESS_TYPE_INITIALIZINGIndicates that a new request is initializing its connection- See Also:
-
PROGRESS_TYPE_OUTPUT
public static final int PROGRESS_TYPE_OUTPUTIndicates the value for the current output stream writing- See Also:
-
PROGRESS_TYPE_INPUT
public static final int PROGRESS_TYPE_INPUTIndicates the value for the current input stream reading- See Also:
-
PROGRESS_TYPE_COMPLETED
public static final int PROGRESS_TYPE_COMPLETEDIndicates that the connection request has completed- See Also:
-
-
Constructor Details
-
NetworkEvent
Constructs an event for an error message
Parameters
-
source: source of the error message -
error: the exception
-
-
NetworkEvent
Constructs a response code even
Parameters
-
request: the connection request indicating progress -
responseCode: the code -
message: the error message
-
-
NetworkEvent
Constructs a network status update event used to update progress indicators and application logic of the current state in the NetworkManager
Parameters
-
request: the connection request indicating progress -
progressType
-
-
NetworkEvent
Constructs a callback event from a connection request with some arbitrary associated meta data
Parameters
-
request: the connection request -
metaData: the data associated with the event
-
-
-
Method Details
-
getConnectionRequest
Equivalent to getSource() casted to connection request
Returns
the source connection request
-
getError
Returns
the error
-
setError
Parameters
error: the error to set
-
getProgressType
public int getProgressType()Indicates the type of progres indication for this event
Returns
- Returns:
- One of PROGRESS_TYPE_COMPLETED, PROGRESS_TYPE_INITIALIZING, PROGRESS_TYPE_INPUT, PROGRESS_TYPE_OUTPUT
-
getResponseCode
public int getResponseCode()Indicates the response code sent by the response code listener
Returns
HTTP error code
-
getLength
public int getLength()Returns the length of the download event or the upload event in case it is known. -1 is returned when the value is unknown.
Returns
the length length in bytes or -1
-
getSentReceived
public int getSentReceived()Returns the amount of data received up to this event or sent up to this event (depending on the event type).
Returns
the receieved or sent value
-
getProgressPercentage
public int getProgressPercentage()Returns the percentage of progress for a download operation assuming length is known
Returns
the percentage of the download or -1
-
getMetaData
Returns
the metaData
-
getMessage
Returns
the message
-