Skip to content

Instantly share code, notes, and snippets.

View jonalter's full-sized avatar

Jonathan Alter jonalter

View GitHub Profile
@jonalter
jonalter / app.js
Created September 13, 2011 16:57
Android: back button finish activities and exit app
Titanium.UI.setBackgroundColor('#000');
var windows = [];
//
// create base UI tab and root window
//
var win1 = Titanium.UI.createWindow({
title : 'Tab 1',
backgroundColor : '#fff',
exitOnClose : true
});
@jonalter
jonalter / app.js
Created September 14, 2011 00:07
Android: open pdf with external pdf reader
// Must have a pdf reader app installed, maybe Adobe Reader, maybe something else
var win = Ti.UI.createWindow({
navBarHidden: true,
backgroundColor: 'blue'
});
win.open();
var button = Ti.UI.createButton({
title: 'Get PDF',
height: 50,
@jonalter
jonalter / app.js
Created September 14, 2011 16:01
BlackBerry: 1.7.0.RC2 appending complex rows to a tableView
var win = Ti.UI.createWindow();
var data = [];
for (var i = 0; i < 10; i++) {
data.push({title:'I am row text '+i });
}
var tableView = Ti.UI.createTableView({
data:data
});
tableView.setCreateCallback(function(e) {
@jonalter
jonalter / app.js
Created September 15, 2011 22:43
iOS: open window on orientation change to landscape
// Must use TiSDK 1.8.0.v20110915133349 or newer
var tabGroup = Ti.UI.createTabGroup();
var win1 = Ti.UI.createWindow({
backgroundColor : 'white',
orientationModes : [Ti.UI.PORTRAIT]
});
var label1 = Ti.UI.createLabel({
text : 'I am a label'
});
win1.add(label1);
@jonalter
jonalter / app.js
Created September 16, 2011 17:04
iOS: using videoPlayer to play remote content
var win = Ti.UI.createWindow({
backgroundColor : 'black',
orientationModes : [Ti.UI.PORTRAIT]
});
win.open();
var activeVideo = Titanium.Media.createVideoPlayer({
top : 0,
height : 200
});
win.add(activeVideo);
@jonalter
jonalter / app.js
Created September 22, 2011 00:05
iOS: disable snapshot from being taken when app backgrounded (for security reasons)
// by Blain Hamon
var win = Ti.UI.createWindow({
backgroundColor : 'white',
orientationModes : [Ti.UI.PORTRAIT]
});
win.open();
var label = Ti.UI.createLabel({
text : 'No app event received. Make call while running app',
textAlign : 'center',
@jonalter
jonalter / app.js
Created September 22, 2011 16:30
Android: open url in browser via intent
var win = Ti.UI.createWindow({
backgroundColor : 'white'
});
win.open();
win.addEventListener('click', function(e) {
var intent = Ti.Android.createIntent({
action : Ti.Android.ACTION_VIEW,
data : "https://www.google.com/"
@jonalter
jonalter / app.js
Created September 22, 2011 19:01
iOS/Android: read the bytes of a file
var win = Ti.UI.createWindow({
backgroundColor : 'white'
});
win.open();
var button = Ti.UI.createButton({
title : "Click me!",
height : 50,
width : 200,
top : 100
@jonalter
jonalter / app.js
Created September 29, 2011 20:56
Android: window orientation example for 1.8.x
var win1 = Titanium.UI.createWindow({
title : 'Tab 1',
backgroundColor : '#fff',
fullscreen: true,
});
// orientationModes needs to be set after the createWindow
win1.orientationModes = [Ti.UI.PORTRAIT];
var b1 = Titanium.UI.createButton({
title : 'Win 2',
@jonalter
jonalter / Will-not-release.js
Created September 30, 2011 21:25
Memory Management Example
// GLOBAL SCOPE
var win = Ti.UI.createWindow();
var parentView = Ti.UI.createView();
var childView = Ti.UI.createView();
parentView.add(childView);
win.add(parentView);
win.open();