Skip to content

Instantly share code, notes, and snippets.

View alanleard's full-sized avatar

Alan Leard alanleard

View GitHub Profile
@alanleard
alanleard / app.js
Created August 2, 2012 19:05
Scroll Image
var lImageView = Ti.UI.createScrollView({
height:labelSize.height,
width:labelSize.width,
contentHeight:'auto',
contentWidth:'auto',
minZoomScale:0.05,
maxZoomScale:5.0,
zoomScale:1.0
});
@alanleard
alanleard / app.js
Created December 5, 2012 15:22
Android Local Notification
var intent = Ti.Android.createServiceIntent({url: 'notification.js'});
Ti.Android.stopService(intent);
////*notification.js*////////
Titanium.Android.NotificationManager.notify(
0, // <-- this is an ID that we can use to clear the notification later
Ti.Android.createNotification({
//contentView: customView,
@alanleard
alanleard / app.js
Created December 6, 2012 19:50
Infinite Remote ImageView Scrollable
/*
Recognized parameters:
imageListURL - string (URL to JSON array of image names, if not available, imageList will be used)
imageList - array (array of image names to be added to imageURL, not used if imageListURL present)
imageURL - string (base url of images)
defaultImage - string (preventDefaultImage set if not used)
scrollable - object (pass in your own scrollableView)
scrollProps - object (pass in your own scrollable properties)
Sample Usage:
@alanleard
alanleard / app.js
Created December 12, 2012 19:09
mimic iOS switch
var win = Ti.UI.createWindow();
var switchContainer = Ti.UI.createView({
width:100,
height:40,
borderRadius:10,
backgroundColor:'gray'
});
var switchLabelYes = Ti.UI.createLabel({
@alanleard
alanleard / app.js
Created January 16, 2013 19:03
Android Vertical Slider
var win = Ti.UI.createWindow();
var container = Ti.UI.createView({
height:260,
width:30
})
var slider = Ti.UI.createView({
height:200,
width:20,
@alanleard
alanleard / app.js
Created January 23, 2013 20:56
simple calendar link for iOS
var text = Ti.UI.createTextArea({
value:'Event: Jan 25, 2012 at 5:00pm',
autoLink: Ti.UI.iOS.AUTODETECT_CALENDAR,
top:100,
enabled:false,
font:{fontSize:16}
});
var win = Ti.UI.createWindow({backgroundColor:'#fff'});
@alanleard
alanleard / index.php
Created January 30, 2013 18:56
Mobile App PHP redirect
<?php
$ua = strtolower($_SERVER['HTTP_USER_AGENT']);
if(stripos($ua,'android') !== false) { // && stripos($ua,'mobile') !== false) {
header('Location: https://MyAndroidAppURL');
exit();
} else if(strstr($_SERVER['HTTP_USER_AGENT'],'iPhone') || strstr($_SERVER['HTTP_USER_AGENT'],'iPod') || strstr($_SERVER['HTTP_USER_AGENT'],'iPad'))
{
header('Location: http://MyiTunesAppURL');
exit();
} else {
@alanleard
alanleard / app.js
Last active July 19, 2016 13:21
Understanding how backgroundLeftCap and backgroundTopCap work in Titanium
//This is a demo to show how backgroundLeftCap and backgroundTopCap work on the Tianium platform by Appcelerator
//Paste this code in app.js (tested on iOS)
//Screenshot: http://screencast.com/t/txWQD3l2UBN
///////////////////////////////////////////////////////////////////////////////
//Just modify these variables to see how backgroundLeftCap and topCap will work
var topCap = 20;
var leftCap = 35;
var originalImageSize = {height:100, width:100}
@alanleard
alanleard / app.js
Created February 4, 2013 22:54
Very simple drag and drop example
var win = Ti.UI.createWindow({
backgroundColor: '#333'
});
var box = Ti.UI.createView({
backgroundColor:'blue',
center:{x:50,y:50},
height:40,
width:40
});
@alanleard
alanleard / app.js
Last active December 12, 2015 08:08
Map annotation selected image
var win = Ti.UI.createWindow();
var pinImage = 'map-pin.png';
var selectedPinImage = 'map-pin-selected.png';
var pin1 = Titanium.Map.createAnnotation({
latitude:37.390749,
longitude:-122.081651,
title:"Appcelerator Headquarters",
subtitle:'Mountain View, CA',