[TIMOB-4877] Android: activityIndicator does not show in app.js without setTimeout
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Trivial |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2017-07-10T22:04:20.000+0000 |
Affected Version/s | Release 1.7.2 |
Fix Version/s | n/a |
Components | Android |
Labels | tbs-1.9.0 |
Reporter | Jon Alter |
Assignee | Eric Merriman |
Created | 2011-08-03T09:55:27.000+0000 |
Updated | 2017-07-10T22:04:29.000+0000 |
Description
In the code below, you will never see the activity indicator if you do not use setTimeout
Step 1: run the code below
Step 2: notice that you do not see an activity indicator or the blue window
Step 3: uncomment the setTimeout
Step 4: run the app again
Step 5: notice that the activity indicator and blue window show as expected.
var win = Ti.UI.createWindow({
backgroundColor: 'blue'
});
var actInd = Titanium.UI.createActivityIndicator({
bottom:100,
height:50,
width:10,
style:Titanium.UI.iPhone.ActivityIndicatorStyle.PLAIN,
font: {fontFamily:'Helvetica Neue', fontSize:15,fontWeight:'bold'},
color: 'white',
message: 'Loading...',
width: 210
});
var loadingWin = Ti.UI.createWindow({
backgroundImage: Ti.Platform.name == 'iPhone OS' ? 'Default.png':'default.png' ,
fullscreen: true
});
loadingWin.open();
loadingWin.add(actInd);
actInd.show();
// setTimeout(function(){
for(var i = 0; i<3000; i++){
Ti.API.info(i);
}
loadingWin.close();
actInd.hide();
win.open();
// },0);
Not much we can do here since it's an issue with JS multithreading. I would use the workaround as you suggested with setTimeout() or add an event listener for the 'open' event like:
Closing ticket due to time passed and lack of progress for a number of years. Please open a new ticket if there are any problems.