Category Archives: Learn Titanium Appcelerator

Develop iPhone, iPad and Android apps using Titanium Appcelerator. Interesting resources, news and opinions.

Dan’s speech at TiConf Valencia 2013

A really short post today that gathers Dan’s presentation at TiConf 2013 where he talked about optimizing the code in order to speed up Titanium Appcelerator apps.

The video

The slides

Speed up your apps by Dan Tamas TiConf 2013 from dan_tamas

I hope I’ll be able to post a transcript of his speech sometimes next week.

TiConf-logo

Let’s meet at TiConf 2013 in Valencia – Europe’s first Titanium Appcelerator conference

This will probably be the last blog post for 2012 and I don’t want to end this year and begin another one without sending an invitation to all Titanium Appcelerators DeveLovers out there to come and meet each other at TiConf 2013.

Let’s meet next February 23th in Valencia (Spain), have a drink and chat about Titanium, NodeJs, SQLite, your latest Android phone, the latest SDK available or the last night’s tapas tour. Whatever makes you happy, just come – spring in Valencia is awesome and there will also be plenty of time to tour the city and its bars too.
Continue reading

Dan’s presentation at Appcelerator Meetup @ Mobile World Congress 2012

I’m the most annoying person on Appc’s QA forum, my name is Dan and this is how I can be found:

@dan_tamas
http://dan-tamas.me

Today I will try to talk about my experience as a freelancer that uses Titanium for all his mobile projects.

The community

screenshot of the Appcelerator community website

This is the Appcelerator Community. I’d like to tell you about what drives me to spend so much time on the QA. I love the open source movement and I think that helping other people will make us better and we’ll finally achieve world peace.

WRONG! This is wrong, but not as in lying but as in not telling the whole truth, just like marketing does ๐Ÿ˜€

Let’s take a client. Kevin (Whinnery) looks like he knows some stuff about Appcelerator and he wants a cross-platform application. Somehow he finds my website.

Dan Tamas portfolio screenshot from his website

A freelancer’s life is usually governed by NDAs. Everybody wants an NDA as if their project will be the next Angry Birds. When you reach a certain level and people start to know you, you begin to have better and more complex / interesting / nicer projects. But we all know how this usually happens.

The X (big) company hires a Marketing company to take care of their image, website and of course mobile apps. But they need programmers for this, so they hire a programming company. Well the story is that the programming company is nothing more than a few guys in-house and the rest of the team is made by us, the freelancers. And as you suspected they will want an NDA, because they also have one from the Marketing company or they don’t want the world to know that somebody else did their job.

I can tell you that I have worked for 2 companies so big that everybody in this room heard about. But of course I cannot tell you who they are. You might believe me or not but Kevin, the client, surely won’t – he needs something to see and not just simple words.

So coming back to my portfolio what does the client see?

Some certification – everybody has one – a boring FunyABC app for kids, MotorSport – an auto magazine for a German publication, some books and of course the biggest hit: the divorce calculator.

Nothing fancy, nothing outstanding. But because I’m pretty in the picture he gives me a chance and asks me for an interview.

What can I come up with?

I come up with this: I’m number 2 in the Top Experts
Appcelerator top experts: Dan Tamas is second

And this: I’m an Enterprise user of the framework with access to professional support, free modules and… free beer of course ๐Ÿ˜€
Dan Tamas profile on Appcelerator website

And I start to explain to the client that I’m a Titan, that I was chosen “Titan of the month” back in September, that I wrote some tutorials and, starting tomorrow, that I was invited to speak to an event organized by Appcelerator itself.

At this point there are very few clients that will discard me as a candidate for their project. If he’s not looking for cheap work or unless some other Titan manages to impress him better – like Aaron or Matt or any other guy spending his time on the QA forum – I’m all set.

How do you reach this level?

  1. Spend some quality time on QA, giving answers to questions, but good answers.
  2. Write articles and tutorials, people are searching for good Titanium tutorials.

Appcelerator as company is a little different because they are really helping the community, despite what some people complain on the forum. For example, most of the Titans have Pro accounts – for free – and the most active guys on QA are actually Appcelerator employees.

As you see, 1 hour ‘wasted’ on QA every day starts to bring something back.

Also reading other people’s answers makes you a better programmer, you learn for free just by reading their posts. And we have the whole stuff about clients impressed by this, as I just told you.

Bottom line

So bottom line – as a freelancer, build your business around the community. That one hour a day spent helping other people will have the best ROI you ever saw.

The Meetup in pictures

Meeting the Appcelerator guys

Kevin Javier and  Dan Tamas at Appcelerator Meetup Barcelona 2012

Kevin Javier and  Dan Tamas at Appcelerator Meetup Barcelona 2012

Nolan Jeff and  Dan Tamas at Appcelerator Meetup Barcelona 2012

Dan Tamas speaking at Appcelerator Meetup Barcelona 2012

Dan Tamas speaking at Appcelerator Meetup Barcelona 2012

Dan Tamas speaking at Appcelerator Meetup Barcelona 2012

Javier Rayon speaking at Appcelerator Meetup Barcelona 2012

Javier Rayon speaking at Appcelerator Meetup Barcelona 2012

Javier Rayon speaking at Appcelerator Meetup Barcelona 2012

day7

Seven days with Titanium – day 7 – orientation and accelerometer

Most of the devices nowadays are equipped with an accelerometer that detect the orientation of the device or the movements the user is doing with it.

Titanium exposes this functionality through its APIs so let’s take advantage of that :)

The orientation

The device can report 7 states of the orientation and they are defined in Titanium as follows:

  • Ti.UI.UNKNOWN – the app cannot detect the position
  • Ti.UI.PORTRAIT
  • Ti.UI.UPSIDE_PORTRAIT
  • Ti.UI.LANDSCAPE_LEFT
  • Ti.UI.LANDSCAPE_RIGHT
  • Ti.UI.FACE_DOWN – like resting on a table with the screen downward
  • Ti.UI.FACE_UP – like resting on a table but with the screen upward

While we have all this constants defined there are situations where they might not be available: in iOs when the user locks the orientation the device will report that orientation no matter how the device is held. On Android many devices can detect only the PORTRAIT and LANDSCAPE_LEFT orientations.

Since version 1.7.2 of the SDK the orientation API changed and is set per window (or activity). You can do this using the property orientationModes that accepts an array with the allowed orientation for that window. See this post on Appcelerator’s blog.

win.orientationModes = [Ti.UI.PORTRAIT, Ti.UI.LANDSCAPE_RIGHT];

There is also an event that triggers when the orientation changes allowing you to make the changes you might need (adapt the UI to the new orientation for example.)

Ti.Gesture.addEventListener('orientationchange',function(e) {
    alert(e.orientation);
});

The alert will show a number from 1 to 7 because the constants defined above are type INT. A good practice is to compare the orientation reported by the event with the constant and not directly with the number. In case something will change in the future this will assure you that the code will keep working.

You can find more about it in the docs page for Titanium.Gesture

The accelerometer

The accelerometer is a piece of hardware that is giving you the current position of the device in a 3D coordinates (x, y and z) vector. This can allow you for example to control the movements of an element on the screen.

To get this vector all you have to do is to catch the update event of the Titanium.Accelerometer APIs. It will return the vector we were talking about.

Ti.Accelerometer.addEventListener('update', function(e) {
    lbl.text = 'x: ' + e.x + 'y:' + e.y + 'z:' + e.z;
});

Again, it’s a good practice to remove the event when we don’t need it anymore to save some CPU cycles :)

Well, that’s it for Day 7. Code strong!