[TIMOB-8889] Android: android:back event does not get fired from activity indicator
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2012-06-18T18:16:45.000+0000 |
Affected Version/s | Release 2.0.0 |
Fix Version/s | n/a |
Components | Android |
Labels | api |
Reporter | Allen Yeung |
Assignee | Josh Roesslein |
Created | 2012-04-25T15:06:57.000+0000 |
Updated | 2017-03-24T18:10:54.000+0000 |
Description
Repro steps:
1. Run the code below
2. hit back while the activity indicator is running
Expected result:
You should see 'back!!!!!!!' in the logs
Actual result:
The event is never fired.
Note, I tried adding the listener to the win1, win2, and activityIndicator with the same results.
Ti.UI.backgroundColor = 'white';
var win1 = Ti.UI.createWindow({
backgroundColor: 'blue'
});
var win2 = Ti.UI.createWindow({
backgroundColor: 'yellow',
fullscreen: true
});
var activityIndicator = Ti.UI.createActivityIndicator({
color: 'green',
font: {fontFamily:'Helvetica Neue', fontSize:26, fontWeight:'bold'},
message: 'Loading...',
style:Ti.UI.iPhone.ActivityIndicatorStyle.DARK,
top:10,
left:10,
height:'auto',
width:'auto'
});
// On iOS, the activity indicator must be added to a window or view for it to appear
if (Ti.Platform.name === 'iPhone OS'){
win2.add(activityIndicator);
}
// eventListeners must always be loaded before the event is likely to fire
// hence, the open() method must be positioned before the window is opened
win2.addEventListener('open', function (e) {
activityIndicator.show();
// do some work that takes 6 seconds
// ie. replace the following setTimeout block with your code
setTimeout(function(){
win2.close();
activityIndicator.hide();
}, 6000);
});
activityIndicator.addEventListener('android:back', function(){
Ti.API.info('back!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!');
});
win1.open();
win2.open();
Proposed solution: Expose a "cancel" event on the ActivityIndicator proxy. For Android this will be fired when the back button is pressed. Indicator dialog will be hidden before the event is fired. This is only enabled when the property "cancelable" is true (false by default). Bonus: Android also supports cancelling via a touch outside the dialog. Could expose this as another property (ex: cancelOnTouch). Example:
Would this satisfy your use case and solve the issue?
Looks like this will only be an Android API since iOS and Mobile Web don't use modal dialogs for the activity indicator.
Resolved by PR #2118
The customer is on 1.8.2. Can the fix be backported to support 1.8.2. Customer delivery date is 5/11.
@Eric - We are not porting new features back to older releases. This issue was resolved by implementing a new feature so we cannot put it in 1.8.X branch.
This still occurs with SDK 2.1.0.v20120618102300 on a Droid running 2.2.3.
We won't fix the unsupported/undocumented behavior this test case describes here. Instead we implemented the API/feature in TIMOB-8954 to satisfy the customer's use case.
Closing ticket as invalid with reference to the above comments.