[TIMOB-25687] Android: Picker change listener doesn't work the first time
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2018-02-19T11:30:54.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 7.1.0 |
Components | Android |
Labels | Android, picker |
Reporter | Guillermo Figueras |
Assignee | Yordan Banev |
Created | 2018-01-17T13:15:52.000+0000 |
Updated | 2018-03-02T00:38:11.000+0000 |
Description
The first time a Picker changes, the change event is not fired. The subsequent times everything is fine.
*Test code:*
+View:+
<Alloy>
<Window class="container" onOpen="open" id="requestWindow" title="title">
<ScrollView id="scrollView" showVerticalScrollIndicator="true" >
<View id="infoView" >
<View width="Ti.UI.FILL" height="40dp" >
<Label class="labels" id="typeLabel" text="L('type')" />
<Picker id="pickerType" platform="android" onChange="pickerChange" />
<View bottom="0" width="Titanium.UI.FILL" height="0.5" backgroundColor="#c8c7cc"></View>
</View>
<View width="Ti.UI.FILL" height="40dp" id="halfDayView" >
<Label class="labels" id="halfDayLabel" text="L('halfDay')" />
<Picker id="pickerHalfDay" platform="android" onChange="pickerChange" />
<View bottom="0" width="Titanium.UI.FILL" height="0.5" backgroundColor="#c8c7cc"></View>
</View>
</View>
</ScrollView>
</Window>
</Alloy>
+Controller:+
function open(){
}
var halfDay = [];
halfDay[0]=Ti.UI.createPickerRow({title:L('halfDay')});
halfDay[1]=Ti.UI.createPickerRow({title:L('fullDay')});
var type = [];
loadTypes();
function loadTypes() {
var url = "https://www.google.es";
var xhr = Ti.Network.createHTTPClient({
onload : function(e) {
// var json = JSON.parse(decodeURIComponent(this.responseText));
// var datas = json.datas;
var datas = {
"vac_tipos": [
{
"tipo": "F",
"nombre": "Festivos"
},
{
"tipo": "V",
"nombre": "Vacaciones"
},
{
"tipo": "U",
"nombre": "Puente"
},
{
"tipo": "FF",
"nombre": "Festivo Especial"
},
{
"tipo": "NI",
"nombre": "DIAS Navidad"
}
]
};
for (var i = 0; i < datas.vac_tipos.length; i++)
{
type[i] = Ti.UI.createPickerRow({title: datas.vac_tipos[i].nombre});
}
if (OS_ANDROID)
{
$.pickerType.add(type);
$.pickerType.selectionIndicator = true;
$.pickerHalfDay.add(halfDay);
$.pickerHalfDay.selectionIndicator = true;
}
},
onerror : function(e) {
Ti.API.debug(e.error);
},
timeout : 5000
});
xhr.open("GET", url);
xhr.send();
}
function pickerChange(){
Ti.API.info('Change listener triggered');
}
+Style:+
"Window[platform=android]" : {
windowSoftInputMode: Ti.UI.Android.SOFT_INPUT_STATE_HIDDEN
}
".container": {
backgroundColor:"#DCDCDC",
}
"#scrollView": {
layout: 'vertical'
}
"#infoView" : {
layout: 'vertical',
height: Ti.UI.SIZE
}
".labels" : {
left: "10dp"
}
"Picker[platform=android]" : {
width: "35%",
borderColor: 'black',
borderWidth: '1',
right: "10dp"
}
Hello, I have tested the issue with the same Android version emulator, I wasn't able to reproduce the issue. The change event does fire every time I change the value of picker. Thanks.
@Sharif, I updated the test code. I think the problem has to do with httpclient requests.
Hello [~gfigueras], The issue seems to be reproducible with the updated sample code, The picker change event does not fire on first picker change. On the subsequent change, it does. Moving to TIMOB.
PR: https://github.com/appcelerator/titanium_mobile/pull/9763
FR Passed. Waiting for merge to be enabled.
Verified the fix in SDK 7.1.0.v20180301114750 & 7.2.0.v20180301081409. Closing. Studio Ver: 5.0.0.201712081732 OS Ver: 10.13.2 Xcode Ver: Xcode 9.2 Appc NPM: 4.2.12 Appc CLI: 7.0.2 Daemon Ver: 1.0.1 Ti CLI Ver: 5.0.14 Alloy Ver: 1.11.0 Node Ver: 8.9.1 NPM Ver: 5.5.1 Java Ver: 1.8.0_101 Devices: ⇨ google Nexus 6P — Android 8.0.0 ⇨ google Nexus 5 — Android 6.0.1