Skip to content

Instantly share code, notes, and snippets.

View mattapperson's full-sized avatar
🏠
Working from home

Matt Apperson mattapperson

🏠
Working from home
View GitHub Profile
var win = Ti.UI.createWindow();
Titanium.Facebook.appid = "181219095251677";
Titanium.Facebook.permissions = ['publish_stream', 'read_stream', 'offline_access'];
var alertDialog = Titanium.UI.createAlertDialog({
title : 'Facebook',
message : 'You need to login with Facebook',
buttonNames : ['Login Facebook']
});
@mattapperson
mattapperson / app.js
Created August 24, 2011 16:42 — forked from appcdr/app.js
Appcelerator: Facebook photo albums sample app
(function() {
Titanium.Facebook.appid = "134793934930";
Titanium.Facebook.permissions = ['publish_stream', 'read_stream', 'user_photos', 'friends_photos'];
Titanium.Facebook.addEventListener('login', function(e) {
if(e.success) {
getAlbumCovers();
return;
} else if(e.error || e.cancelled) {
@mattapperson
mattapperson / app.js
Created September 7, 2011 15:41 — forked from dawsontoth/app.js
Simple remote on demand image caching.
var iconStore = Ti.Filesystem.applicationDataDirectory + '/CachedRemoteImages';
var dir = Ti.Filesystem.getFile(iconStore);
if (!dir.exists()) {
dir.createDirectory();
}
function cacheRemoteURL(image, imageURL) {
if (imageURL) {
var hashedSource = Ti.Utils.md5HexDigest(imageURL + '') + '.' + imageURL.split('.').pop();
var localIcon = Ti.Filesystem.getFile(iconStore, hashedSource);
if (localIcon.exists()) {
var win = Ti.UI.createWindow({
backgroundColor:'white'
});
// assume win.entryImage looks like this: file:///sdcard/dcim/Camera/tia-833058780.jpg
var f = Ti.Filesystem.getFile('file:///sdcard/DCIM/Camera/maybeoncews.jpg');
var imageView = Titanium.UI.createImageView({
image:f,
height:100,
Ti.include(“/customTabBar/customTabBar.js”);
var tabGroup = createCustomTabGroup();
@mattapperson
mattapperson / app.js
Created October 10, 2011 12:10 — forked from dawsontoth/app.js
iOS Text Field Suggestions in Appcelerator Titanium
/**
* This demonstrates how to show suggestions on a text field using just JavaScript with Appcelerator Titanium.
*
* You will need to download four images to get this to work:
*
* 1) http://dl.dropbox.com/u/16441391/Suggest/bg.png
* 2) http://dl.dropbox.com/u/16441391/Suggest/[email protected]
* 3) http://dl.dropbox.com/u/16441391/Suggest/separator.png
* 4) http://dl.dropbox.com/u/16441391/Suggest/[email protected]
*
var udid = require('ti.udid');
var stored_udid = "old saved UDID string";
if(stored_udid === udid.oldUDID) {
stored_udid = Ti.Platform.id;
//save back to a server or something somewhere
}
var json = require("com.irlgaming.jsondb");
var collection = json.factory("contacts");
collection.save({
nickname:"Jon"
full_name:"John Smith",
email:"[email protected]",
phone:1234567889,
address:"13 Dobney Avenue, Wagga Wagga, NSW, Australia, 2650",
loc:{lat:-35.110, lng:147.377},
timestamp:(new Date()).getTime()
var o = collection.find({name:/smith/i}, {$limit:1, $sort:{timestamp:1}});
var o = collection.find({loc:{$within:[[5, 5], 0.2]}}, {
$sort:{nickname:2}});
for(var i=0; i Ti.API.info(o[i]);
}