Last active
November 20, 2019 16:37
-
-
Save exclusiveTanim/063eaf6e1e48a3eb65ed7c609047b870 to your computer and use it in GitHub Desktop.
createActivityIndicator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ti.UI.backgroundColor = 'white'; | |
var win1 = Ti.UI.createWindow({ | |
backgroundColor : 'white' | |
}); | |
var win2 = Ti.UI.createWindow({ | |
backgroundColor : 'yellow' | |
}); | |
var activityIndicator = Ti.UI.createActivityIndicator({ | |
color : 'green', | |
message : 'Loading ...', | |
style : Ti.UI.ActivityIndicatorStyle.DARK, | |
top : 100, | |
left : 100, | |
height : Ti.UI.SIZE, | |
width : Ti.UI.SIZE | |
}); | |
// The activity indicator must be added to a window or view for it to appear | |
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() { | |
for (var i=40000; i>0; i--) | |
Ti.API.info("Test: "+i); | |
e.source.close(); | |
activityIndicator.hide(); | |
}, 6000); | |
}); | |
win1.open(); | |
win2.open(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
win2.addEventListener('open', function(e) { | |
activityIndicator.show(); | |
setTimeout(function() { | |
for (var i=40000; i>0; i--){ | |
Ti.API.info("Test: "+i); | |
} | |
activityIndicator.hide(); | |
e.source.close(); | |
}, 6000); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment