Apps de consumo de APIs de Internet para mobile phones
Upcoming SlideShare
Loading in...5
×
 

Apps de consumo de APIs de Internet para mobile phones

on

  • 1,473 views

Web Apps é um modo fácil e rápido de se construir aplicações para Série 40, entretanto existe o desafio de fazer uma App consumir APIs de Internet. Este webinar tem como objetivo mostrar ...

Web Apps é um modo fácil e rápido de se construir aplicações para Série 40, entretanto existe o desafio de fazer uma App consumir APIs de Internet. Este webinar tem como objetivo mostrar métodos e boas práticas de consumo de APIs de Internet para a Web Apps Série 40.

Statistics

Views

Total Views
1,473
Views on SlideShare
1,473
Embed Views
0

Actions

Likes
1
Downloads
4
Comments
1

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • Rever a gravação do Webinar : http://forumnokia.adobeconnect.com/p6tbxi8ses0/
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Apps de consumo de APIs de Internet para mobile phones Apps de consumo de APIs de Internet para mobile phones Presentation Transcript

  • ECOSYSTEM1
  • Interação Nokia Developer http://www.developer.nokia.com Twitter: @nokiadev_brasil Grupo Devs S40 no Nokia Developer http://www.developer.nokia.com/Co mmunity/Discussion/group.php?grou pid=1142
  • Apps de consumo deAPIs de Internet paramobile phonesRaymundo JuniorDesenvolvedor – INdTEvangelista Nokia de Tecnologia3
  • Conteúdo• Device S40• Estrutura do Projeto• Main• Template• Lib• Service• JSON Viewer• View1• View2• View3• Estudo de Caso 4
  • Device S40Nokia Developer• http://www.developer.nokia.com/Devices/Device_sp ecifications/?filter1=s405
  • Estrutura do Projeto6
  • Mainvar main = {init : function(){view1.init();}};7
  • Templatevar template = {item_view1 : <div class="item-view1"onclick="mwl.switchClass(#content,view*,view2);view2.init({ID});">{TEXT}</div>,item_view2 : <divonclick="mwl.switchClass(#content,view*,view3);view3.init({ID});">{TEXT}</div>,item_view3 : <div>{TEXT}</div>};8
  • Libvar lib = {call: function(url, successCallback, errorCallback){var request = new XMLHttpRequest();try {request.open("GET", url, true);request.onreadystatechange = function(){if (request.readyState == 4) {if (request.status == 200) {successCallback(eval(( + request.responseText + )));} else {errorCallback("error status: " + request.status);}}};request.send(null);} catch (e) {errorCallback("error try: " + e);}}}; 9
  • Servicevar BASE_URL = http://justkaws.com/json/;10
  • Servicevar URLS = {plataformas : index.php?opcao=plataformas,devices : index.php?opcao=devices&id={ID},device : index.php?opcao=device&id={ID}};11
  • ServicegetView2 : function(id, success, error) {var url = service.getUrl(devices).replace("{ID}",id);lib.call(url, success, error);},getView3 : function(id, success, error) {var url = service.getUrl(device).replace("{ID}", id);lib.call(url, success, error);}12
  • Servicevar BASE_URL = http://justkaws.com/json/;var URLS = {plataformas : index.php?opcao=plataformas,devices : index.php?opcao=devices&id={ID},device : index.php?opcao=device&id={ID}};var service = { getUrl: function(id) { return BASE_URL + URLS[id]; }, getView1 : function(success, error) { var url = service.getUrl(plataformas); lib.call(url, success, error);},getView2 : function(id, success, error) {var url = service.getUrl(devices).replace("{ID}", id);lib.call(url, success, error);},getView3 : function(id, success, error) {var url = service.getUrl(device).replace("{ID}", id);lib.call(url, success, error);}}; 13
  • JSON Viewer LINK: http://jsonviewer.stack.hu/14
  • JSON Viewer LINK: http://jsonviewer.stack.hu/15
  • View1init : function(){document.getElementById(title-view1).innerHTML ="Plataformas NOKIA";service.getView1(function(data){view1.render(data);},function(data){document.getElementById(view-content1).innerHTML =data;});},16
  • View1render : function(data){var dados = data.json;var limit = dados.length; var itemTemplate = template.item_view1; var itens = "";for (var x = 0; x< limit; x++){var params = dados[x].platform + [!{#?#?#}!] + dados[x].id;itens += itemTemplate.replace("{TEXT}",dados[x].platform).replace("{ID}", params);}document.getElementById(view-content1).innerHTML = itens;}17
  • View1var view1 = {init : function(){document.getElementById(title-view1).innerHTML = "Plataformas NOKIA";service.getView1(function(data){view1.render(data);},function(data){document.getElementById(view-content1).innerHTML = data;});},render : function(data){var dados = data.json;var limit = dados.length; var itemTemplate = template.item_view1; var itens = "";for (var x = 0; x< limit; x++){var params = dados[x].platform + [!{#?#?#}!] + dados[x].id;itens += itemTemplate.replace("{TEXT}", dados[x].platform).replace("{ID}", params);}document.getElementById(view-content1).innerHTML = itens;}}; 18
  • View2init : function(args){var vetor = args.split([!{#?#?#}!]);document.getElementById(title-view2).innerHTML = vetor[0];service.getView2( vetor[1],function(data){view2.render(data);},function(data){document.getElementById(view-content2).innerHTML = data;});}, 19
  • View2render : function(data){var dados = data.json;var limit = dados.length;var itemTemplate = template.item_view2;var itens = "";for (var x = 0; x< limit; x++){var params = dados[x].name + [!{#?#?#}!] + dados[x].id;itens += itemTemplate.replace("{TEXT}",dados[x].name).replace("{ID}", params);}document.getElementById(view-content2).innerHTML = itens;}20
  • View2var view2 = {init : function(args){var vetor = args.split([!{#?#?#}!]);document.getElementById(title-view2).innerHTML = vetor[0];service.getView2( vetor[1],function(data){view2.render(data);},function(data){document.getElementById(view-content2).innerHTML = data;});},render : function(data){var dados = data.json;var limit = dados.length;var itemTemplate = template.item_view2;var itens = "";for (var x = 0; x< limit; x++){var params = dados[x].name + [!{#?#?#}!] + dados[x].id;itens += itemTemplate.replace("{TEXT}", dados[x].name).replace("{ID}", params);}document.getElementById(view-content2).innerHTML = itens;}}; 21
  • View3init : function(args){var vetor = args.split([!{#?#?#}!]);document.getElementById(title-view3).innerHTML = vetor[0];service.getView3( vetor[1],function(data){view3.render(data);},function(data){document.getElementById(view-content3).innerHTML = data;});}, 22
  • View3render : function(data){var dados = data.json;var limit = dados.length;var itemTemplate = template.item_view3;var itens = "";for (var x = 0; x< limit; x++){itens += itemTemplate.replace("{TEXT}", dados[x].label + ": "+ dados[x].value);}document.getElementById(view-content3).innerHTML =itens;}23
  • View3var view3 = {init : function(args){var vetor = args.split([!{#?#?#}!]);document.getElementById(title-view3).innerHTML = vetor[0];service.getView3( vetor[1],function(data){view3.render(data);},function(data){document.getElementById(view-content3).innerHTML = data;});},render : function(data){var dados = data.json;var limit = dados.length;var itemTemplate = template.item_view3;var itens = "";for (var x = 0; x< limit; x++){itens += itemTemplate.replace("{TEXT}", dados[x].label + ": " + dados[x].value);}document.getElementById(view-content3).innerHTML = itens;}}; 24
  • Estudo de Caso25
  • Obrigado!Raymundo JuniorDesenvolvedor – INdTEvangelista de TecnologiaE-mail: raymundo.ferreira-junior@indt.org.brTwitter: twitter.com/justkawsSite: justkaws.comBlog: blog.justkaws.com26