Skip to content

Instantly share code, notes, and snippets.

View pietromalerba's full-sized avatar

Pietro Malerba pietromalerba

  • M3
  • Civitanova Marche (MC) - Italy
View GitHub Profile
@pietromalerba
pietromalerba / app.js
Created March 28, 2013 21:54 — forked from dasher/app.js
Titanium.UI.setBackgroundColor('#000');
// Create a window
var win = Titanium.UI.createWindow({
title:'Web Test',
backgroundColor:'#fff'
});
// and now a webView
var webview1 = Titanium.UI.createWebView({url:'somePage.html'});
/*
Bullet Proof window drag
This is the most performant window dragging code
I could come up with. All the example on
developer.appcelerator.com we laggy
Version 2: More contained version
*/
/*
* Copyright (c) 2008 David Crawshaw <[email protected]>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
/**
* This sample lets you record and share video with Appcelerator Titanium on Android.
* REQUIRES THE 1.6.0 RC OF TITANIUM MOBILE SDK
* http://developer.appcelerator.com/blog/2011/02/release-candidate-for-titanium-mobile-1-6-0.html
*/
/**
* First, create our UI. We'll have two buttons: record, and share.
*/
var win = Titanium.UI.createWindow({
@pietromalerba
pietromalerba / Titanium-Record-Video
Last active March 8, 2017 14:17
Titanium Record Video snippet
var btnCamera = Ti.UI.createButton({
title: 'Record',
top: 500,
left: 910,
width: 100,
height: 100,
borderColor: "#FFF",
borderRadius: 50,
borderWidth: 3,
backgroundImage: 'none',
@pietromalerba
pietromalerba / titanium-showcamera-register.js
Created May 3, 2013 15:38
Titanium showcamera register and uploads
Titanium.Media.showCamera({
success:function(event)
{
var cameraView = Titanium.UI.createImageView({width:'auto', height:'auto', top: 0, left: 0, image: event.media});
var imageNew0 = cameraView.toImage(function(e){
var filename1 = Titanium.Filesystem.applicationDataDirectory + "/NAMEOFTHEPICTURE1.png";
f1 = Titanium.Filesystem.getFile(filename1);
f1.write(e.blob);
Titanium.Media.saveToPhotoGallery(f1);
Titanium.Media.showCamera({
allowEditing: true,
success: function(event) {
var image = event.media;
var pxhr = Titanium.Network.createHTTPClient();
pxhr.onerror = function() {
Ti.UI.createNotification({
message:'Upload failed, please try again.'
}).show();
}
/**
* Override a tab group's tab bar on iOS.
*
* NOTE: Call this function on a tabGroup AFTER you have added all of your tabs to it! We'll look at the tabs that exist
* to generate the overriding tab bar view. If your tabs change, call this function again and we'll update the display.
*
* @param tabGroup The tab group to override
* @param backgroundOptions The options for the background view; use properties like backgroundColor, or backgroundImage.
* @param selectedOptions The options for a selected tab button.
* @param deselectedOptions The options for a deselected tab button.
function GetLocation(callback){
if (!Ti.Network.online)
{
callback({success: false});
return;
}
var PROVIDER = Titanium.Geolocation.PROVIDER_GPS;
var timeout;
Titanium.Geolocation.accuracy = Titanium.Geolocation.ACCURACY_BEST;
Titanium.Geolocation.distanceFilter = 0;
var win = Ti.UI.createWindow({backgroundColor: '#fff'});
var label = Ti.UI.createLabel();
win.add(label);
win.open();
function reportPosition(e) {
if (!e.success || e.error) {