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 November 3, 2011 05:55
iOS: hide/show statusBar
// by Alan Leard
var win = Ti.UI.createWindow({ backgroundColor: '#000' });
var hide = false;
win.addEventListener('click', function(){
if(hide){
Titanium.UI.iPhone.showStatusBar({animated:true, animationStyle:
Titanium.UI.iPhone.StatusBar.ANIMATION_STYLE_FADE});
hide = false;
} else {
Titanium.UI.iPhone.hideStatusBar({animated:true, animationStyle:
@jonalter
jonalter / app.js
Created October 6, 2011 22:32
Android: download pdf and save it to the sdcard
var win = Ti.UI.createWindow({
navBarHidden: true,
backgroundColor: 'blue'
});
win.open();
var button = Ti.UI.createButton({
title: 'Get PDF',
height: 50,
width: 200,
@jonalter
jonalter / app.js
Created October 4, 2011 16:39
Android/iOS: testing setRequestHeader
var win = Ti.UI.createWindow({
backgroundColor : 'white',
fullscreen : true
});
var button = Ti.UI.createButton({
title : 'test',
height : 60,
width : 200
});
win.add(button);
@jonalter
jonalter / app.js
Created October 3, 2011 19:55
Test setRequestHeader
var win = Ti.UI.createWindow({
backgroundColor : 'white',
fullscreen : true
});
var button = Ti.UI.createButton({
title : 'test',
height : 60,
width : 200
});
win.add(button);
@jonalter
jonalter / get_number_of_likes.js
Created October 3, 2011 17:06
Facebook: likes
Titanium.Facebook.requestWithGraphPath('OBJECT_ID', {}, 'GET', function(e) {
if (e.success) {
alert(e.result);
} else {
return -1;
}
});
@jonalter
jonalter / ExampleService.js
Created October 3, 2011 02:29
Android: delayed/future notification that will launch the app
if(!Ti.App.Properties.hasProperty('notificationCount')) {
Ti.App.Properties.setInt('notificationCount', 0);
} else {
Ti.App.Properties.removeProperty('notificationCount');
var activity = Ti.Android.currentActivity();
var intent = Ti.Android.createIntent({
action : Ti.Android.ACTION_MAIN,
// you can use className or url to launch the app
// className can be found by looking in the build folder
@jonalter
jonalter / app.js
Created October 2, 2011 22:48
Android: notification that will launch app
var win = Titanium.UI.createWindow({
backgroundColor: 'blue'
});
var btn = Ti.UI.createButton({
title : 'Add Notification'
});
btn.addEventListener('click', function(e) {
var activity = Ti.Android.currentActivity();
@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();
@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 / 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