Skip to content

Instantly share code, notes, and snippets.

View rblalock's full-sized avatar
🚀

Rick Blalock rblalock

🚀
View GitHub Profile
var os = require('os').os;
//branch logic based on platform - saves you an if statement
os(function() {
alert('do this on android');
}, function() {
alert('do this on iOS');
});
var platformSpecificValue = os('android string','ios string');
@benbahrenburg
benbahrenburg / app.js
Created July 31, 2011 03:46 — forked from joemaffia/app.js
foursquare OAuth in Titanium
/**
*
*
* Copyright 2011 Aaron K. Saunders, Clearly Innovative Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* <a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a>
@jonalter
jonalter / tiapp.xml
Created September 8, 2011 20:36
Android: splash screen orientation set from tiapp.xml as of Sep 8 2011 11:25 r5be876f7 1.8.0
<android xmlns:android="http://schemas.android.com/apk/res/android">
<manifest>
<supports-screens android:anyDensity="false"/>
<application android:debuggable="true">
<activity android:alwaysRetainTaskState="true"
android:name=".TitestActivity"
android:configChanges="keyboardHidden|orientation"
android:screenOrientation="portrait"
android:theme="@style/Theme.Titanium">
<intent-filter>
@pec1985
pec1985 / app.js
Created September 26, 2011 23:07
Cache Remote Images
var Utils = {
RemoteImage: function(a){
a = a || {};
var md5;
var needsToSave = false;
var savedFile;
if(a.image){
md5 = Ti.Utils.md5HexDigest(a.image)+'.jpg';
savedFile = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory,md5);
if(savedFile.exists()){
@dawsontoth
dawsontoth / app.js
Created October 10, 2011 10:11
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]
*
@pec1985
pec1985 / app.js
Created October 23, 2011 09:20
Pull to Refresh in android, plus a demo
/*
Copyright 2011 Pedro Enrique
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
// Here is a proposal for minimalist JavaScript classes, humbly offered.
// There are (at least) two different directions in which classes can be steered.
// If we go for a wholly new semantics and implementation, then fancier classical
// inheritance can be supported with parallel prototype chains for true inheritance
// of properties at both the class and instance level.
// If however, we keep current JavaScript prototype semantics, and add a form that
// can desugar to ES3, things must necessarily stay simpler. This is the direction
// I'm assuming here.
//Wrapper class to create extensible Titanium components
exports.Component = function(/*Object*/ tiView) {
var self = {
__viewProxy:tiView
};
//passthrough for add
self.add = function(/*Object*/ tiChildView) {
var v = tiChildView.__viewProxy||tiChildView;
self.__viewProxy.add(v);
@jonalter
jonalter / app.js
Created December 20, 2011 21:39
iOS: drag and drop using convertPointToView
var win = Ti.UI.createWindow({
masterWindow: true,
backgroundColor: 'white'
});
var view1 = Ti.UI.createView({
top : 20,
left : 20,
height : 100,
width : 100,
@benbahrenburg
benbahrenburg / gist:1515352
Created December 23, 2011 21:04
Titanium : How to find the Private Directory
function privateDocumentsDirectory(){
Ti.API.info('We need to open a file object to get our directory info');
var testFile = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory);
Ti.API.info('Now we remove the Documents folder reference');
var privateDir = testFile.nativePath.replace('Documents/','');
Ti.API.info('This is our base App Directory =' + privateDir);
Ti.API.info('Now we add the Private Documents Directory');
privateDir+='Library/Private%20Documents/';
Ti.API.info('Our new path is ' + privateDir);