SlideShare a Scribd company logo
1 of 58
Download to read offline
Titanium Mobile
Justin Lee
Mobile App
JAVA Objective-C
HTML5+CSS+JS   HTML5+CSS+JS+JS API   Java, Obj-C+Native API
window                                      window
   webview                                     label
   DOM parser                                  window
   JavaScript interpreter                  label
   CSS parser
   HTML renderer
   SVG renderer             hello world!
   Canvas renderer
   history manager
   SQLLite engine
   index.html

render
    window
label
web
Titanium Mobile
JavaScript


var win = Titanium.UI.createWindow({
    backgroundColor:'#fff'
});

var label = Titanium.UI.createLabel({
    text: 'Hello World!'
});

win.add(label);
win.open();
Titanium
   Javascript
                Titanium API


                       JS to Native Bridge


                Native API
UI API   Phone API
50%
Java   Objective-C   Titanium API
SDK
•Titanium Mobile SDK (1.6.2)
•iOS SDK or Android SDK


Developer Tool
•Titanium Developer (1.2.2)
•Titanium Studio (RC1)



•textmate, vim...
iOS   Mac




{
Titanium Developer
Titanium Studio
   Breakpoint+Debugger
Titanium        javascript
     DOM            JQuery
       UI    Javascript
  window
  view        div
                     AddEventListener
            execution context
Hello World! Titanium
HowIsTheWeather/
    build/
        android/
             ...
        iphone/
             ...
    CHANGELOG.txt
    LICENSE
    LICENSE.txt
    manifest
    README
    Resources/
        android/
             ...
        app.js
        iphone/
             ...
        KS_nav_ui.png
        KS_nav_views.png
    tiapp.xml
Hello World!
var win = Titanium.UI.createWindow({
    backgroundColor:'#fff'
});

var label = Titanium.UI.createLabel({
    text: 'Hello World!',
    textAlign: 'center'
});

label.addEventListener('click', function(e){
    Titanium.API.info('label clicked!');
});

win.add(label);
win.open();
http://goo.gl/0be5C
Titanium
http://goo.gl/Fj3pl


   UI
   GPS
         XML
var win = Titanium.UI.createWindow({
    backgroundColor:'#fff'
});

var locationLabel = Titanium.UI.createLabel({
    color:'#000',
    text:'     ',
    font:{fontSize: 30, fontFamily:'Helvetica Neue'},
                                                               75px
    textAlign:'center',
    width:'auto',
    height: 'auto',
    left: 15,
                                                        15px
    top: 75
});

var weatherIcon = Titanium.UI.createImageView({
    image: 'images/mostly_cloudy.gif',
    width: 80,
    height: 80,
    left: 15,
    top: 120
});
var temperatureLabel = Titanium.UI.createLabel({
    color:'#000',
    text:'28°C',
    font:{fontSize: 90, fontFamily:'Helvetica Neue'},
    textAlign:'center',
    width:'auto',
    height: 'auto',
    right: 15,
    top: 100
});

var detailLabel = Titanium.UI.createLabel({
    color:'#000',
    text: '       n      62%n         n     10     /   ',
    font:{fontSize: 24, fontFamily:'Helvetica Neue'},
    textAlign:'left',
    width:'auto',
    height: 'auto',
    left: 20,
    top: 220
});

win.add(locationLabel);
win.add(weatherIcon);
win.add(temperatureLabel);
win.add(detailLabel);
win.open();
if (Titanium.Geolocation.locationServicesEnabled === false)
{
     Titanium.UI.createAlertDialog({title:'             ',
     message:'    啓                                '}).show();
}
else                                                       	 
{
     Ti.Geolocation.purpose = "get current position";
     Titanium.Geolocation.accuracy = Titanium.Geolocation.ACCURACY_THREE_KILOMETERS;

    Titanium.Geolocation.distanceFilter = 1000;

    Titanium.Geolocation.getCurrentPosition(function(e)
    {
        if (e.error)
        {
            Titanium.API.info("error: " + JSON.stringify(e.error));
            return;
        }

          var latitude = e.coords.latitude;
          var longitude = e.coords.longitude;
          Ti.API.info(longitude+','+latitude);
    });
    ...
}
function updateLocationName(lat, lng)
{
    Titanium.Geolocation.reverseGeocoder(lat, lng, function(e)
    {
        if (e.success) {
            var places = e.places;
            if (places && places.length) {
                locationLabel.text = places[0].city;
            } else {
                locationLabel.text = "";
            }
            Ti.API.debug("reverse geolocation result = "+JSON.stringify(e));
        }
        else {
            Ti.UI.createAlertDialog({
                title:'Reverse geo error',
                message:evt.error
            }).show();
            Ti.API.info("Code translation: "+translateErrorCode(e.code));
        }
    });
}
Google’s secret Weather API
http://www.google.com/ig/api?hl={locale}&weather=,,,{lat},{lng}


 http://www.google.com/ig/api?hl=zh-tw&weather=,,,25060808,121485606
    <?xml version="1.0"?>
    <xml_api_reply version="1">
    <weather module_id="0" tab_id="0" mobile_row="0" mobile_zipped="1" row="0" section="0" >
        <forecast_information>
            <city data=""/>
            <postal_code data=""/>
            <latitude_e6 data="25060808"/>
            <longitude_e6 data="121485606"/>
            <forecast_date data="2010-09-15"/>
            <current_date_time data="2010-09-14 23:00:00 +0000"/>
            <unit_system data="SI"/>
        </forecast_information>
        <current_conditions>
            <condition data="   "/>
                                                                http://img0.gmodules.com/
            <temp_f data="79"/>
            <temp_c data="26"/>
            <humidity data="      87%"/>
            <icon data="/ig/images/weather/cloudy.gif"/>
            <wind_condition data="           /   "/>
        </current_conditions>
        <forecast_conditions>
            <day_of_week data="    "/>
            <low data="26"/>
            <high data="35"/>
            <icon data="/ig/images/weather/thunderstorm.gif"/>
            <condition data="              "/>
        </forecast_conditions>
                  ...
    </weather>
    </xml_api_reply>
function updateWeather(lat, lng)
{
    var xhr = Titanium.Network.createHTTPClient();

    xhr.onload = function()
    {
        Ti.API.info('weather xml ' + this.responseXML + ' text ' + this.responseText);
        //var doc = this.responseXML.documentElement; encoding bug on Android
        var doc = Titanium.XML.parseString(this.responseText).documentElement;

        var condition = doc.evaluate("//weather/current_conditions/condition").item
(0).getAttribute('data');
        Ti.API.info(condition);

        ...

       temperatureLabel.text = temp_c + '°C';
       weatherIcon.image = icon;
       detailLabel.text = condition + 'n';
       detailLabel.text += humidity + 'n';
       detailLabel.text += wind_condition.split('    ')[0] + 'n';
       detailLabel.text += wind_condition.split('    ')[1] + 'n';
    };
    var url = 'http://www.google.com/ig/api?hl=zh-tw&weather=,,,'+parseInt(lat*1000000,
10)+','+parseInt(lng*1000000, 10);
    Ti.API.info(url);
    xhr.open('GET', url);
    xhr.send();
function getCurrentWeather()
{
        if (Titanium.Geolocation.locationServicesEnabled === false)
    {
           Titanium.UI.createAlertDialog({title:'                ', message:'   啓                                '}).show();
    }
    else
    {
           Ti.Geolocation.purpose = "                       ";
           Titanium.Geolocation.accuracy = Titanium.Geolocation.ACCURACY_BEST;
           Titanium.Geolocation.distanceFilter = 1000;
           Titanium.Geolocation.getCurrentPosition(function(e)
           {
                 if (e.error)
                 {
                     Titanium.API.info("error: " + JSON.stringify(e.error));
                     Titanium.UI.createAlertDialog({title:'              ', message: e.error.message}).show();
                     detailLabel.text = '                                 ';
                     return;
                 }
                 var latitude = e.coords.latitude;
                 var longitude = e.coords.longitude;
                 Ti.API.info(longitude+','+latitude);
                 updateLocationName(latitude, longitude);
                 updateWeather(latitude, longitude);
           });
    }
}
getCurrentWeather();
updateInterval = setInterval(getCurrentWeather, 300000);
var settingWin = Titanium.UI.createWindow({
    backgroundColor: '#999'
});

var aboutWebview = Titanium.UI.createWebView({
    url: 'about.html',
    ...
    });
settingWin.add(aboutWebview);

var doneButton = Titanium.UI.createButton({
    title: '   ',
    ...
});
settingWin.add(doneButton);

doneButton.addEventListener('click', function(e){
    if(Titanium.Platform.osname === 'iphone')
    {
        settingWin.close({transition: Ti.UI.iPhone.AnimationStyle.FLIP_FROM_RIGHT});
        mainWin.open();
    }else if(Titanium.Platform.osname === 'android')
    {
        mainWin.open();
        settingWin.close();
    }
    getCurrentWeather();
});
<!doctype html>
<html lang="zh-tw">
<head>
    <meta charset="utf-8">
    <title>About</title>
    <meta name="description" content="About the app">
    <meta name="viewport" content="width=320"/>
    <meta name="author" content="lis186">
    <link rel="stylesheet" href="screen.css">
</head>

<body>
<h1>            </h1>
<img src='appicon.png'>
<p>     1.0</p>
<p>Powered by Titanium Mobile.</p>
</body>
</html>


                                            about.js
if(Titanium.Platform.osname === 'iphone')
{
    var unitTabbedBar = Titanium.UI.createTabbedBar({
        labels:['°C', '°F'],
        style:Titanium.UI.iPhone.SystemButtonStyle.BAR,
        ...
    });

    unitTabbedBar.addEventListener('click', function(e){
        if(e.index === 0)
        {
            Titanium.App.Properties.setString('tempUnit', 'c');
        }else if (e.index === 1){
            Titanium.App.Properties.setString('tempUnit', 'f');
        }
    });

    settingWin.add(unitTabbedBar);

    var settingButton = Titanium.UI.createButton({
        ...
        style: Titanium.UI.iPhone.SystemButton.INFO_DARK
    });

    mainWin.add(settingButton);
}
if(Titanium.Platform.osname === 'android')
{
    var cButton = Titanium.UI.createButton({
        title: '°C',
        ...
    });

    var fButton = Titanium.UI.createButton({
        title: '°F',
        ...
    });

    cButton.addEventListener('click', function(e){
        Titanium.App.Properties.setString('tempUnit', 'c');
        cButton.enabled = false;
        fButton.enabled = true;
    });

    fButton.addEventListener('click', function(e){
        Titanium.App.Properties.setString('tempUnit', 'f');
        cButton.enabled = true;
        fButton.enabled = false;
    });

    settingWin.add(cButton);
    settingWin.add(fButton);
}
if(Titanium.Platform.osname === 'iphone')
{
    mainWin.add(settingButton);
    settingButton.addEventListener('click', function(e){
        settingWin.open({
           transition: Ti.UI.iPhone.AnimationStyle.FLIP_FROM_LEFT
           });
        var tempUnit = Titanium.App.Properties.getString('tempUnit', 'c');
        if(tempUnit === 'c')
        {
            unitTabbedBar.index = 0;
        }else if(tempUnit === 'f')
        {
            unitTabbedBar.index = 1;
        }
        mainWin.close();
    });
}
if(Titanium.Platform.osname === 'android')
{
    Titanium.Android.currentActivity.onCreateOptionsMenu = function(e) {
        Titanium.API.info("create menu");
        var menu = e.menu;
        var refreshMenuItem = menu.add({ title: '       ' });
        var settingMenuItem = menu.add({ title: '   ' });

         refreshMenuItem.addEventListener("click", function(e) {
             getCurrentWeather();
         });
         settingMenuItem.addEventListener("click", function(e) {
             indicator.hide();
             settingWin.open();
             var tempUnit = Titanium.App.Properties.getString('tempUnit', 'c');
             if(tempUnit === 'c')
             {
                 cButton.enabled = false;
                 fButton.enabled = true;
             }else if(tempUnit === 'f')
             {
                 cButton.enabled = true;
                 fButton.enabled = false;
             }
             mainWin.close();
         });
    };
}
if(Titanium.Platform.osname === 'iphone')
     {
         var service;
         Titanium.App.addEventListener('pause',function(e)
         {
             Ti.API.info('pause');
             service = Titanium.App.iOS.registerBackgroundService({
                 url: 'bgjob.js',
                 tempUnit: Titanium.App.Properties.getString('tempUnit', 'c')
               });
	            Titanium.API.info("registered background service = "+service);
         });

         Titanium.App.addEventListener('resumed',function(e)
         {
             Ti.API.info('resumed');
             if(service != null){
                 getCurrentWeather();
                 service.stop();
                 service.unregister();
                 Ti.API.info('Stop background service');
             }
         });
     }
function updateWeather(lat, lng)
{
    var xhr = Titanium.Network.createHTTPClient();                        bgjob.js
    xhr.onload = function()
    {
       var tempUnit = Titanium.App.currentService.tempUnit;

              ...

        if(tempUnit === 'c')
                                                                 	 
        {
            Titanium.UI.iPhone.appBadge   = temp_c;
            Ti.API.info('Update badge:'   + temp_c);
        }else if(tempUnit === 'f')
        {
            Titanium.UI.iPhone.appBadge   = temp_f;
            Ti.API.info('Update badge:'   + temp_f);
        }
    };
    var url = 'http://www.google.com/ig/api?hl=zh-tw&weather=,,,'+
               parseInt(lat*1000000, 10)+','+parseInt(lng*1000000, 10);
    Ti.API.info(url);
    xhr.open('GET', url);
    xhr.send();
}

function getCurrentWeather()
{
    ...
}
...
Ti.API.info('starting background service');
var updateInterval = setInterval(getCurrentWeather, 300000);
if(Titanium.Platform.osname === 'android')
{
    Titanium.Android.currentActivity.addEventListener('resume', function(e) {
        Ti.API.info("resumed");
        getCurrentWeather();
    });
}
!== “Write Once, Run Everywhere”
http://www.cultofmac.com/self-evidently-bad-app-idea-scale-for-ipad
Titanium Mobile SDK
http://goo.gl/Se1dF

Kitchen Sink
http://goo.gl/5v6dJ


http://goo.gl/Fj3pl
Titanium Mobile




       6/9
  http://www.lis186.com/?p=2140
Hiring!
We’re

Titanium SDK Developer

 Titanium Evangelist

    http://ti.herxun.co/?page_id=66
20110525[Taipei GTUG] titanium mobile簡介

More Related Content

What's hot

201410 2 fiware-orion-contextbroker
201410 2 fiware-orion-contextbroker201410 2 fiware-orion-contextbroker
201410 2 fiware-orion-contextbroker
FIWARE
 
CiklumJavaSat_15112011:Alex Kruk VMForce
CiklumJavaSat_15112011:Alex Kruk VMForceCiklumJavaSat_15112011:Alex Kruk VMForce
CiklumJavaSat_15112011:Alex Kruk VMForce
Ciklum Ukraine
 

What's hot (20)

mobl
moblmobl
mobl
 
201410 2 fiware-orion-contextbroker
201410 2 fiware-orion-contextbroker201410 2 fiware-orion-contextbroker
201410 2 fiware-orion-contextbroker
 
Dojo and Adobe AIR
Dojo and Adobe AIRDojo and Adobe AIR
Dojo and Adobe AIR
 
Practical
PracticalPractical
Practical
 
Android wearpp
Android wearppAndroid wearpp
Android wearpp
 
The Ring programming language version 1.8 book - Part 74 of 202
The Ring programming language version 1.8 book - Part 74 of 202The Ring programming language version 1.8 book - Part 74 of 202
The Ring programming language version 1.8 book - Part 74 of 202
 
HTML5って必要?
HTML5って必要?HTML5って必要?
HTML5って必要?
 
CiklumJavaSat_15112011:Alex Kruk VMForce
CiklumJavaSat_15112011:Alex Kruk VMForceCiklumJavaSat_15112011:Alex Kruk VMForce
CiklumJavaSat_15112011:Alex Kruk VMForce
 
Backbone Basics with Examples
Backbone Basics with ExamplesBackbone Basics with Examples
Backbone Basics with Examples
 
Migrating from Flux to Redux. Why and how.
Migrating from Flux to Redux. Why and how.Migrating from Flux to Redux. Why and how.
Migrating from Flux to Redux. Why and how.
 
Introduction To Google Android (Ft Rohan Bomle)
Introduction To Google Android (Ft Rohan Bomle)Introduction To Google Android (Ft Rohan Bomle)
Introduction To Google Android (Ft Rohan Bomle)
 
“iOS 11 в App in the Air”, Пронин Сергей, App in the Air
“iOS 11 в App in the Air”, Пронин Сергей, App in the Air“iOS 11 в App in the Air”, Пронин Сергей, App in the Air
“iOS 11 в App in the Air”, Пронин Сергей, App in the Air
 
The Ring programming language version 1.7 book - Part 72 of 196
The Ring programming language version 1.7 book - Part 72 of 196The Ring programming language version 1.7 book - Part 72 of 196
The Ring programming language version 1.7 book - Part 72 of 196
 
The Ring programming language version 1.10 book - Part 79 of 212
The Ring programming language version 1.10 book - Part 79 of 212The Ring programming language version 1.10 book - Part 79 of 212
The Ring programming language version 1.10 book - Part 79 of 212
 
Rxjs marble-testing
Rxjs marble-testingRxjs marble-testing
Rxjs marble-testing
 
Android For All The Things
Android For All The ThingsAndroid For All The Things
Android For All The Things
 
Testing a 2D Platformer with Spock
Testing a 2D Platformer with SpockTesting a 2D Platformer with Spock
Testing a 2D Platformer with Spock
 
Unit testing with mock libs
Unit testing with mock libsUnit testing with mock libs
Unit testing with mock libs
 
The Ring programming language version 1.5.1 book - Part 64 of 180
The Ring programming language version 1.5.1 book - Part 64 of 180The Ring programming language version 1.5.1 book - Part 64 of 180
The Ring programming language version 1.5.1 book - Part 64 of 180
 
Yahoo Query Language: Select * from Internet
Yahoo Query Language: Select * from InternetYahoo Query Language: Select * from Internet
Yahoo Query Language: Select * from Internet
 

Viewers also liked

2013/05/19 - Titanium 入門實戰 3
2013/05/19 - Titanium 入門實戰 32013/05/19 - Titanium 入門實戰 3
2013/05/19 - Titanium 入門實戰 3
樂平 大俠
 
快快樂樂利用 PhoneGap 打造屬於自己的 App
快快樂樂利用 PhoneGap 打造屬於自己的 App快快樂樂利用 PhoneGap 打造屬於自己的 App
快快樂樂利用 PhoneGap 打造屬於自己的 App
ericpi Bi
 
2011/08/20跨平台行動應用程式使用者介面開發—以titanium mobile為例
2011/08/20跨平台行動應用程式使用者介面開發—以titanium mobile為例2011/08/20跨平台行動應用程式使用者介面開發—以titanium mobile為例
2011/08/20跨平台行動應用程式使用者介面開發—以titanium mobile為例
Justin Lee
 
Hackatron - UIKit Dynamics
Hackatron - UIKit DynamicsHackatron - UIKit Dynamics
Hackatron - UIKit Dynamics
Renzo G. Pretto
 
基于Cocos2 d x二次开发的自有引擎方案分享-mobile 2d framework en
基于Cocos2 d x二次开发的自有引擎方案分享-mobile 2d framework en基于Cocos2 d x二次开发的自有引擎方案分享-mobile 2d framework en
基于Cocos2 d x二次开发的自有引擎方案分享-mobile 2d framework en
增强 杜
 
20120524 App開發流程與小工具分享@UI Cafe
20120524 App開發流程與小工具分享@UI Cafe20120524 App開發流程與小工具分享@UI Cafe
20120524 App開發流程與小工具分享@UI Cafe
Justin Lee
 
App使用者經驗設計
App使用者經驗設計App使用者經驗設計
App使用者經驗設計
Justin Lee
 
Android動態ui介面設計
Android動態ui介面設計Android動態ui介面設計
Android動態ui介面設計
艾鍗科技
 
Java SE 7 技術手冊投影片第 13 章 - 視窗程式設計
Java SE 7 技術手冊投影片第 13 章 - 視窗程式設計Java SE 7 技術手冊投影片第 13 章 - 視窗程式設計
Java SE 7 技術手冊投影片第 13 章 - 視窗程式設計
Justin Lin
 

Viewers also liked (17)

2013/05/19 - Titanium 入門實戰 3
2013/05/19 - Titanium 入門實戰 32013/05/19 - Titanium 入門實戰 3
2013/05/19 - Titanium 入門實戰 3
 
2013/05/19 Sketching with code@JSDC2013
2013/05/19 Sketching with code@JSDC20132013/05/19 Sketching with code@JSDC2013
2013/05/19 Sketching with code@JSDC2013
 
20130604 Prototype Driven Design@Computex 2013 智慧手持裝置論壇 I 加拿大人機介面技術發展與經驗分享
20130604 Prototype Driven Design@Computex 2013 智慧手持裝置論壇 I  加拿大人機介面技術發展與經驗分享20130604 Prototype Driven Design@Computex 2013 智慧手持裝置論壇 I  加拿大人機介面技術發展與經驗分享
20130604 Prototype Driven Design@Computex 2013 智慧手持裝置論壇 I 加拿大人機介面技術發展與經驗分享
 
快快樂樂利用 PhoneGap 打造屬於自己的 App
快快樂樂利用 PhoneGap 打造屬於自己的 App快快樂樂利用 PhoneGap 打造屬於自己的 App
快快樂樂利用 PhoneGap 打造屬於自己的 App
 
Intro to appcelerator
Intro to appceleratorIntro to appcelerator
Intro to appcelerator
 
iOS中Lua脚本的应用
iOS中Lua脚本的应用iOS中Lua脚本的应用
iOS中Lua脚本的应用
 
2011/08/20跨平台行動應用程式使用者介面開發—以titanium mobile為例
2011/08/20跨平台行動應用程式使用者介面開發—以titanium mobile為例2011/08/20跨平台行動應用程式使用者介面開發—以titanium mobile為例
2011/08/20跨平台行動應用程式使用者介面開發—以titanium mobile為例
 
Hackatron - UIKit Dynamics
Hackatron - UIKit DynamicsHackatron - UIKit Dynamics
Hackatron - UIKit Dynamics
 
基于Cocos2 d x二次开发的自有引擎方案分享-mobile 2d framework en
基于Cocos2 d x二次开发的自有引擎方案分享-mobile 2d framework en基于Cocos2 d x二次开发的自有引擎方案分享-mobile 2d framework en
基于Cocos2 d x二次开发的自有引擎方案分享-mobile 2d framework en
 
20120524 App開發流程與小工具分享@UI Cafe
20120524 App開發流程與小工具分享@UI Cafe20120524 App開發流程與小工具分享@UI Cafe
20120524 App開發流程與小工具分享@UI Cafe
 
App使用者經驗設計
App使用者經驗設計App使用者經驗設計
App使用者經驗設計
 
Objective C Tricks
Objective C TricksObjective C Tricks
Objective C Tricks
 
Android動態ui介面設計
Android動態ui介面設計Android動態ui介面設計
Android動態ui介面設計
 
Java SE 8 技術手冊第 10 章 - 輸入輸出
Java SE 8 技術手冊第 10 章 - 輸入輸出Java SE 8 技術手冊第 10 章 - 輸入輸出
Java SE 8 技術手冊第 10 章 - 輸入輸出
 
Java SE 7 技術手冊投影片第 13 章 - 視窗程式設計
Java SE 7 技術手冊投影片第 13 章 - 視窗程式設計Java SE 7 技術手冊投影片第 13 章 - 視窗程式設計
Java SE 7 技術手冊投影片第 13 章 - 視窗程式設計
 
Extending Titanium with native iOS and Android modules
Extending Titanium with native iOS and Android modules Extending Titanium with native iOS and Android modules
Extending Titanium with native iOS and Android modules
 
Lua/LuaJIT 字节码浅析
Lua/LuaJIT 字节码浅析Lua/LuaJIT 字节码浅析
Lua/LuaJIT 字节码浅析
 

Similar to 20110525[Taipei GTUG] titanium mobile簡介

Codestrong 2012 breakout session hacking titanium
Codestrong 2012 breakout session   hacking titaniumCodestrong 2012 breakout session   hacking titanium
Codestrong 2012 breakout session hacking titanium
Axway Appcelerator
 
Is HTML5 Ready? (workshop)
Is HTML5 Ready? (workshop)Is HTML5 Ready? (workshop)
Is HTML5 Ready? (workshop)
Remy Sharp
 
Is html5-ready-workshop-110727181512-phpapp02
Is html5-ready-workshop-110727181512-phpapp02Is html5-ready-workshop-110727181512-phpapp02
Is html5-ready-workshop-110727181512-phpapp02
PL dream
 
How to build a html5 websites.v1
How to build a html5 websites.v1How to build a html5 websites.v1
How to build a html5 websites.v1
Bitla Software
 
Mobile Software Engineering Crash Course - C06 WindowsPhone
Mobile Software Engineering Crash Course - C06 WindowsPhoneMobile Software Engineering Crash Course - C06 WindowsPhone
Mobile Software Engineering Crash Course - C06 WindowsPhone
Mohammad Shaker
 
mobl presentation @ IHomer
mobl presentation @ IHomermobl presentation @ IHomer
mobl presentation @ IHomer
zefhemel
 
CouchDB on Android
CouchDB on AndroidCouchDB on Android
CouchDB on Android
Sven Haiges
 

Similar to 20110525[Taipei GTUG] titanium mobile簡介 (20)

Codestrong 2012 breakout session hacking titanium
Codestrong 2012 breakout session   hacking titaniumCodestrong 2012 breakout session   hacking titanium
Codestrong 2012 breakout session hacking titanium
 
Micro app-framework - NodeLive Boston
Micro app-framework - NodeLive BostonMicro app-framework - NodeLive Boston
Micro app-framework - NodeLive Boston
 
Micro app-framework
Micro app-frameworkMicro app-framework
Micro app-framework
 
Paris js extensions
Paris js extensionsParis js extensions
Paris js extensions
 
Cross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App EngineCross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App Engine
 
Is HTML5 Ready? (workshop)
Is HTML5 Ready? (workshop)Is HTML5 Ready? (workshop)
Is HTML5 Ready? (workshop)
 
Is html5-ready-workshop-110727181512-phpapp02
Is html5-ready-workshop-110727181512-phpapp02Is html5-ready-workshop-110727181512-phpapp02
Is html5-ready-workshop-110727181512-phpapp02
 
How to build a html5 websites.v1
How to build a html5 websites.v1How to build a html5 websites.v1
How to build a html5 websites.v1
 
huhu
huhuhuhu
huhu
 
SharePoint Saturday Belgium 2018 - APIs, APIs everywhere!
SharePoint Saturday Belgium 2018 - APIs, APIs everywhere!SharePoint Saturday Belgium 2018 - APIs, APIs everywhere!
SharePoint Saturday Belgium 2018 - APIs, APIs everywhere!
 
APIs, APIs Everywhere!
APIs, APIs Everywhere!APIs, APIs Everywhere!
APIs, APIs Everywhere!
 
Mobile Software Engineering Crash Course - C06 WindowsPhone
Mobile Software Engineering Crash Course - C06 WindowsPhoneMobile Software Engineering Crash Course - C06 WindowsPhone
Mobile Software Engineering Crash Course - C06 WindowsPhone
 
Designing REST API automation tests in Kotlin
Designing REST API automation tests in KotlinDesigning REST API automation tests in Kotlin
Designing REST API automation tests in Kotlin
 
Top 10 Web Security Vulnerabilities
Top 10 Web Security VulnerabilitiesTop 10 Web Security Vulnerabilities
Top 10 Web Security Vulnerabilities
 
mobl presentation @ IHomer
mobl presentation @ IHomermobl presentation @ IHomer
mobl presentation @ IHomer
 
Svcc 2013-d3
Svcc 2013-d3Svcc 2013-d3
Svcc 2013-d3
 
SVCC 2013 D3.js Presentation (10/05/2013)
SVCC 2013 D3.js Presentation (10/05/2013)SVCC 2013 D3.js Presentation (10/05/2013)
SVCC 2013 D3.js Presentation (10/05/2013)
 
CouchDB on Android
CouchDB on AndroidCouchDB on Android
CouchDB on Android
 
SharePoint Conference 2018 - APIs, APIs everywhere!
SharePoint Conference 2018 - APIs, APIs everywhere!SharePoint Conference 2018 - APIs, APIs everywhere!
SharePoint Conference 2018 - APIs, APIs everywhere!
 
Html5 For Jjugccc2009fall
Html5 For Jjugccc2009fallHtml5 For Jjugccc2009fall
Html5 For Jjugccc2009fall
 

More from Justin Lee

20130614 Titanium簡介@政大資科
20130614 Titanium簡介@政大資科20130614 Titanium簡介@政大資科
20130614 Titanium簡介@政大資科
Justin Lee
 
Android 4.0 UI Design Tips
Android 4.0 UI Design TipsAndroid 4.0 UI Design Tips
Android 4.0 UI Design Tips
Justin Lee
 
UI於現階段與未來的應用趨勢
UI於現階段與未來的應用趨勢UI於現階段與未來的應用趨勢
UI於現階段與未來的應用趨勢
Justin Lee
 
談如何發展具有破壞力的創新構想
談如何發展具有破壞力的創新構想談如何發展具有破壞力的創新構想
談如何發展具有破壞力的創新構想
Justin Lee
 
Interaction Design & Industrial Design In 3C Industry
Interaction Design & Industrial Design In 3C IndustryInteraction Design & Industrial Design In 3C Industry
Interaction Design & Industrial Design In 3C Industry
Justin Lee
 
User Experience Design
User Experience DesignUser Experience Design
User Experience Design
Justin Lee
 

More from Justin Lee (20)

2023/04/19 學習中的AI 如何幫助孩子有效學習
2023/04/19 學習中的AI 如何幫助孩子有效學習2023/04/19 學習中的AI 如何幫助孩子有效學習
2023/04/19 學習中的AI 如何幫助孩子有效學習
 
2014/01/12 旅人的府城漫步
2014/01/12 旅人的府城漫步2014/01/12 旅人的府城漫步
2014/01/12 旅人的府城漫步
 
20130614 Titanium簡介@政大資科
20130614 Titanium簡介@政大資科20130614 Titanium簡介@政大資科
20130614 Titanium簡介@政大資科
 
[ICOS2013] Appcelerator Titanium簡介
[ICOS2013] Appcelerator Titanium簡介[ICOS2013] Appcelerator Titanium簡介
[ICOS2013] Appcelerator Titanium簡介
 
20130112用原型驅動設計@webconf
20130112用原型驅動設計@webconf20130112用原型驅動設計@webconf
20130112用原型驅動設計@webconf
 
2012/02/15 Android 4.0 UI Design Tips@happy designer meetup
2012/02/15 Android 4.0 UI Design Tips@happy designer meetup2012/02/15 Android 4.0 UI Design Tips@happy designer meetup
2012/02/15 Android 4.0 UI Design Tips@happy designer meetup
 
Android 4.0 UI Design Tips
Android 4.0 UI Design TipsAndroid 4.0 UI Design Tips
Android 4.0 UI Design Tips
 
UI於現階段與未來的應用趨勢
UI於現階段與未來的應用趨勢UI於現階段與未來的應用趨勢
UI於現階段與未來的應用趨勢
 
2011/09/16 Taiwan UX Summit: App設計實戰:在開始寫程式之前
2011/09/16 Taiwan UX Summit: App設計實戰:在開始寫程式之前2011/09/16 Taiwan UX Summit: App設計實戰:在開始寫程式之前
2011/09/16 Taiwan UX Summit: App設計實戰:在開始寫程式之前
 
2011/06/21 Microsoft Developer Day 2011—Design Decade
2011/06/21 Microsoft Developer Day 2011—Design Decade2011/06/21 Microsoft Developer Day 2011—Design Decade
2011/06/21 Microsoft Developer Day 2011—Design Decade
 
HP19 Mobile Design: 為行動使用者設計
HP19 Mobile Design: 為行動使用者設計HP19 Mobile Design: 為行動使用者設計
HP19 Mobile Design: 為行動使用者設計
 
Sketching User Experience—Video Sketching
Sketching User Experience—Video SketchingSketching User Experience—Video Sketching
Sketching User Experience—Video Sketching
 
How I Use Google Technology to Enhance Travel Experience
How I Use Google Technology to Enhance Travel ExperienceHow I Use Google Technology to Enhance Travel Experience
How I Use Google Technology to Enhance Travel Experience
 
20100915 學習撰寫 Google Chrome Extension
20100915 學習撰寫 Google Chrome Extension20100915 學習撰寫 Google Chrome Extension
20100915 學習撰寫 Google Chrome Extension
 
談如何發展具有破壞力的創新構想
談如何發展具有破壞力的創新構想談如何發展具有破壞力的創新構想
談如何發展具有破壞力的創新構想
 
Interaction Design & Industrial Design In 3C Industry
Interaction Design & Industrial Design In 3C IndustryInteraction Design & Industrial Design In 3C Industry
Interaction Design & Industrial Design In 3C Industry
 
Web 3.0 Intro
Web 3.0 IntroWeb 3.0 Intro
Web 3.0 Intro
 
USB 3.0 Intro
USB 3.0 IntroUSB 3.0 Intro
USB 3.0 Intro
 
Plurk Intro
Plurk IntroPlurk Intro
Plurk Intro
 
User Experience Design
User Experience DesignUser Experience Design
User Experience Design
 

Recently uploaded

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Recently uploaded (20)

ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 

20110525[Taipei GTUG] titanium mobile簡介

  • 3.
  • 6.
  • 7. HTML5+CSS+JS HTML5+CSS+JS+JS API Java, Obj-C+Native API
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13. window window webview label DOM parser window JavaScript interpreter label CSS parser HTML renderer SVG renderer hello world! Canvas renderer history manager SQLLite engine index.html render window label
  • 14. web
  • 16. JavaScript var win = Titanium.UI.createWindow({ backgroundColor:'#fff' }); var label = Titanium.UI.createLabel({ text: 'Hello World!' }); win.add(label); win.open();
  • 17. Titanium Javascript Titanium API JS to Native Bridge Native API
  • 18.
  • 19. UI API Phone API
  • 20. 50%
  • 21. Java Objective-C Titanium API
  • 22.
  • 23. SDK •Titanium Mobile SDK (1.6.2) •iOS SDK or Android SDK Developer Tool •Titanium Developer (1.2.2) •Titanium Studio (RC1) •textmate, vim...
  • 24. iOS Mac {
  • 26. Titanium Studio Breakpoint+Debugger
  • 27. Titanium javascript DOM JQuery UI Javascript window view div AddEventListener execution context
  • 29. HowIsTheWeather/ build/ android/ ... iphone/ ... CHANGELOG.txt LICENSE LICENSE.txt manifest README Resources/ android/ ... app.js iphone/ ... KS_nav_ui.png KS_nav_views.png tiapp.xml
  • 30. Hello World! var win = Titanium.UI.createWindow({ backgroundColor:'#fff' }); var label = Titanium.UI.createLabel({ text: 'Hello World!', textAlign: 'center' }); label.addEventListener('click', function(e){ Titanium.API.info('label clicked!'); }); win.add(label); win.open();
  • 33. http://goo.gl/Fj3pl UI GPS XML
  • 34. var win = Titanium.UI.createWindow({ backgroundColor:'#fff' }); var locationLabel = Titanium.UI.createLabel({ color:'#000', text:' ', font:{fontSize: 30, fontFamily:'Helvetica Neue'}, 75px textAlign:'center', width:'auto', height: 'auto', left: 15, 15px top: 75 }); var weatherIcon = Titanium.UI.createImageView({ image: 'images/mostly_cloudy.gif', width: 80, height: 80, left: 15, top: 120 });
  • 35. var temperatureLabel = Titanium.UI.createLabel({ color:'#000', text:'28°C', font:{fontSize: 90, fontFamily:'Helvetica Neue'}, textAlign:'center', width:'auto', height: 'auto', right: 15, top: 100 }); var detailLabel = Titanium.UI.createLabel({ color:'#000', text: ' n 62%n n 10 / ', font:{fontSize: 24, fontFamily:'Helvetica Neue'}, textAlign:'left', width:'auto', height: 'auto', left: 20, top: 220 }); win.add(locationLabel); win.add(weatherIcon); win.add(temperatureLabel); win.add(detailLabel); win.open();
  • 36. if (Titanium.Geolocation.locationServicesEnabled === false) { Titanium.UI.createAlertDialog({title:' ', message:' 啓 '}).show(); } else { Ti.Geolocation.purpose = "get current position"; Titanium.Geolocation.accuracy = Titanium.Geolocation.ACCURACY_THREE_KILOMETERS; Titanium.Geolocation.distanceFilter = 1000; Titanium.Geolocation.getCurrentPosition(function(e) { if (e.error) { Titanium.API.info("error: " + JSON.stringify(e.error)); return; } var latitude = e.coords.latitude; var longitude = e.coords.longitude; Ti.API.info(longitude+','+latitude); }); ... }
  • 37. function updateLocationName(lat, lng) { Titanium.Geolocation.reverseGeocoder(lat, lng, function(e) { if (e.success) { var places = e.places; if (places && places.length) { locationLabel.text = places[0].city; } else { locationLabel.text = ""; } Ti.API.debug("reverse geolocation result = "+JSON.stringify(e)); } else { Ti.UI.createAlertDialog({ title:'Reverse geo error', message:evt.error }).show(); Ti.API.info("Code translation: "+translateErrorCode(e.code)); } }); }
  • 38. Google’s secret Weather API http://www.google.com/ig/api?hl={locale}&weather=,,,{lat},{lng} http://www.google.com/ig/api?hl=zh-tw&weather=,,,25060808,121485606 <?xml version="1.0"?> <xml_api_reply version="1"> <weather module_id="0" tab_id="0" mobile_row="0" mobile_zipped="1" row="0" section="0" > <forecast_information> <city data=""/> <postal_code data=""/> <latitude_e6 data="25060808"/> <longitude_e6 data="121485606"/> <forecast_date data="2010-09-15"/> <current_date_time data="2010-09-14 23:00:00 +0000"/> <unit_system data="SI"/> </forecast_information> <current_conditions> <condition data=" "/> http://img0.gmodules.com/ <temp_f data="79"/> <temp_c data="26"/> <humidity data=" 87%"/> <icon data="/ig/images/weather/cloudy.gif"/> <wind_condition data=" / "/> </current_conditions> <forecast_conditions> <day_of_week data=" "/> <low data="26"/> <high data="35"/> <icon data="/ig/images/weather/thunderstorm.gif"/> <condition data=" "/> </forecast_conditions> ... </weather> </xml_api_reply>
  • 39. function updateWeather(lat, lng) { var xhr = Titanium.Network.createHTTPClient(); xhr.onload = function() { Ti.API.info('weather xml ' + this.responseXML + ' text ' + this.responseText); //var doc = this.responseXML.documentElement; encoding bug on Android var doc = Titanium.XML.parseString(this.responseText).documentElement; var condition = doc.evaluate("//weather/current_conditions/condition").item (0).getAttribute('data'); Ti.API.info(condition); ... temperatureLabel.text = temp_c + '°C'; weatherIcon.image = icon; detailLabel.text = condition + 'n'; detailLabel.text += humidity + 'n'; detailLabel.text += wind_condition.split(' ')[0] + 'n'; detailLabel.text += wind_condition.split(' ')[1] + 'n'; }; var url = 'http://www.google.com/ig/api?hl=zh-tw&weather=,,,'+parseInt(lat*1000000, 10)+','+parseInt(lng*1000000, 10); Ti.API.info(url); xhr.open('GET', url); xhr.send();
  • 40. function getCurrentWeather() { if (Titanium.Geolocation.locationServicesEnabled === false) { Titanium.UI.createAlertDialog({title:' ', message:' 啓 '}).show(); } else { Ti.Geolocation.purpose = " "; Titanium.Geolocation.accuracy = Titanium.Geolocation.ACCURACY_BEST; Titanium.Geolocation.distanceFilter = 1000; Titanium.Geolocation.getCurrentPosition(function(e) { if (e.error) { Titanium.API.info("error: " + JSON.stringify(e.error)); Titanium.UI.createAlertDialog({title:' ', message: e.error.message}).show(); detailLabel.text = ' '; return; } var latitude = e.coords.latitude; var longitude = e.coords.longitude; Ti.API.info(longitude+','+latitude); updateLocationName(latitude, longitude); updateWeather(latitude, longitude); }); } }
  • 42. var settingWin = Titanium.UI.createWindow({ backgroundColor: '#999' }); var aboutWebview = Titanium.UI.createWebView({ url: 'about.html', ... }); settingWin.add(aboutWebview); var doneButton = Titanium.UI.createButton({ title: ' ', ... }); settingWin.add(doneButton); doneButton.addEventListener('click', function(e){ if(Titanium.Platform.osname === 'iphone') { settingWin.close({transition: Ti.UI.iPhone.AnimationStyle.FLIP_FROM_RIGHT}); mainWin.open(); }else if(Titanium.Platform.osname === 'android') { mainWin.open(); settingWin.close(); } getCurrentWeather(); });
  • 43. <!doctype html> <html lang="zh-tw"> <head> <meta charset="utf-8"> <title>About</title> <meta name="description" content="About the app"> <meta name="viewport" content="width=320"/> <meta name="author" content="lis186"> <link rel="stylesheet" href="screen.css"> </head> <body> <h1> </h1> <img src='appicon.png'> <p> 1.0</p> <p>Powered by Titanium Mobile.</p> </body> </html> about.js
  • 44. if(Titanium.Platform.osname === 'iphone') { var unitTabbedBar = Titanium.UI.createTabbedBar({ labels:['°C', '°F'], style:Titanium.UI.iPhone.SystemButtonStyle.BAR, ... }); unitTabbedBar.addEventListener('click', function(e){ if(e.index === 0) { Titanium.App.Properties.setString('tempUnit', 'c'); }else if (e.index === 1){ Titanium.App.Properties.setString('tempUnit', 'f'); } }); settingWin.add(unitTabbedBar); var settingButton = Titanium.UI.createButton({ ... style: Titanium.UI.iPhone.SystemButton.INFO_DARK }); mainWin.add(settingButton); }
  • 45. if(Titanium.Platform.osname === 'android') { var cButton = Titanium.UI.createButton({ title: '°C', ... }); var fButton = Titanium.UI.createButton({ title: '°F', ... }); cButton.addEventListener('click', function(e){ Titanium.App.Properties.setString('tempUnit', 'c'); cButton.enabled = false; fButton.enabled = true; }); fButton.addEventListener('click', function(e){ Titanium.App.Properties.setString('tempUnit', 'f'); cButton.enabled = true; fButton.enabled = false; }); settingWin.add(cButton); settingWin.add(fButton); }
  • 46. if(Titanium.Platform.osname === 'iphone') { mainWin.add(settingButton); settingButton.addEventListener('click', function(e){ settingWin.open({ transition: Ti.UI.iPhone.AnimationStyle.FLIP_FROM_LEFT }); var tempUnit = Titanium.App.Properties.getString('tempUnit', 'c'); if(tempUnit === 'c') { unitTabbedBar.index = 0; }else if(tempUnit === 'f') { unitTabbedBar.index = 1; } mainWin.close(); }); }
  • 47. if(Titanium.Platform.osname === 'android') { Titanium.Android.currentActivity.onCreateOptionsMenu = function(e) { Titanium.API.info("create menu"); var menu = e.menu; var refreshMenuItem = menu.add({ title: ' ' }); var settingMenuItem = menu.add({ title: ' ' }); refreshMenuItem.addEventListener("click", function(e) { getCurrentWeather(); }); settingMenuItem.addEventListener("click", function(e) { indicator.hide(); settingWin.open(); var tempUnit = Titanium.App.Properties.getString('tempUnit', 'c'); if(tempUnit === 'c') { cButton.enabled = false; fButton.enabled = true; }else if(tempUnit === 'f') { cButton.enabled = true; fButton.enabled = false; } mainWin.close(); }); }; }
  • 48. if(Titanium.Platform.osname === 'iphone') { var service; Titanium.App.addEventListener('pause',function(e) { Ti.API.info('pause'); service = Titanium.App.iOS.registerBackgroundService({ url: 'bgjob.js', tempUnit: Titanium.App.Properties.getString('tempUnit', 'c') }); Titanium.API.info("registered background service = "+service); }); Titanium.App.addEventListener('resumed',function(e) { Ti.API.info('resumed'); if(service != null){ getCurrentWeather(); service.stop(); service.unregister(); Ti.API.info('Stop background service'); } }); }
  • 49. function updateWeather(lat, lng) { var xhr = Titanium.Network.createHTTPClient(); bgjob.js xhr.onload = function() { var tempUnit = Titanium.App.currentService.tempUnit; ... if(tempUnit === 'c') { Titanium.UI.iPhone.appBadge = temp_c; Ti.API.info('Update badge:' + temp_c); }else if(tempUnit === 'f') { Titanium.UI.iPhone.appBadge = temp_f; Ti.API.info('Update badge:' + temp_f); } }; var url = 'http://www.google.com/ig/api?hl=zh-tw&weather=,,,'+ parseInt(lat*1000000, 10)+','+parseInt(lng*1000000, 10); Ti.API.info(url); xhr.open('GET', url); xhr.send(); } function getCurrentWeather() { ... } ... Ti.API.info('starting background service'); var updateInterval = setInterval(getCurrentWeather, 300000);
  • 50. if(Titanium.Platform.osname === 'android') { Titanium.Android.currentActivity.addEventListener('resume', function(e) { Ti.API.info("resumed"); getCurrentWeather(); }); }
  • 51.
  • 52.
  • 53. !== “Write Once, Run Everywhere”
  • 55. Titanium Mobile SDK http://goo.gl/Se1dF Kitchen Sink http://goo.gl/5v6dJ http://goo.gl/Fj3pl
  • 56. Titanium Mobile 6/9 http://www.lis186.com/?p=2140
  • 57. Hiring! We’re Titanium SDK Developer Titanium Evangelist http://ti.herxun.co/?page_id=66