Skip to content

Instantly share code, notes, and snippets.

View manumaticx's full-sized avatar
👌
i'm okay

Manuel Lehner manumaticx

👌
i'm okay
View GitHub Profile
@manumaticx
manumaticx / README.md
Last active July 11, 2020 14:07
Fading ActionBar in Titanium

Fading Actionbar

This is a quick example of how to create a fading actionbar effect like this in Appcelerator Titanium

fadingactionbar

How this works

This is actually very simple. The trick is putting the Actionbar in overlay mode by configuring the theme with windowActionBarOverlay:true. Then all you need to do is updating the color of the Actionbar, in this case by scrolling a ScrollView.

@manumaticx
manumaticx / components.my-component\.js
Last active June 26, 2020 11:21
modified twice bug
import Component from '@ember/component';
import { computed } from '@ember/object';
export default Component.extend({
init() {
this._super(...arguments);
this.onUpdate(false);
},
@manumaticx
manumaticx / physical_size.js
Created December 17, 2013 12:57
Function to calculate display size as inches on android for Appcelerator Titanium with the help of https://github.com/dbankier/HasMenu
/**
* Calculates the physical display size for android devices
* e.g 4,95 for Nexus 5 or 7,02 for Nexus 7
*
* IMPORTANT: this requires https://github.com/dbankier/HasMenu
*
* @return {Number} size as inches
*/
function getPhysicalSize(){
// some infos we need
@manumaticx
manumaticx / gruntfile.js
Created February 21, 2016 22:49
convert all MP4 files to MOV with ffmpeg and grunt
/**
* This is just a little helper I made when I had to convert a lot of MP4 files.
* Using ffmpeg this works fine but it just needed to be automated. Maybe this isn't the best
* solution, it's quick and dirty but I was happy with its results.
* The grunt script ran overnight to process about a hundred video files.
*/
module.exports = function(grunt) {
var _ = require('underscore');
@manumaticx
manumaticx / pagingcontrol.js
Last active July 17, 2017 16:10
port of PagingControl Alloy Widget for Titanium Classic
/**
* Original Alloy Widget:
* https://github.com/manumaticx/pagingcontrol
*
* This implementation is a port for Classic Titanium.
* @author: Manuel Lehner
*/
var OS_ANDROID = Ti.Platform.osname === 'android';
@manumaticx
manumaticx / BackgroundNotification.js
Last active March 16, 2017 14:47
Android background service called from bencoding.AlarmManager BackgroundNotification.js is located under Resources/android/ or app/assets/android (in Alloy) Stackoverflow question: http://stackoverflow.com/questions/18234250/titanium-appcelerator-android-daily-notification-at-some-specified-time
/* locate this file under:
* - Resources/android/
* or
* - app/assets/android/ (when working with Alloy)
*/
var service = Ti.Android.currentService;
var serviceIntent = service.getIntent();
setNotification();
@manumaticx
manumaticx / audio_stream.js
Last active March 15, 2017 18:43
modified sample code from http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.Media.AudioPlayer related to this question: http://developer.appcelerator.com/question/154232/how-to-check-if-audio-is-playing Also added an intent filter to launch Activity from an url while the stream is playing in background. See this question: http://devel…
var win = Titanium.UI.createWindow({
title:'Audio Test',
backgroundColor:'#fff',
layout: 'vertical'
});
var startStopButton = Titanium.UI.createButton({
title:'Start/Stop Streaming',
top:'10dp',
width:'200dp',
@manumaticx
manumaticx / index.js
Last active March 15, 2017 18:41
CommonJS location helper for Titanium
var location = require('location');
if (location.enabled){
if (location.hasAuth){
location.currentLocation(function(e){
alert(e.latitude + '; ' + e.longitude);
});
}else{
alert('need permission to access location service');
}
// Forked from https://gist.github.com/2417902 to fix a small bug
// -----
function PagingControl(scrollableView){
var pages = [];
var page;
var numberOfPages = scrollableView.getViews().length;
// Configuration
var pageColor = "#c99ed5";
var container = Titanium.UI.createView({
@manumaticx
manumaticx / app.js
Last active June 8, 2016 16:23
Underline a word in a Ti.UI.Label
/**
* Underlines a single word of a label
* @param {Ti.UI.Label} _label
* @param {String} _word
*/
function underline(_label, _word) {
if (Ti.Platform.name === 'iPhone OS') {
var text = _label.getText();
var attr = Titanium.UI.iOS.createAttributedString({
text : text,