Skip to content

Instantly share code, notes, and snippets.

View ricardoalcocer's full-sized avatar
💭
making music at https://alcomusic.com

Alco ricardoalcocer

💭
making music at https://alcomusic.com
View GitHub Profile
/*
Developed by Kevin L. Hopkins (http://kevin.h-pk-ns.com)
You may borrow, steal, use this in any way you feel necessary but please
leave attribution to me as the source. If you feel especially grateful,
give me a linkback from your blog, a shoutout @Devneck on Twitter, or
my company profile @ http://wearefound.com.
/* Expects parameters of the directory name you wish to save it under, the url of the remote image,
and the Image View Object its being assigned to. */
cachedImageView = function(imageDirectoryName, url, imageViewObject)
@iskugor
iskugor / AndroidManifest.xml
Created January 9, 2012 12:35
Android hardware accelerator & tabs width
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.adriatic.test" android:versionCode="1"
android:versionName="1">
<uses-sdk android:minSdkVersion="11" />
<!-- TI_MANIFEST -->
<application android:icon="@drawable/appicon"
android:label="Test Application" android:name="TestApplication"
@rblalock
rblalock / swipe.js
Last active December 14, 2015 00:59
// Custom swipe detection for table rows (since technically the "swipe"
// event doesn't apply to individual rows but rather the table. This way we
// don't have to assign a swipe event for each row. One event to manage
// them all is more performant.
var TOUCH_X = 0;
$.list.addEventListener("touchstart", function(e) {
TOUCH_X = e.x;
});
$.list.addEventListener("touchend", function(e) {
if(e.x > (TOUCH_X + 44)) {
@rblalock
rblalock / index.js
Last active December 15, 2015 09:28
/**
* Helper for opening / animating sidebar
*/
$.openSidebar = function() {
if(isOpen) {
var animateRight = Ti.UI.createAnimation({
left : 0,
curve : Ti.UI.ANIMATION_CURVE_EASE_OUT,
duration : 200
});
@FokkeZB
FokkeZB / app.js
Last active December 16, 2015 12:28
CommonJS module to spin a view in Titanium
var v = Ti.UI.createView();
var s = new require('spinner').Spinner(
v, // View to spin
30 // Degrees to spin per millisecond
); // Auto-starts
// Stop
s.stop();
@timanrebel
timanrebel / index.js
Created June 5, 2013 16:03
Did you know it is possible to create custom XML tags in Alloy and use them?
// <<MyElement> becomes Ti.UI.createMyElement, so that doesn't work
Ti.UI.createMyElement({
id: 'myId'
});
// But give it a namespace and all of a sudden, it is translated to:
Sc.UI.createMySecondElement({
id: 'mySecondId'
})
@tonylukasavage
tonylukasavage / .bash_profile
Last active December 18, 2015 08:49
Shell script to create a new Titanium project, make it Alloy, and load it up in Sublime Text
# Here's how to add it to a shell profile
tialloy() {
ti create --id com.testing.$1 --name $1 --workspace-dir . --platforms \
android,blackberry,ios,ipad,iphone,mobileweb,tizen --no-prompt && \
cd $1 && alloy new . && subl .
}
@mauropm
mauropm / app.js
Created July 4, 2013 00:22
An example of generic app with different actions according to the button. It's showing how to manage the destruction of the window after you use it, and other nice things. To use: Create a new classic mobile project in Titanium Studio, and copy all this files to Resources directory. This is intended to work with Titanium Mobile SDK 3.1.1.GA, wit…
// INcluding memory management utils.
Ti.include('utils.js');
// root window.
var win = Ti.UI.createWindow({
backgroundColor:'white',
exitOnclose:true,
});
@tsteur
tsteur / alloy.jmk
Created July 15, 2013 22:12
Simple build configuration file for Titanium Mobile Alloy. It extends the destroy method of each controller to automatically remove all event listeners which are defined in the view (XML).
function readContentFromFile(file)
{
return require('fs').readFileSync(file).toString();
}
function writeContentToFile(file, content)
{
require('fs').writeFileSync(file, content);
}
@benbahrenburg
benbahrenburg / AddingFetchToSDK.md
Last active August 13, 2016 17:28
This gist outlines an approach for adding the fetch background mode to Titanium

This document details how to add the background mode of fetch into the Titanium SDK. It is important to note that once these updates are performed you will be able to attach a listener to be called when the fetch background mode is triggered.

After the below updates are made, you can clear your Titanium project and run this sample app.js to view how it works.

TiBase.h and TiBase.m updates

The first step in adding the fetch background mode is to create the const values that will later be used when adding or listening to notification center.

To do this first open the TiBase.h file and add the const of