Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Codestrong 2012 breakout session android internals and best practices

1,137 views

Published on

  • Be the first to comment

  • Be the first to like this

Codestrong 2012 breakout session android internals and best practices

  1. 1. Titanium Mobile:Best Practices for Android Josh Roesslein, Software Engineer Appcelerator, Inc. jroesslein@appcelerator.com Max Stepanov, Senior Software Engineer Appcelerator, Inc. mstepanov@appcelerator.com
  2. 2. Agenda • History • Windows and Navigation • Layout events • Event Bubbling • Modern Look and Feel • Debugging
  3. 3. History • 0.8: HTML UI / WebView • 0.9: Native UI / Mozilla Rhino • 1.8: Google V8
  4. 4. Windows and Navigation • Heavyweight vs. Lightweight • Activities and Back Stack • Back Stack
  5. 5. Windows and Navigation Window A Window B Activity A Window B Activity B Activity B Window D
  6. 6. Layouts • Eventing: Use postlayout NOT open • A layout pass may not have occurred by the time an open event is fired • A postlayout event occurs after a native Android layout pass (may occur multiple times)
  7. 7. Event bubbling • SDK 3.0 allows control over event bubbling • Titanium.Event object has two new properties • bubbles • cancelBubble • Current defaults are identical to 2.X, but will change to achieve parity in the future
  8. 8. Control bubbling Allow custom events to bubble button.fireEvent(“myEvent”, {bubbles: true}); Allow bubbling to cancel during event handling view.addEventListener(“myEvent”, function(e) { e.cancelBubble = true; })
  9. 9. Cancel bubbling Allow views to bubble up / not to bubble up events view.bubbleParent = false; For more information: http://docs.appcelerator.com/titanium/ 3.0/index.html#!/guide/Event_Handlin g
  10. 10. Newer Look/Feel• Target API level • Backwards compatible • Unlocks newer behaviors and features• Themes • Consistent • Holo themes• ActionBar • MenuItem • Action Items • Tabs • Opt-in • TabGroup API
  11. 11. Android Debugging
  12. 12. New in Titanium Titanium 1.7 Titanium 3.0 Android Emulator Physical Devices
  13. 13. Device Debugging • V8 only (for on-device debugging) • Just plug in device into USB • Launches faster than Emulator!
  14. 14. Threading User taps button 1 EventListener 1• UI thread for handling  var x = 1; user interactions Ti.API.log(x); openWin(x);• JS thread for the postlayout event application logic Geo location Function Run• Debugger thread for communications with EventListener 2 Titanium Studio  Line 1 Line 2• Other Android Line 3 platform threads
  15. 15. Best Practices • Use conditional breakpoints • JavaScript code block • Hit count • Use Console logging with Ti.API functions
  16. 16. Josh Roesslein & Max Stepanovjroesslein@appcelerator.com / mstepanov@appcelerator.com

×