Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-17704] XHR onreadystatechange called multiple times #6228

Merged
merged 10 commits into from
Oct 22, 2014
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void handleCreationDict(KrollDict dict)
{
super.handleCreationDict(dict);
if (hasProperty(TiC.PROPERTY_TIMEOUT)) {
client.setTimeout(TiConvert.toInt(getProperty(TiC.PROPERTY_TIMEOUT)));
client.setTimeout(TiConvert.toInt(getProperty(TiC.PROPERTY_TIMEOUT),0));
}

//Set the securityManager on the client if it is defined as a valid value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -565,13 +565,14 @@ public void setReadyState(int readyState)
{
Log.d(TAG, "Setting ready state to " + readyState, Log.DEBUG_MODE);
this.readyState = readyState;

dispatchCallback("onreadystatechange", null);
KrollDict data = new KrollDict();
data.put("readyState", Integer.valueOf(readyState));
dispatchCallback("onreadystatechange", data);

if (readyState == READY_STATE_DONE) {
KrollDict data = new KrollDict();
data.putCodeAndMessage(TiC.ERROR_CODE_NO_ERROR, null);
dispatchCallback("onload", data);
KrollDict data1 = new KrollDict();
data1.putCodeAndMessage(TiC.ERROR_CODE_NO_ERROR, null);
dispatchCallback("onload", data1);
}
}

Expand Down
84 changes: 42 additions & 42 deletions apidoc/Titanium/Media/Media.yml
Original file line number Diff line number Diff line change
Expand Up @@ -269,13 +269,13 @@ methods:
events:
- name: linechange
deprecated:
since: "3.4.1"
since: "3.4.2"
notes: Titanium no longer fires this event. Use the [routechange](Titanium.Media.routechange) event instead.
summary: Fired when an audio line type change is detected.
platforms: [iphone, ipad]
- name: recordinginput
deprecated:
since: "3.4.1"
since: "3.4.2"
notes: Titanium no longer fires this event. Use the [canRecord](Titanium.Media.canRecord) property to check if an input hardware is available.
summary: Fired when the availablity of recording input changes.
properties:
Expand All @@ -295,7 +295,7 @@ events:
- name: currentRoute
summary: Returns a description of the current route, consisting of zero or more input ports and zero or more output ports.
type: RouteDescription
since: "3.4.1"
since: "3.4.2"
platforms: [iphone, ipad]
- name: volume
summary: Fired when the volume output changes.
Expand Down Expand Up @@ -387,55 +387,55 @@ properties:
platforms: [iphone, ipad]
- name: AUDIO_HEADPHONES
deprecated:
since: "3.4.1"
since: "3.4.2"
notes: Deprecated in favor of the `AUDIO_SESSION_PORT` constants defined in <Titanium.Media>.
summary: Line-type constant for headphones.
type: Number
permission: read-only
platforms: [iphone, ipad]
- name: AUDIO_HEADPHONES_AND_MIC
deprecated:
since: "3.4.1"
since: "3.4.2"
notes: Deprecated in favor of the `AUDIO_SESSION_PORT` constants defined in <Titanium.Media>.
summary: Line-type constant for headphones and microphone.
type: Number
permission: read-only
platforms: [iphone, ipad]
- name: AUDIO_HEADSET_INOUT
deprecated:
since: "3.4.1"
since: "3.4.2"
notes: Deprecated in favor of the `AUDIO_SESSION_PORT` constants defined in <Titanium.Media>.
summary: Line-type constant for headset in/out.
type: Number
permission: read-only
platforms: [iphone, ipad]
- name: AUDIO_LINEOUT
deprecated:
since: "3.4.1"
since: "3.4.2"
notes: Deprecated in favor of the `AUDIO_SESSION_PORT` constants defined in <Titanium.Media>.
summary: Line-type constant for line-out.
type: Number
permission: read-only
platforms: [iphone, ipad]
- name: AUDIO_MICROPHONE
deprecated:
since: "3.4.1"
since: "3.4.2"
notes: Deprecated in favor of the `AUDIO_SESSION_PORT` constants defined in <Titanium.Media>.
summary: Line-type constant for microphone.
type: Number
permission: read-only
platforms: [iphone, ipad]
- name: AUDIO_MUTED
deprecated:
since: "3.4.1"
since: "3.4.2"
notes: Deprecated in favor of the `AUDIO_SESSION_PORT` constants defined in <Titanium.Media>.
summary: Line-type constant indicated mute switch is on.
type: Number
permission: read-only
platforms: [iphone, ipad]
- name: AUDIO_RECEIVER_AND_MIC
deprecated:
since: "3.4.1"
since: "3.4.2"
notes: Deprecated in favor of the `AUDIO_SESSION_PORT` constants defined in <Titanium.Media>.
summary: Line-type constant indicating receiver and microphone.
type: Number
Expand All @@ -451,7 +451,7 @@ properties:
type: String
permission: read-only
platforms: [iphone, ipad]
since: "3.4.1"
since: "3.4.2"
- name: AUDIO_SESSION_CATEGORY_PLAYBACK
summary: Session mode for playing recorded music or other sounds that are central to the successful use of your application.
description: |
Expand All @@ -461,7 +461,7 @@ properties:
type: String
permission: read-only
platforms: [iphone, ipad]
since: "3.4.1"
since: "3.4.2"
- name: AUDIO_SESSION_CATEGORY_PLAY_AND_RECORD
summary: Session mode for recording (input) and playback (output) of audio, such as for a VOIP (voice over IP) application.
description: |
Expand All @@ -476,13 +476,13 @@ properties:
type: String
permission: read-only
platforms: [iphone, ipad]
since: "3.4.1"
since: "3.4.2"
- name: AUDIO_SESSION_CATEGORY_RECORD
summary: Session mode for recording audio; it silences playback audio.
type: String
permission: read-only
platforms: [iphone, ipad]
since: "3.4.1"
since: "3.4.2"
- name: AUDIO_SESSION_CATEGORY_SOLO_AMBIENT
summary: Session mode for long-duration sounds such as rain, car engine noise, and so on.
description: |
Expand All @@ -495,10 +495,10 @@ properties:
type: String
permission: read-only
platforms: [iphone, ipad]
since: "3.4.1"
since: "3.4.2"
- name: AUDIO_SESSION_MODE_AMBIENT
deprecated:
since: "3.4.1"
since: "3.4.2"
notes: Deprecated in favor of the `AUDIO_SESSION_CATEGORY` constants defined in <Titanium.Media>.
summary: For long-duration sounds such as rain, car engine noise, and so on.
description: |
Expand All @@ -511,7 +511,7 @@ properties:
platforms: [iphone, ipad]
- name: AUDIO_SESSION_MODE_PLAYBACK
deprecated:
since: "3.4.1"
since: "3.4.2"
notes: Deprecated in favor of the `AUDIO_SESSION_CATEGORY` constants defined in <Titanium.Media>.
summary: Session mode for playing recorded music or other sounds that are central to the successful use of your application.
description: |
Expand All @@ -523,7 +523,7 @@ properties:
platforms: [iphone, ipad]
- name: AUDIO_SESSION_MODE_PLAY_AND_RECORD
deprecated:
since: "3.4.1"
since: "3.4.2"
notes: Deprecated in favor of the `AUDIO_SESSION_CATEGORY` constants defined in <Titanium.Media>.
summary: Session mode for recording (input) and playback (output) of audio, such as for a VOIP (voice over IP) application.
description: |
Expand All @@ -540,15 +540,15 @@ properties:
platforms: [iphone, ipad]
- name: AUDIO_SESSION_MODE_RECORD
deprecated:
since: "3.4.1"
since: "3.4.2"
notes: Deprecated in favor of the `AUDIO_SESSION_CATEGORY` constants defined in <Titanium.Media>.
summary: Session mode for recording audio; it silences playback audio.
type: Number
permission: read-only
platforms: [iphone, ipad]
- name: AUDIO_SESSION_MODE_SOLO_AMBIENT
deprecated:
since: "3.4.1"
since: "3.4.2"
notes: Deprecated in favor of the `AUDIO_SESSION_CATEGORY` constants defined in <Titanium.Media>.
summary: Session mode for long-duration sounds such as rain, car engine noise, and so on.
description: |
Expand Down Expand Up @@ -576,106 +576,106 @@ properties:
type: String
permission: read-only
platforms: [iphone, ipad]
since: "3.4.1"
since: "3.4.2"
- name: AUDIO_SESSION_PORT_BUILTINMIC
summary: Constant for built-in microphone on an iOS device. This is an input port.
type: String
permission: read-only
platforms: [iphone, ipad]
since: "3.4.1"
since: "3.4.2"
- name: AUDIO_SESSION_PORT_HEADSETMIC
summary: Constant for microphone on a wired headset. This is an input port.
type: String
permission: read-only
platforms: [iphone, ipad]
since: "3.4.1"
since: "3.4.2"
- name: AUDIO_SESSION_PORT_LINEOUT
summary: Constant for line level output on a dock connector. This is an output port.
type: String
permission: read-only
platforms: [iphone, ipad]
since: "3.4.1"
since: "3.4.2"
- name: AUDIO_SESSION_PORT_HEADPHONES
summary: Constant for headphone or headset output. This is an output port.
type: String
permission: read-only
platforms: [iphone, ipad]
since: "3.4.1"
since: "3.4.2"
- name: AUDIO_SESSION_PORT_BLUETOOTHA2DP
summary: Constant for output on a Bluetooth A2DP device. This is an output port.
type: String
permission: read-only
platforms: [iphone, ipad]
since: "3.4.1"
since: "3.4.2"
- name: AUDIO_SESSION_PORT_BUILTINRECEIVER
summary: Constant for the speaker you hold to your ear when on a phone call. This is an output port.
type: String
permission: read-only
platforms: [iphone, ipad]
since: "3.4.1"
since: "3.4.2"
- name: AUDIO_SESSION_PORT_BUILTINSPEAKER
summary: Constant for built-in speaker on an iOS device. This is an output port.
type: String
permission: read-only
platforms: [iphone, ipad]
since: "3.4.1"
since: "3.4.2"
- name: AUDIO_SESSION_PORT_HDMI
summary: Constant for output via High-Definition Multimedia Interface. This is an output port
type: String
permission: read-only
platforms: [iphone, ipad]
since: "3.4.1"
since: "3.4.2"
- name: AUDIO_SESSION_PORT_AIRPLAY
summary: Constant for output on a remote Air Play device. This is an output port.
type: String
permission: read-only
platforms: [iphone, ipad]
since: "3.4.1"
since: "3.4.2"
- name: AUDIO_SESSION_PORT_BLUETOOTHHFP
summary: Constant for input or output on a Bluetooth Hands-Free Profile device. This can be both an input and output port.
type: String
permission: read-only
platforms: [iphone, ipad]
since: "3.4.1"
since: "3.4.2"
- name: AUDIO_SESSION_PORT_USBAUDIO
summary: Constant for input or output on a Universal Serial Bus device. This can be both an input and output port.
type: String
permission: read-only
platforms: [iphone, ipad]
since: "3.4.1"
since: "3.4.2"
- name: AUDIO_SESSION_PORT_BLUETOOTHLE
summary: Constant for output on a Bluetooth Low Energy device. This is an output port. This is available on iOS7 and later.
type: String
permission: read-only
platforms: [iphone, ipad]
since: "3.4.1"
since: "3.4.2"
osver: {ios: {min: "7.0"}}
- name: AUDIO_SESSION_PORT_CARAUDIO
summary: Constant for Input or output via Car Audio. This can be both an input and output port. This is available on iOS7 and later.
type: String
permission: read-only
platforms: [iphone, ipad]
since: "3.4.1"
since: "3.4.2"
osver: {ios: {min: "7.0"}}
- name: AUDIO_SPEAKER
deprecated:
since: "3.4.1"
since: "3.4.2"
notes: Deprecated in favor of the `AUDIO_SESSION_PORT` constants defined in <Titanium.Media>.
summary: Line-type constant for speaker output.
type: Number
permission: read-only
platforms: [iphone, ipad]
- name: AUDIO_UNAVAILABLE
deprecated:
since: "3.4.1"
since: "3.4.2"
notes: Deprecated in favor of the `AUDIO_SESSION_PORT` constants defined in <Titanium.Media>.
summary: Line-type constant indicating that audio is unavailable.
type: Number
permission: read-only
platforms: [iphone, ipad]
- name: AUDIO_UNKNOWN
deprecated:
since: "3.4.1"
since: "3.4.2"
notes: Deprecated in favor of the `AUDIO_SESSION_PORT` constants defined in <Titanium.Media>.
summary: Line-type constant indicating that line-type is unknown or not determined.
type: Number
Expand Down Expand Up @@ -1140,7 +1140,7 @@ properties:
permission: read-only
- name: audioLineType
deprecated:
since: "3.4.1"
since: "3.4.2"
notes: Deprecated in favor of [currentRoute](Titanium.Media.currentRoute) property defined in <Titanium.Media>.
summary: Returns the line type constant for the current line type.
type: Number
Expand All @@ -1161,10 +1161,10 @@ properties:
type: Number
constants: Titanium.Media.AUDIO_SESSION_CATEGORY*
platforms: [iphone, ipad]
since: "3.4.1"
since: "3.4.2"
- name: audioSessionMode
deprecated:
since: "3.4.1"
since: "3.4.2"
notes: Deprecated in favor of the [audioSessionCategory](Titanium.Media.audioSessionCategory) property defined in <Titanium.Media>.
summary: A constant for the audio session mode to be used.
description: |
Expand Down Expand Up @@ -1223,7 +1223,7 @@ properties:
Returns a description of the current route, consisting of zero or more input ports and zero or more output ports.
type: RouteDescription
platforms: [iphone, ipad]
since: "3.4.1"
since: "3.4.2"
permission: read-only
- name: isCameraSupported
summary: |
Expand Down Expand Up @@ -1632,7 +1632,7 @@ extends: ErrorResponse
name: RouteDescription
summary: An Object describing the current audio route.
platforms: [iphone, ipad]
since: "3.4.1"
since: "3.4.2"
properties:
- name: inputs
summary: An Array of current input ports for the session. See the `AUDIO_SESSION_PORT` constants.
Expand Down
15 changes: 15 additions & 0 deletions apidoc/Titanium/Network/HTTPClient.yml
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,12 @@ properties:
[LOADING](Titanium.Network.HTTPClient.LOADING),
or [DONE](Titanium.Network.HTTPClient.DONE).

Due to the asynchronous nature of the Titanium platform, the internal value of
[readyState](Titanium.Network.HTTPClient.readyState) might be different from the state change
for which the event was fired. To address this discrepancy, the function is now invoked with a
payload object of type <ReadyStatePayload>. This was introduced in version 3.4.2 of the SDK and is
supported on the iOS and android platforms.

- name: onsendstream
summary: Function to be called at regular intervals as the request data is being transmitted.
description: |
Expand Down Expand Up @@ -645,3 +651,12 @@ description: |

since: 3.3.0
platforms: [iphone, ipad]
---
name: ReadyStatePayload
summary: An Object describing the current ready state. See [onreadystatechange](Titanium.Network.HTTPClient.onreadystatechange) for more information.
platforms: [iphone, ipad, android]
since: "3.4.2"
properties:
- name: readyState
summary: The state for which `onreadystatechange` was invoked. Set to one of `Titanium.Network.HTTPClient` ready-state constants
type: Number