Skip to content

Instantly share code, notes, and snippets.

var win = Titanium.UI.currentWindow;
var xhr;
Ti.App.globalImage = null;
function alert(title,message){
var alertDialog = Titanium.UI.createAlertDialog({
title: title,
message: message,
buttonNames: ['OK']
Module developer creates a module
They wish to create a single module but have enhanced API functionality for 2.1+ because they depend on some API features only available on that platform. The API they are using also may have changed between platform versions (think Android contacts).
For users of the 1.6 module - they will have reduced functionality but broader reach.
Option (1)
They release 2 differently named modules and the module consumer has to download/buy both
Option (2)
Use a folder structure for modules that differentiate based on platform.
// Create the xhr object
var xhr = Titanium.Network.createHTTPClient();
// Set the static properties on the xhr object
xhr.setTimeout(20000);
// Helper for updating the interface
function networkUpdateSuccess() {
alert('Success Uploaded',Ti.App.globalImage);
var updatePeriod = 5 * 60 * 1000; //mins * seconds * 1000
var locationUpdateEnabled = false;
// This gets fired when the webView has loaded.
// Rather than using the generic event of the webview
// - it's more reliable to create your own and have the page itself trigger when it's ready
// - This allows your code to initialise things properly before asking for update
Ti.App..addEventListener('pageReadyForUpdates', function(e) {
// This will only get fired once and when the page itself is ready to start receiving update
Titanium.UI.setBackgroundColor('#000');
// Create a window
var win = Titanium.UI.createWindow({
title:'Web Test',
backgroundColor:'#fff'
});
// and now a webView
var webview1 = Titanium.UI.createWebView({url:'somePage.html'});
// create table view data object
var data = [];
for (var c=0;c<10;c++)
{
data[c] = Ti.UI.createTableViewSection({headerTitle:'Group '+(c+1)});
for (var x=0;x<40;x++)
{
var label = Ti.UI.createLabel({
text:'Group '+(c+1)+', Row '+(x+1)+"\nThis is another line.\nCool",
// Simple debug output helper
function debug(message) {
Ti.API.info(message);
}
/**
*
* @param thisControl The control you wish to dump
* @param goDeep boolean Do you want deep introspection
* @param incFuncs boolean Do you want to include functions in the output when going deep
var currentData = new Array();
var requestAgain = true;
var xhr = Titanium.Network.createHTTPClient();
var returnedData;
var timeDelay = (2 * 60 * 1000); // 2 mins * 60 seconds * 1000 milliseconds
// Setup our event handlers
xhr.onload = function() {
// This gets first one receipt of the data
returnedData = this.responseText;
// Let's make a funky Window
var win = Titanium.UI.createWindow({
backgroundColor:'#F00',
left: 0,
top: 0,
zIndex: 0
});
//
// Paypal Button
// this sets the background color of the master UIView (when there are no windows/tab groups on it)
Titanium.UI.setBackgroundColor('#000');
//
// create root window
var win = Titanium.UI.createWindow({
backgroundColor:'#F00',
left: 0,
top: 0,
zIndex: 0