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 is a hack solves the "Invalid method passed to UIModule" error | |
* It works by forcing Titanium to load SDK components into memory. | |
* | |
* Drop this file anywhere in your project and DON'T Ti.include() it. | |
* Be sure this file extension is .js. | |
* Clean and recompile your project. | |
* | |
* Enjoy! | |
* @tzmartin |
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
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); |
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
function fetchDbFile(dbName){ | |
Ti.API.info('We build the directory path to find ' + dbName + '.sql'); | |
return Ti.Filesystem.getFile(Ti.Filesystem.applicationSupportDirectory, 'database', dbName + '.sql'); | |
}; | |
var myDbName = 'foo123'; | |
Ti.API.info('We create a db to test our method') | |
var testDb = Ti.Database.open(myDbName); | |
Ti.API.info('No we get the file') | |
var dbFile = fetchDbFile(myDbName); |
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 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 | |
// |
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 is a test case showing how the Android menu | |
// no longer works as excepted when using a function return | |
// similar to how you would return a window from a commonJS module | |
// | |
// To cover all test cases please update the | |
// useApproach variable with a number between 1 and 4 | |
// This will return each of the examples as outlined | |
// in another Jira ticket located here http://jira.appcelerator.org/browse/TIMOB-6648 | |
// |
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
exports.AppTabGroup = function() { | |
//Thanks Kevin Whinnery for the sample | |
//https://github.com/appcelerator-developer-relations/Forging-Titanium/blob/master/ep-006 | |
var instance = Ti.UI.createTabGroup(); | |
//loop through tab objects and add them to the tab group | |
for (var i = 0, l = arguments.length; i < l; i++) { | |
var tab = Ti.UI.createTab(arguments[i]); | |
//on initialization, we track the current tab as the first one added | |
if (i === 0) { |
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
Ti.API.info("Create a new Carrier Info Object"); | |
var carrierInfo = benCodingNetwork.createCarrierInfo(); | |
Ti.API.info("Get carrier name => " + carrierInfo.carrierName); | |
Ti.API.info("Get mobile country code => " + carrierInfo.mobileCountryCode); | |
Ti.API.info("Get mobile network code => " + carrierInfo.mobileNetworkCode); | |
Ti.API.info("Get ISO country code for cellular service provider => " + carrierInfo.isoCountryCode); | |
Ti.API.info("Mobile service provider supports VOIP => " + carrierInfo.allowsVOIP); |
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
//Setup our app namespace | |
var my={}; | |
//Bring in our helpers | |
my.helpers=require('helpers'); | |
//Bring in our custom UI elements | |
my.uiHelpers=require('ui_helper'); | |
//Bring in our fake modules | |
my.mod=require('some_mod'); | |
//Let's get a window | |
my.win=my.mod.fetchWindow(); |
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 test2 = require('test').netTest(); |
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 file located in /Library/Application Support/Titanium/mobilesdk/osx/{version_number} | |
// add the following methods to GeolocationModule.mm | |
- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region | |
{ | |
NSDictionary *event = [NSDictionary dictionaryWithObjectsAndKeys:NUMBOOL(YES),@"success",[NSDictionary dictionaryWithObjectsAndKeys:NUMDOUBLE(region.center.latitude),@"lat",NUMDOUBLE(region.center.longitude),@"lng",NUMDOUBLE(region.radius),@"radius",region.identifier,@"identifier",nil],@"region",nil]; | |
if ([self _hasListeners:@"enteredRegion"]) | |
{ | |
[self fireEvent:@"enteredRegion" withObject:event]; |