Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function handleResponse(e) {
log.args('Ti.Media.openPhotoGallery', e);
if (!e.success) {
return alert(e.error || 'Error #' + e.code);
}
if (e.mediaType !== Ti.Media.MEDIA_TYPE_LIVEPHOTO) {
return alert('This should never happen. We required a Live Photo but somehow you selected something else.');
}
if (!e.livePhoto) {
return alert('This should never happen. If mediaType says you selected a Live Photo it should be there.');
}
$.livePhotoView.livePhoto = e.livePhoto;
// Programmatically triggering playback isn't recommended in any other use case
function calendar(e) {
// The new cross-platform way to check permissions
var hasCalendarPermissions = Ti.Calendar.hasCalendarPermissions();
log.args('Ti.Calendar.hasCalendarPermissions', hasCalendarPermissions);
if (hasCalendarPermissions) {
// We have to actually use a Ti.Calendar method for the permissions to be generated
// FIXME: https://jira.appcelerator.org/browse/TIMOB-19933
log.args('Ti.Calendar.getAllCalendars', Ti.Calendar.getAllCalendars());
return alert('You already have permission.');
}
// On iOS we can get information on the reason why we might not have permission
if (OS_IOS) {
// Map constants to names
var map = {};
map[Ti.Calendar.AUTHORIZATION_AUTHORIZED] = 'AUTHORIZATION_AUTHORIZED';
log.args('Starting unoptimized operations..');
collection.forEach(function(model, n) {
// do something heavy, like creating rows to add to a table
Ti.Platform.createUUID();
$.progressBar.value = progressAsc ? n : (Alloy.CFG.threadOperations - 1 - n);
});
progressAsc = !progressAsc;
progressRunning = false;
log.args('Finished operations..');
}
// OPTIMIZED CODE
// If the switch is on use code optimized for single thread.
// Result will be ~ same if main thread is DISABLED or ENABLED
// because each call to $.progress.value will be either executed inmediately (DISABLED)
// or before the next call to doSomething, which is stacked after it.
// Use Underscore's _.defer()
if (e.index === 1) {
log.args('Starting operations optimized using _.defer() ..');
function doSomething(n) {
Ti.App.iOS.addEventListener('continueactivity', function(e) {
log.args('Ti.App.iOS:continueactivity', e);
// Activate the tab active on the other device
if (e.activityType === 'com.appcelerator.sample.ti520.tab') {
$.index.tabs[e.userInfo.activeTabIndex].active = true;
}
});
function removeDetailsShortcut() {
// Other than in list.js we don't need to check the userInfo.filename
// since we will replace it if we're called from the constructor or it
// is the one we created there and now remove in deletePicture()
appShortcuts.removeDynamicShortcut('details');
log.args('Ti.UI.iOS.ApplicationShortcuts.removeDynamicShortcut', 'details');
}
function onTabSelection(e) {
log.args('Ti.UI.Tab:' + e.type, e);
}
function onPeek(e) {
log.args('Ti.UI.iOS.PreviewContext:peek', e);
}
function onDrag(e) {
log.args('Ti.UI.ListView:' + e.type, e);
}
function logDimensions(e) {
log.args('Ti.App:' + e.type + ' was fired and our dimensions are:', {
'Ti.Platform.displayCaps.platformWidth': Ti.Platform.displayCaps.platformWidth,
'Ti.Platform.displayCaps.platformHeight': Ti.Platform.displayCaps.platformHeight,
'$.index.size.width': $.index.size.width,
'$.index.size.height': $.index.size.height
});
}
function changeKeyboardType(e) {
var keyboardType = 'KEYBOARD_TYPE_' + e.source.labels[e.index].title;
log.args('keyboardType', 'Ti.UI.' + keyboardType);
$.textField.keyboardType = Ti.UI[keyboardType];
$.textField.blur();
}