This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void handleBitmap(Bitmap image) { | |
int w = image.getWidth(), h = image.getHeight(); | |
int[] rgb = new int[w * h]; | |
byte[] yuv = new byte[w * h]; | |
image.getPixels(rgb, 0, w, 0, 0, w, h); | |
populateYUVLuminanceFromRGB(rgb, yuv, w, h); | |
} | |
// Inspired in large part by: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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] | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var win = Ti.UI.createWindow({ | |
backgroundColor: '#fff' | |
}); | |
var table = Ti.UI.createTableView({ | |
bottom: 50 | |
}); | |
win.add(table); | |
var startTime = new Date().getTime(), startMemory = Ti.Platform.availableMemory; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var deferredExecutionQueue = []; | |
function deferExecution(func, delayMS) { | |
deferredExecutionQueue.push({ func: func, time: new Date().getTime() + delayMS }); | |
} | |
setInterval(function() { | |
if (!deferredExecutionQueue.length) | |
return; | |
if (deferredExecutionQueue[0].time < new Date().getTime()) { | |
var deferred = deferredExecutionQueue.pop(); | |
deferred.func(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Creates an image view using Google's QR Code generator. | |
* @param text The text to be encoded in the QR code | |
* @param size The size of the QR code; Possible Sizes: 100x100, 150x150, 200x200, 250x250, 300x300, 350x350, 400x400, 500x500 | |
*/ | |
function createQRCodeImageView(text, size) { | |
var url = 'http://chart.apis.google.com/chart?cht=qr&chs=' + size + '&chl=' + encodeURI(text) + '&chld=H|0'; | |
var width = size.split('x')[0], height = size.split('x')[1]; | |
if (Ti.Android) { | |
width += 'dp'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Appcelerator Titanium Mobile | |
* Copyright (c) 2009-2010 by Appcelerator, Inc. All Rights Reserved. | |
*/ | |
package ti.modules.titanium.paypal; | |
import java.math.BigDecimal; | |
import org.appcelerator.kroll.KrollDict; | |
import org.appcelerator.titanium.proxy.TiViewProxy; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* The following snippet will ask the user to rate your app the second time they launch it. | |
* It lets the user rate it now, "Remind Me Later" or never rate the app. | |
*/ | |
var win = Ti.UI.createWindow({ backgroundColor: '#fff' }); | |
win.addEventListener('open', checkReminderToRate); | |
win.add(Ti.UI.createLabel({ text: 'This is a simple app that will remind you to rate it.' })); | |
win.open(); | |
function checkReminderToRate() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | |
<ti:app xmlns:ti="http://ti.appcelerator.org"> | |
... | |
<android xmlns:android="http://schemas.android.com/apk/res/android"> | |
<manifest android:versionCode="1" android:versionName="1.0"> | |
<supports-screens | |
android:smallScreens="false" | |
android:normalScreens="true" | |
android:largeScreens="false" | |
android:anyDensity="false"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* The images for this example can be downloaded from http://j.mp/loadingimagesforti */ | |
var win = Ti.UI.createWindow({ backgroundColor: '#f00'}); | |
var loading = Ti.UI.createImageView({ | |
images: [ | |
'images/loading/00.png', 'images/loading/01.png', 'images/loading/02.png', | |
'images/loading/03.png', 'images/loading/04.png', 'images/loading/05.png', | |
'images/loading/06.png', 'images/loading/08.png', 'images/loading/09.png', | |
'images/loading/10.png', 'images/loading/11.png' | |
], | |
width: 33, height: 33 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) { |