Skip to content

Instantly share code, notes, and snippets.

@skypanther
skypanther / app.js
Created September 1, 2011 21:48
Draw gridlines in a Titanium window
// implement like this:
var window = Ti.UI.createWindow({
backgroundColor:'#fff'
});
// draw the gridlines first so your other elements stack on top of them
// without requiring you to set the z-index property of each
var grid = require('gridlines');
grid.drawgrid(10,window);
function createNotification() {
var mainIntent = Titanium.Android.createIntent({
className: 'org.appcelerator.titanium.TiActivity',
packageName: 'com.appcelerator.foo'
});
var pending = Titanium.Android.createPendingIntent({
activity: Titanium.Android.currentActivity,
intent: mainIntent,
@skypanther
skypanther / app.js
Created December 2, 2011 19:49
Titanium Mobile helper module for determining whether you're on a tablet or phone
// this sets the background color of the master UIView (when there are no windows/tab groups on it)
Titanium.UI.setBackgroundColor('#000');
// create tab group
var tabGroup = Titanium.UI.createTabGroup();
//
// create base UI tab and root window
//
@skypanther
skypanther / logger.js
Created January 21, 2012 00:23 — forked from pec1985/app.js
console.log - appcelerator
/*
Custom logger
// usage
var console = require('/logger');
console.log({sdf:"df"}, [1,3,5,6], "sdfsdf");
*/
exports.log = function() {
if(Ti.App.Properties.getBool('production')==false) {
@skypanther
skypanther / app.js
Created February 24, 2012 15:46 — forked from pec1985/app.js
Cache Remote Images
var Utils = {
/* modified version of https://gist.github.com/1243697
* adds detection of file extension rather than hard-coding .jpg as in the original
*/
_getExtension: function(fn) {
// from http://stackoverflow.com/a/680982/292947
var re = /(?:\.([^.]+))?$/;
var tmpext = re.exec(fn)[1];
return (tmpext) ? tmpext : '';
},
@skypanther
skypanther / app.js
Created June 27, 2012 18:44
Titanium 2.1 changes demo
// tested on Titanium 2.1.0.v20120621224153 on iOS and Android 2.2
// this sets the background color of the master UIView (when there are no windows/tab groups on it)
Titanium.UI.setBackgroundColor('#000');
// create tab group
var tabGroup = Titanium.UI.createTabGroup();
//
@skypanther
skypanther / AndroidManifest.xml
Created October 12, 2012 18:50
Android 4 theme and menu
<?xml version="1.0" ?><manifest android:versionCode="1" android:versionName="1" package="com.appcelerator.holotheme" xmlns:android="http://schemas.android.com/apk/res/android">
<uses-sdk android:minSdkVersion="8"/>
<uses-sdk android:targetSdkVersion="14"/>
<!-- TI_MANIFEST -->
<application android:debuggable="false" android:icon="@drawable/appicon" android:label="HoloTheme" android:name="HolothemeApplication" android:theme="@android:style/Theme.Holo.Light">
<!-- TI_APPLICATION -->
@skypanther
skypanther / Source_app_index.js
Last active December 14, 2015 22:59
Custom URL Schemes: Tap a button in the "Source" app and have it open "Target" Works in iOS and Android. For the Target app's manifest, you'll need to create a PROJECT_DIR/platform/android folder and put the file in there. This is an Alloy-based demo, tested on Titanium 3.0.0.GA.
function doClick(e) {
if(OS_IOS) {
if(Ti.Platform.canOpenURL('Urlschemes://')) {
Ti.Platform.openURL('Urlschemes://');
} else {
alert('You must install the Urlschemes app first');
}
} else {
var didItWork = Ti.Platform.openURL('urlschemes://');
if(!didItWork) {
@skypanther
skypanther / index.js
Created April 9, 2013 20:35
URLSchemes handling code for TCE lab
function urlParser(url) {
url = url.replace(/[Uu]rlschemes:\/\/\?/,"");
return url.split('&');
}
// check for arguments passed to this app
if(OS_IOS) {
function grabArguments() {
var args = Ti.App.getArguments();
if(args.url) {
@skypanther
skypanther / example_usage.js
Created April 23, 2013 18:18
Split window-like CommonJS component for Titanium
// define your leftView and rightView content views here...
var Win = require('ui/components/splitwindow'),
win = new Win({
splitWidth: 300,
masterTitle: 'Master',
detailTitle: 'Details',
navBarHidden: true,
backgroundColor: 'transparent',
}, leftView, rightView);
win.open();