Codestrong 2012 breakout session android internals and best practices

  • View
    725

  • Download
    4

Embed Size (px)

Text of Codestrong 2012 breakout session android internals and best practices

  • 1.Titanium Mobile:Best Practices for Android Josh Roesslein, Software EngineerAppcelerator, Inc.jroesslein@appcelerator.com Max Stepanov, Senior Software Engineer Appcelerator, Inc. mstepanov@appcelerator.com

2. Agenda History Windows and Navigation Layout events Event Bubbling Modern Look and Feel Debugging 3. History 0.8: HTML UI / WebView 0.9: Native UI / Mozilla Rhino 1.8: Google V8 4. Windows and Navigation Heavyweight vs. Lightweight Activities and Back Stack Back Stack 5. Windows and NavigationWindow AWindow B Activity A Window B Activity B Activity B Window D 6. Layouts Eventing: Use postlayoutNOT open A layout pass may nothave occurred by the timean open event is fired A postlayout event occursafter a native Androidlayout pass (may occurmultiple times) 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. 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. Cancel bubblingAllow views to bubble up / not tobubble up eventsview.bubbleParent = false;For more information:http://docs.appcelerator.com/titanium/3.0/index.html#!/guide/Event_Handling 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. Android Debugging 12. New in Titanium Titanium 1.7Titanium 3.0Android Emulator Physical Devices 13. Device Debugging V8 only (for on-device debugging) Just plug in device into USB Launches faster than Emulator! 14. Threading User taps button 1EventListener 1 UI thread for handling var x = 1;user interactions Ti.API.log(x); openWin(x); JS thread for thepostlayout eventapplication logicGeo locationFunction Run Debugger thread forcommunications with EventListener 2Titanium Studio Line 1Line 2 Other Android Line 3platform threads 15. Best Practices Use conditional breakpoints JavaScript code block Hit count Use Console logging with Ti.API functions 16. Josh Roesslein & Max Stepanovjroesslein@appcelerator.com / mstepanov@appcelerator.com