SlideShare a Scribd company logo
Mobile Java with GWT
(and alternatives)
Murat Yener & Alex Theedom
@yenerm @alextheedom
who (the hell) am I?!?
Java, Flex, GWT, iOS, Android developer
Principle Mentor at Eteration
Eclipse Committer
GDG (GTUG) Istanbul Organizer
Conference Speaker
Mobile App Developer at Intel
as a mobile developer
what (the hell) is this talk
about?!?
The fifth element... The Webview..
HTML5 mobile frameworks
Phonegap
keeping native UX
so an HTML5 talk???
Facebook killed HTML5
app.. Zuckerberg said
HTML5 is not there yet!!
try fastbook from sencha
fb.html5isready.com
LinkedIn moved to native!!
so did they just fix it??
mobile apps!
Android
iPhone
Blackberry
Windows Phone
Tablets?!?
Hybrid Apps: Teaching the old dog new tricks?
html5 apps in native shell?? nuts!! this
is too complicated!!
have many of you have web development
experience?
how many of you develop native apps?
how many of you don’t like web
development just because of javascript??
but it is slow!!
building games?
3d physics?
image or sound processing?
...
no most of the time we just do this!
wait is this really web?
Angry Birds for Chrome (GWT)
Quake on Mobile (requires Chrome Beta for
WebGL) http://mediatojicode.com/q3bsp/
“We started with the existing Jake2 Java port of the Quake II engine,
then used the Google Web Toolkit (along with WebGL, WebSockets,
and a lot of refactoring) to cross-compile it into Javascript. You can see
the results in the video above — we were honestly a bit surprised when
we saw it pushing over 30 frames per second on our laptops (your
mileage may vary)!” from Google Code Blog...
Chromium WebView
Mobile (friendly) HTML5
Frameworks
jQueryMobile
Sencha
Zepto
mGWT
GWT 101: java to
javascript?
GWT compiler does the
magic
Optimized high
performance javascript
cross browser
compability (upto ie6)
not really mobile look’n
feel :(
UI & UX
gwt frameworks?
gwt-mobile-webkit: database, storage,
geolocation, widgets(?)
http://code.google.com/p/gwt-mobile-webkit/
gwtmobile: GwtMobile-UI, Gwtmobile-
Persistence, GwtMobile-PhoneGap(!)
http://code.google.com/p/gwtmobile/
touch4j: Sencha,
http://www.emitrom.com/gwt4touch
mgwt: UI Widgets, GWT-Phonegap
http://code.google.com/p/mgwt/
so what is mGWT
mobile widget library on gwt
native looking widgets for each platform
maven friendly
mvp ready (maven archetype)
and with gwt-phonegap
where to start?
get the source https://code.google.com/p/mgwt
or download the jar
or just use maven
<dependency>
<groupId>com.googlecode.mgwt</groupId>
<artifactId>mgwt</artifactId>
<version>1.1.2</version>
</dependency>
Hello World!!
public class MGWTEntryPoint implements EntryPoint {
public void onModuleLoad() {
// set viewport and other settings for mobile
MGWT.applySettings(MGWTSettings.getAppSetting());
// build animation helper and attach it
AnimationHelper animationHelper = new AnimationHelper();
RootPanel.get().add(animationHelper);
// build some UI
LayoutPanel layoutPanel = new LayoutPanel();
Button button = new Button("Hello mgwt");
layoutPanel.add(button);
// animate
animationHelper.goTo(layoutPanel, Animation.SLIDE);
}
}
using other libs:
ex. maps..
Google Maps Ver 2.0:
http://code.google.com/p/gwt-google-
apis/
Google Maps Ver 3.0:
http://code.google.com/p/gwt-google-
maps-v3/
No Javascript so far!
<inherits name='com.google.gwt.maps.GoogleMaps' />
add a litte spice:
phonegap
geolocation
camera
accelerator
compass
phonebook
file system
even nfc
phonegap in action
...
Button button = new Button("Hello mgwt");
button().addTapHandler(new TapHandler() {
@Override
public void onTap(TapEvent event) {
phoneGap.getNotification().alert("Done!!");
}
});
layoutPanel.add(button);
...
phonegap, in real action
phoneGap.getGeolocation().watchPosition(geolocationOptions, new MyGeolocationCallback(){
@Override
public void onSuccess(Position position) {
// check accuracy
if (position.getCoordinates().getAccuracy() > 11) {
raceView.getLabel().setText("Error: Accuracy");
}
// geolocation returns mps, multiply with 3.6 to convert to kph
double speed = 3.6 * position.getCoordinates().getSpeed();
if (speed > 0.2) {// if going
raceView.getLabel().setText(speed + "km @" + position.getCoordinates().getAccuracy());
currentLocation = position;
// got the position now can start!
start();
// stop if the threshold is reached
if (isGoing && speed >= 60) {
MgwtAppEntryPoint.phoneGap.getGeolocation().clearWatch(geolocationWatcher);
endLocation = position;
calculate();
}
} else {// if stoped
raceView.getLabel().setText("get ready!!");
isGoing = false;
}
}
@Override
public void onFailure(PositionError error) {
MgwtAppEntryPoint.phoneGap.getNotification().alert("Problem getting location");
}
});
even more...
public void onTap(TapEvent event) {
final MCheckBox check = ((MCheckBox) event.getSource());
if (check.getValue()) {
if (TWITTER.equalsIgnoreCase(type))
profileView.getBrowser().showWebPage(Service.BASE_URL + "auth/twitter");
else if (FACEBOOK.equalsIgnoreCase(type))
profileView.getBrowser().showWebPage(Service.BASE_URL + "auth/facebook");
profileView.getBrowser().addLocationChangeHandler(new
ChildBrowserLocationChangedHandler() {
@Override
public void onLocationChanged(ChildBrowserLocationChangedEvent event) {
//Do the login...
}
});
}
}
}
going fancy, mvp!
code your UI in the View preferably in xml
via UIBinder
and your logic in the controller (activity)
sound familiar?
easy navigation
lots of boilerplate code
mgwt, advanced
MVP
Model
View
Presenter
Maven Archetype
connecting to backend
GWT-RPC (yeah, it rocks), but in native package?
JSONP with with RequestBuilder & Autobean
JsonpRequestBuilder jsonp = new JsonpRequestBuilder();
String url = URL.encode(JSON_URL + "/sendData/" + “HelloWorld”);
jsonp.requestObject(url, new AsyncCallback<JavaScriptObject>() {
@Override
public void onFailure(Throwable caught) {
MgwtAppEntryPoint.phoneGap.getNotification().alert(caught.getMessage());
}
@Override
public void onSuccess(JavaScriptObject result) {
JSONObject jsObj = new JSONObject(result);
AutoBean<Score[]> bean = AutoBeanCodex.decode(factory, Score[].class, jsObj.toString());
Score[] scores = bean.as();
scoresCallback.onResponse(scores);
}
});
accessing native js
can use any existing javascript
use javascript in type safe way
BUT!! don’t mess touch events!!
AND beware you are not in the safe and
optimized zone anymore!!
JSNI
public native static String key(int index) /*-{
return $wnd.localStorage.key(index);
}-*/;
public native static void setItem(String key, String value) /*-{
$wnd.localStorage.setItem(key, value);
}-*/;
public native static String getItem(String key) /*-{
return $wnd.localStorage.getItem(key);
}-*/;
public native static void removeItem(String key) /*-{
$wnd.localStorage.removeItem(key);
}-*/;
public native static void clear() /*-{
$wnd.localStorage.clear();
}-*/;
building my swipe panel
just like the one in sencha
wrapped swipeview from
cubiq
mgwt groups
https://groups.google.com/forum/?fromgroups#!forum/mgwt
daniel to rescue..
here it is
gwtquery
coming from jQuery, no problem!
public void onModuleLoad() {
//Hide the text and set the width and append an h1 element
$("#text").hide()
.css("width", "400px")
.prepend("<h1>GwtQuery Rocks !</h1>");
//add a click handler on the button
$("button").click(new Function(){
public void f() {
//display the text with effects and animate its background color
$("#text").as(Effects)
.clipDown()
.animate("backgroundColor: 'yellow'", 500)
.delay(1000)
.animate("backgroundColor: '#fff'", 1500);
}
});
}
skinning
default themes for
Android (>4.0)
iOS/iOS retina (<7.0)
Blackberry
easy to create yours
https://code.google.com/p/mgwt/wiki/Styling
//append your own css as last thing in the head
MGWTStyle.injectStyleSheet("yourcssfile.css");
wait, css in java?!?
.mgwt-Button {
display: inline-block;
float: left;
width: 145px;
height: 100px;
border: 1px solid rgba(0,0,0,0.23);
background: #ff6600;
border-radius: 6px;
box-shadow: inset -1px 0px 0px rgba(255,255,255,0.41), inset
1px 0px 0px rgba(255,255,255,0.21), inset 0px -1px 0px
rgba(0,0,0,0.21), inset 0px 1px 0px rgba(255,255,255,0.41), 0px 1px
2px rgba(0,0,0,0.21);
text-align: center;
font-size: 14px;
margin: 5px;
font-weight: bold;
text-shadow: 0px 1px 1px rgba(0,0,0,0.49);
color: white;
line-height: 124px;
}
debugging
first class java debugging in your
IDE
GWT pretty compile and debug
javascript in your browser
use source maps and debug java
in your browser!!
use remote debugging to debug on
mobile devices
what about others?
iOS, works like charm.. pretty much native
android, near native experience
blackberry
windows phone
tablets?
desktop??
what can i really build?
anything!
but why not going native for games
many widgets.. lists, carousels, forms
dev friendly, you know java? just dive in!
make use of current js
windows phone? seriously?!?
</slides>
GDG Istanbul (every 3. or 4. Saturday)
Interested in OSGi? No? ok, i thought so…
and GWT.create at San Francisco
murat@muratyener.com
@yenerm
devchronicles.com
40%
discount with promo
code
VBK43
when ordering
through
wiley.com
valid until end of
December 2015
who (the hell) am I?!?
Java (Spring/EE) developer
Microservices
Jersey Coders Mentor
Conference Speaker
Cross-platform Mobile
Development
Develop once run on multiple platforms
Choose just ‘one’ language
Two Approaches
Hybrid
Cross compile
Tabris
Hybrid
Java
.war
JSON
Lets see some code
UI coded in Java
Rendered in native UI
Codename One
Compile to native
C#
JDK 1.3
iOS
Windows Phone
C
Java 5
Lets see some code
Familiar to Swing
and GWT coders
Java 8 next release
Oracle Mobile Application
Framework (MAF)
Only Jdeveloper or Eclipse
Lightweight JVM
Lets see some code
Flow define GUI
Device feature via
DeviceManager

More Related Content

What's hot

Web Apps and more
Web Apps and moreWeb Apps and more
Web Apps and more
Yan Shi
 
GWT widget development
GWT widget developmentGWT widget development
GWT widget development
pgt technology scouting GmbH
 
L’enjeu du mobile pour le développeur Web, et comment Mozilla va vous aider
L’enjeu du mobile pour le développeur Web,  et comment Mozilla va vous aiderL’enjeu du mobile pour le développeur Web,  et comment Mozilla va vous aider
L’enjeu du mobile pour le développeur Web, et comment Mozilla va vous aider
Tristan Nitot
 
High Performance HTML5 (SF HTML5 UG)
High Performance HTML5 (SF HTML5 UG)High Performance HTML5 (SF HTML5 UG)
High Performance HTML5 (SF HTML5 UG)
Steve Souders
 
Node.js Authentication and Data Security
Node.js Authentication and Data SecurityNode.js Authentication and Data Security
Node.js Authentication and Data Security
Tim Messerschmidt
 
How to Win at UI Development in the World of Microservices - THAT Conference ...
How to Win at UI Development in the World of Microservices - THAT Conference ...How to Win at UI Development in the World of Microservices - THAT Conference ...
How to Win at UI Development in the World of Microservices - THAT Conference ...
Matt Raible
 
Preconnect, prefetch, prerender...
Preconnect, prefetch, prerender...Preconnect, prefetch, prerender...
Preconnect, prefetch, prerender...
MilanAryal
 
Microservices for the Masses with Spring Boot, JHipster, and OAuth - Utah JUG...
Microservices for the Masses with Spring Boot, JHipster, and OAuth - Utah JUG...Microservices for the Masses with Spring Boot, JHipster, and OAuth - Utah JUG...
Microservices for the Masses with Spring Boot, JHipster, and OAuth - Utah JUG...
Matt Raible
 
不只自動化而且更敏捷的Android開發工具 gradle mopcon
不只自動化而且更敏捷的Android開發工具 gradle mopcon不只自動化而且更敏捷的Android開發工具 gradle mopcon
不只自動化而且更敏捷的Android開發工具 gradle mopcon
sam chiu
 
Top Ten Tips for HTML5/Mobile Web Development
Top Ten Tips for HTML5/Mobile Web DevelopmentTop Ten Tips for HTML5/Mobile Web Development
Top Ten Tips for HTML5/Mobile Web Development
Simon Guest
 
Amp by Google: The Present And Future Of Quick Content Delivery
Amp by Google: The Present And Future Of Quick Content DeliveryAmp by Google: The Present And Future Of Quick Content Delivery
Amp by Google: The Present And Future Of Quick Content Delivery
Raunak Hajela
 
Front-End 개발의 괜찮은 선택 ES6 & React
Front-End 개발의 괜찮은 선택  ES6 & ReactFront-End 개발의 괜찮은 선택  ES6 & React
Front-End 개발의 괜찮은 선택 ES6 & React
지수 윤
 
Mobile Development with Ionic, React Native, and JHipster - ACGNJ Java Users ...
Mobile Development with Ionic, React Native, and JHipster - ACGNJ Java Users ...Mobile Development with Ionic, React Native, and JHipster - ACGNJ Java Users ...
Mobile Development with Ionic, React Native, and JHipster - ACGNJ Java Users ...
Matt Raible
 
How fast are we going now?
How fast are we going now?How fast are we going now?
How fast are we going now?
Steve Souders
 
Souders WPO Web2.0Expo
Souders WPO Web2.0ExpoSouders WPO Web2.0Expo
Souders WPO Web2.0Expoguest0b3d92d
 
Use Web Skills To Build Mobile Apps
Use Web Skills To Build Mobile AppsUse Web Skills To Build Mobile Apps
Use Web Skills To Build Mobile Apps
Nathan Smith
 
Windows Azure Toolkit for iOS
Windows Azure Toolkit for iOSWindows Azure Toolkit for iOS
Windows Azure Toolkit for iOSSimon Guest
 
Developing for Mobile
Developing for MobileDeveloping for Mobile
Developing for Mobile
Remy Sharp
 
Building an HTML5 Video Player
Building an HTML5 Video PlayerBuilding an HTML5 Video Player
Building an HTML5 Video Player
Jim Jeffers
 
Spring Boot APIs and Angular Apps: Get Hip with JHipster! KCDC 2019
Spring Boot APIs and Angular Apps: Get Hip with JHipster! KCDC 2019Spring Boot APIs and Angular Apps: Get Hip with JHipster! KCDC 2019
Spring Boot APIs and Angular Apps: Get Hip with JHipster! KCDC 2019
Matt Raible
 

What's hot (20)

Web Apps and more
Web Apps and moreWeb Apps and more
Web Apps and more
 
GWT widget development
GWT widget developmentGWT widget development
GWT widget development
 
L’enjeu du mobile pour le développeur Web, et comment Mozilla va vous aider
L’enjeu du mobile pour le développeur Web,  et comment Mozilla va vous aiderL’enjeu du mobile pour le développeur Web,  et comment Mozilla va vous aider
L’enjeu du mobile pour le développeur Web, et comment Mozilla va vous aider
 
High Performance HTML5 (SF HTML5 UG)
High Performance HTML5 (SF HTML5 UG)High Performance HTML5 (SF HTML5 UG)
High Performance HTML5 (SF HTML5 UG)
 
Node.js Authentication and Data Security
Node.js Authentication and Data SecurityNode.js Authentication and Data Security
Node.js Authentication and Data Security
 
How to Win at UI Development in the World of Microservices - THAT Conference ...
How to Win at UI Development in the World of Microservices - THAT Conference ...How to Win at UI Development in the World of Microservices - THAT Conference ...
How to Win at UI Development in the World of Microservices - THAT Conference ...
 
Preconnect, prefetch, prerender...
Preconnect, prefetch, prerender...Preconnect, prefetch, prerender...
Preconnect, prefetch, prerender...
 
Microservices for the Masses with Spring Boot, JHipster, and OAuth - Utah JUG...
Microservices for the Masses with Spring Boot, JHipster, and OAuth - Utah JUG...Microservices for the Masses with Spring Boot, JHipster, and OAuth - Utah JUG...
Microservices for the Masses with Spring Boot, JHipster, and OAuth - Utah JUG...
 
不只自動化而且更敏捷的Android開發工具 gradle mopcon
不只自動化而且更敏捷的Android開發工具 gradle mopcon不只自動化而且更敏捷的Android開發工具 gradle mopcon
不只自動化而且更敏捷的Android開發工具 gradle mopcon
 
Top Ten Tips for HTML5/Mobile Web Development
Top Ten Tips for HTML5/Mobile Web DevelopmentTop Ten Tips for HTML5/Mobile Web Development
Top Ten Tips for HTML5/Mobile Web Development
 
Amp by Google: The Present And Future Of Quick Content Delivery
Amp by Google: The Present And Future Of Quick Content DeliveryAmp by Google: The Present And Future Of Quick Content Delivery
Amp by Google: The Present And Future Of Quick Content Delivery
 
Front-End 개발의 괜찮은 선택 ES6 & React
Front-End 개발의 괜찮은 선택  ES6 & ReactFront-End 개발의 괜찮은 선택  ES6 & React
Front-End 개발의 괜찮은 선택 ES6 & React
 
Mobile Development with Ionic, React Native, and JHipster - ACGNJ Java Users ...
Mobile Development with Ionic, React Native, and JHipster - ACGNJ Java Users ...Mobile Development with Ionic, React Native, and JHipster - ACGNJ Java Users ...
Mobile Development with Ionic, React Native, and JHipster - ACGNJ Java Users ...
 
How fast are we going now?
How fast are we going now?How fast are we going now?
How fast are we going now?
 
Souders WPO Web2.0Expo
Souders WPO Web2.0ExpoSouders WPO Web2.0Expo
Souders WPO Web2.0Expo
 
Use Web Skills To Build Mobile Apps
Use Web Skills To Build Mobile AppsUse Web Skills To Build Mobile Apps
Use Web Skills To Build Mobile Apps
 
Windows Azure Toolkit for iOS
Windows Azure Toolkit for iOSWindows Azure Toolkit for iOS
Windows Azure Toolkit for iOS
 
Developing for Mobile
Developing for MobileDeveloping for Mobile
Developing for Mobile
 
Building an HTML5 Video Player
Building an HTML5 Video PlayerBuilding an HTML5 Video Player
Building an HTML5 Video Player
 
Spring Boot APIs and Angular Apps: Get Hip with JHipster! KCDC 2019
Spring Boot APIs and Angular Apps: Get Hip with JHipster! KCDC 2019Spring Boot APIs and Angular Apps: Get Hip with JHipster! KCDC 2019
Spring Boot APIs and Angular Apps: Get Hip with JHipster! KCDC 2019
 

Viewers also liked

Devoxx UK 2015: How Java EE has changed pattern implementation
Devoxx UK 2015: How Java EE has changed pattern implementationDevoxx UK 2015: How Java EE has changed pattern implementation
Devoxx UK 2015: How Java EE has changed pattern implementation
Alex Theedom
 
Java EE changes design pattern implementation: JavaDays Kiev 2015
Java EE changes design pattern implementation: JavaDays Kiev 2015Java EE changes design pattern implementation: JavaDays Kiev 2015
Java EE changes design pattern implementation: JavaDays Kiev 2015
Alex Theedom
 
Java EE revisits design patterns
Java EE revisits design patterns Java EE revisits design patterns
Java EE revisits design patterns
Alex Theedom
 
Java days Lviv 2015
Java days Lviv 2015Java days Lviv 2015
Java days Lviv 2015
Alex Theedom
 
Jersey Coders New Term Introduction
Jersey Coders New Term IntroductionJersey Coders New Term Introduction
Jersey Coders New Term Introduction
Alex Theedom
 
Java EE revisits design patterns
Java EE revisits design patternsJava EE revisits design patterns
Java EE revisits design patterns
Alex Theedom
 
Gwt training presentation
Gwt training presentationGwt training presentation
Gwt training presentation
MUFIX Community
 
SE2016 - Java EE revisits design patterns 2016
SE2016 - Java EE revisits design patterns 2016SE2016 - Java EE revisits design patterns 2016
SE2016 - Java EE revisits design patterns 2016
Alex Theedom
 
jDays Sweden 2016
jDays Sweden 2016jDays Sweden 2016
jDays Sweden 2016
Alex Theedom
 
Java EE 8: What Servlet 4 and HTTP2 Mean
Java EE 8: What Servlet 4 and HTTP2 MeanJava EE 8: What Servlet 4 and HTTP2 Mean
Java EE 8: What Servlet 4 and HTTP2 Mean
Alex Theedom
 

Viewers also liked (10)

Devoxx UK 2015: How Java EE has changed pattern implementation
Devoxx UK 2015: How Java EE has changed pattern implementationDevoxx UK 2015: How Java EE has changed pattern implementation
Devoxx UK 2015: How Java EE has changed pattern implementation
 
Java EE changes design pattern implementation: JavaDays Kiev 2015
Java EE changes design pattern implementation: JavaDays Kiev 2015Java EE changes design pattern implementation: JavaDays Kiev 2015
Java EE changes design pattern implementation: JavaDays Kiev 2015
 
Java EE revisits design patterns
Java EE revisits design patterns Java EE revisits design patterns
Java EE revisits design patterns
 
Java days Lviv 2015
Java days Lviv 2015Java days Lviv 2015
Java days Lviv 2015
 
Jersey Coders New Term Introduction
Jersey Coders New Term IntroductionJersey Coders New Term Introduction
Jersey Coders New Term Introduction
 
Java EE revisits design patterns
Java EE revisits design patternsJava EE revisits design patterns
Java EE revisits design patterns
 
Gwt training presentation
Gwt training presentationGwt training presentation
Gwt training presentation
 
SE2016 - Java EE revisits design patterns 2016
SE2016 - Java EE revisits design patterns 2016SE2016 - Java EE revisits design patterns 2016
SE2016 - Java EE revisits design patterns 2016
 
jDays Sweden 2016
jDays Sweden 2016jDays Sweden 2016
jDays Sweden 2016
 
Java EE 8: What Servlet 4 and HTTP2 Mean
Java EE 8: What Servlet 4 and HTTP2 MeanJava EE 8: What Servlet 4 and HTTP2 Mean
Java EE 8: What Servlet 4 and HTTP2 Mean
 

Similar to Mobile Java with GWT: Still "Write Once, Run Everywhere"

Fake it 'til you make it
Fake it 'til you make itFake it 'til you make it
Fake it 'til you make it
Jonathan Snook
 
HTML5 and Other Modern Browser Game Tech
HTML5 and Other Modern Browser Game TechHTML5 and Other Modern Browser Game Tech
HTML5 and Other Modern Browser Game Tech
vincent_scheib
 
Accelerated Adoption: HTML5 and CSS3 for ASP.NET Developers
Accelerated Adoption: HTML5 and CSS3 for ASP.NET DevelopersAccelerated Adoption: HTML5 and CSS3 for ASP.NET Developers
Accelerated Adoption: HTML5 and CSS3 for ASP.NET Developers
Todd Anglin
 
Html5 on Mobile(For Developer)
Html5 on Mobile(For Developer)Html5 on Mobile(For Developer)
Html5 on Mobile(For Developer)
Adam Lu
 
DIY: Computer Vision with GWT.
DIY: Computer Vision with GWT.DIY: Computer Vision with GWT.
DIY: Computer Vision with GWT.
JooinK
 
DIY- computer vision with GWT
DIY- computer vision with GWTDIY- computer vision with GWT
DIY- computer vision with GWTFrancesca Tosi
 
Web app and more
Web app and moreWeb app and more
Web app and morefaming su
 
Plattformübergreifende App-Entwicklung (ein Vergleich) - MobileTechCon 2010
Plattformübergreifende App-Entwicklung (ein Vergleich) - MobileTechCon 2010Plattformübergreifende App-Entwicklung (ein Vergleich) - MobileTechCon 2010
Plattformübergreifende App-Entwicklung (ein Vergleich) - MobileTechCon 2010
Heiko Behrens
 
Installing Games Sucks, Learn WebGL
Installing Games Sucks, Learn WebGLInstalling Games Sucks, Learn WebGL
Installing Games Sucks, Learn WebGL
Corey Clark, Ph.D.
 
Vaadin 7 CN
Vaadin 7 CNVaadin 7 CN
Vaadin 7 CN
jojule
 
No more excuses left - Webinale 2015 Lunch keynote
No more excuses left - Webinale 2015 Lunch keynoteNo more excuses left - Webinale 2015 Lunch keynote
No more excuses left - Webinale 2015 Lunch keynote
Christian Heilmann
 
Java Web Programming on Google Cloud Platform [3/3] : Google Web Toolkit
Java Web Programming on Google Cloud Platform [3/3] : Google Web ToolkitJava Web Programming on Google Cloud Platform [3/3] : Google Web Toolkit
Java Web Programming on Google Cloud Platform [3/3] : Google Web Toolkit
IMC Institute
 
Real World Lessons in jQuery Mobile
Real World Lessons in jQuery MobileReal World Lessons in jQuery Mobile
Real World Lessons in jQuery Mobile
Kai Koenig
 
Google Web Toolkit
Google Web ToolkitGoogle Web Toolkit
Google Web Toolkit
Software Park Thailand
 
Stefan Judis "Did we(b development) lose the right direction?"
Stefan Judis "Did we(b development) lose the right direction?"Stefan Judis "Did we(b development) lose the right direction?"
Stefan Judis "Did we(b development) lose the right direction?"
Fwdays
 
Firefox OS - HTML5 for a truly world-wide-web
Firefox OS - HTML5 for a truly world-wide-webFirefox OS - HTML5 for a truly world-wide-web
Firefox OS - HTML5 for a truly world-wide-web
Christian Heilmann
 
Apps & Widgets in Mobile Learning
Apps & Widgets in Mobile LearningApps & Widgets in Mobile Learning
Apps & Widgets in Mobile Learning
The University of Manchester
 
Building a Simple Mobile-optimized Web App Using the jQuery Mobile Framework
Building a Simple Mobile-optimized Web App Using the jQuery Mobile FrameworkBuilding a Simple Mobile-optimized Web App Using the jQuery Mobile Framework
Building a Simple Mobile-optimized Web App Using the jQuery Mobile Framework
St. Petersburg College
 
Fragmentation in mobile design: fact or fiction
Fragmentation in mobile design: fact or fictionFragmentation in mobile design: fact or fiction
Fragmentation in mobile design: fact or fictionBelen Barros Pena
 
From Idea to App (or “How we roll at Small Town Heroes”)
From Idea to App (or “How we roll at Small Town Heroes”)From Idea to App (or “How we roll at Small Town Heroes”)
From Idea to App (or “How we roll at Small Town Heroes”)
Bramus Van Damme
 

Similar to Mobile Java with GWT: Still "Write Once, Run Everywhere" (20)

Fake it 'til you make it
Fake it 'til you make itFake it 'til you make it
Fake it 'til you make it
 
HTML5 and Other Modern Browser Game Tech
HTML5 and Other Modern Browser Game TechHTML5 and Other Modern Browser Game Tech
HTML5 and Other Modern Browser Game Tech
 
Accelerated Adoption: HTML5 and CSS3 for ASP.NET Developers
Accelerated Adoption: HTML5 and CSS3 for ASP.NET DevelopersAccelerated Adoption: HTML5 and CSS3 for ASP.NET Developers
Accelerated Adoption: HTML5 and CSS3 for ASP.NET Developers
 
Html5 on Mobile(For Developer)
Html5 on Mobile(For Developer)Html5 on Mobile(For Developer)
Html5 on Mobile(For Developer)
 
DIY: Computer Vision with GWT.
DIY: Computer Vision with GWT.DIY: Computer Vision with GWT.
DIY: Computer Vision with GWT.
 
DIY- computer vision with GWT
DIY- computer vision with GWTDIY- computer vision with GWT
DIY- computer vision with GWT
 
Web app and more
Web app and moreWeb app and more
Web app and more
 
Plattformübergreifende App-Entwicklung (ein Vergleich) - MobileTechCon 2010
Plattformübergreifende App-Entwicklung (ein Vergleich) - MobileTechCon 2010Plattformübergreifende App-Entwicklung (ein Vergleich) - MobileTechCon 2010
Plattformübergreifende App-Entwicklung (ein Vergleich) - MobileTechCon 2010
 
Installing Games Sucks, Learn WebGL
Installing Games Sucks, Learn WebGLInstalling Games Sucks, Learn WebGL
Installing Games Sucks, Learn WebGL
 
Vaadin 7 CN
Vaadin 7 CNVaadin 7 CN
Vaadin 7 CN
 
No more excuses left - Webinale 2015 Lunch keynote
No more excuses left - Webinale 2015 Lunch keynoteNo more excuses left - Webinale 2015 Lunch keynote
No more excuses left - Webinale 2015 Lunch keynote
 
Java Web Programming on Google Cloud Platform [3/3] : Google Web Toolkit
Java Web Programming on Google Cloud Platform [3/3] : Google Web ToolkitJava Web Programming on Google Cloud Platform [3/3] : Google Web Toolkit
Java Web Programming on Google Cloud Platform [3/3] : Google Web Toolkit
 
Real World Lessons in jQuery Mobile
Real World Lessons in jQuery MobileReal World Lessons in jQuery Mobile
Real World Lessons in jQuery Mobile
 
Google Web Toolkit
Google Web ToolkitGoogle Web Toolkit
Google Web Toolkit
 
Stefan Judis "Did we(b development) lose the right direction?"
Stefan Judis "Did we(b development) lose the right direction?"Stefan Judis "Did we(b development) lose the right direction?"
Stefan Judis "Did we(b development) lose the right direction?"
 
Firefox OS - HTML5 for a truly world-wide-web
Firefox OS - HTML5 for a truly world-wide-webFirefox OS - HTML5 for a truly world-wide-web
Firefox OS - HTML5 for a truly world-wide-web
 
Apps & Widgets in Mobile Learning
Apps & Widgets in Mobile LearningApps & Widgets in Mobile Learning
Apps & Widgets in Mobile Learning
 
Building a Simple Mobile-optimized Web App Using the jQuery Mobile Framework
Building a Simple Mobile-optimized Web App Using the jQuery Mobile FrameworkBuilding a Simple Mobile-optimized Web App Using the jQuery Mobile Framework
Building a Simple Mobile-optimized Web App Using the jQuery Mobile Framework
 
Fragmentation in mobile design: fact or fiction
Fragmentation in mobile design: fact or fictionFragmentation in mobile design: fact or fiction
Fragmentation in mobile design: fact or fiction
 
From Idea to App (or “How we roll at Small Town Heroes”)
From Idea to App (or “How we roll at Small Town Heroes”)From Idea to App (or “How we roll at Small Town Heroes”)
From Idea to App (or “How we roll at Small Town Heroes”)
 

More from Alex Theedom

Build an Amazon Polly connector in 15 mins with MuleSoft
Build an Amazon Polly connector in 15 mins with MuleSoftBuild an Amazon Polly connector in 15 mins with MuleSoft
Build an Amazon Polly connector in 15 mins with MuleSoft
Alex Theedom
 
Java EE 8 security and JSON binding API
Java EE 8 security and JSON binding APIJava EE 8 security and JSON binding API
Java EE 8 security and JSON binding API
Alex Theedom
 
JDKIO: Java EE 8 what Servlet 4 and HTTP2 mean to you
JDKIO: Java EE 8 what Servlet 4 and HTTP2 mean to youJDKIO: Java EE 8 what Servlet 4 and HTTP2 mean to you
JDKIO: Java EE 8 what Servlet 4 and HTTP2 mean to you
Alex Theedom
 
Java EE 8: What Servlet 4.0 and HTTP2 mean to you
Java EE 8: What Servlet 4.0 and HTTP2 mean to youJava EE 8: What Servlet 4.0 and HTTP2 mean to you
Java EE 8: What Servlet 4.0 and HTTP2 mean to you
Alex Theedom
 
Java EE Revisits Design Patterns
Java EE Revisits Design PatternsJava EE Revisits Design Patterns
Java EE Revisits Design Patterns
Alex Theedom
 
Java EE 8: What Servlet 4.0 and HTTP/2 mean to you
Java EE 8: What Servlet 4.0 and HTTP/2 mean to youJava EE 8: What Servlet 4.0 and HTTP/2 mean to you
Java EE 8: What Servlet 4.0 and HTTP/2 mean to you
Alex Theedom
 

More from Alex Theedom (6)

Build an Amazon Polly connector in 15 mins with MuleSoft
Build an Amazon Polly connector in 15 mins with MuleSoftBuild an Amazon Polly connector in 15 mins with MuleSoft
Build an Amazon Polly connector in 15 mins with MuleSoft
 
Java EE 8 security and JSON binding API
Java EE 8 security and JSON binding APIJava EE 8 security and JSON binding API
Java EE 8 security and JSON binding API
 
JDKIO: Java EE 8 what Servlet 4 and HTTP2 mean to you
JDKIO: Java EE 8 what Servlet 4 and HTTP2 mean to youJDKIO: Java EE 8 what Servlet 4 and HTTP2 mean to you
JDKIO: Java EE 8 what Servlet 4 and HTTP2 mean to you
 
Java EE 8: What Servlet 4.0 and HTTP2 mean to you
Java EE 8: What Servlet 4.0 and HTTP2 mean to youJava EE 8: What Servlet 4.0 and HTTP2 mean to you
Java EE 8: What Servlet 4.0 and HTTP2 mean to you
 
Java EE Revisits Design Patterns
Java EE Revisits Design PatternsJava EE Revisits Design Patterns
Java EE Revisits Design Patterns
 
Java EE 8: What Servlet 4.0 and HTTP/2 mean to you
Java EE 8: What Servlet 4.0 and HTTP/2 mean to youJava EE 8: What Servlet 4.0 and HTTP/2 mean to you
Java EE 8: What Servlet 4.0 and HTTP/2 mean to you
 

Mobile Java with GWT: Still "Write Once, Run Everywhere"

  • 1. Mobile Java with GWT (and alternatives) Murat Yener & Alex Theedom @yenerm @alextheedom
  • 2. who (the hell) am I?!? Java, Flex, GWT, iOS, Android developer Principle Mentor at Eteration Eclipse Committer GDG (GTUG) Istanbul Organizer Conference Speaker Mobile App Developer at Intel
  • 3. as a mobile developer
  • 4. what (the hell) is this talk about?!? The fifth element... The Webview.. HTML5 mobile frameworks Phonegap keeping native UX
  • 5. so an HTML5 talk??? Facebook killed HTML5 app.. Zuckerberg said HTML5 is not there yet!! try fastbook from sencha fb.html5isready.com LinkedIn moved to native!! so did they just fix it??
  • 7. Hybrid Apps: Teaching the old dog new tricks?
  • 8. html5 apps in native shell?? nuts!! this is too complicated!! have many of you have web development experience? how many of you develop native apps? how many of you don’t like web development just because of javascript??
  • 9. but it is slow!! building games? 3d physics? image or sound processing? ... no most of the time we just do this!
  • 10. wait is this really web? Angry Birds for Chrome (GWT) Quake on Mobile (requires Chrome Beta for WebGL) http://mediatojicode.com/q3bsp/ “We started with the existing Jake2 Java port of the Quake II engine, then used the Google Web Toolkit (along with WebGL, WebSockets, and a lot of refactoring) to cross-compile it into Javascript. You can see the results in the video above — we were honestly a bit surprised when we saw it pushing over 30 frames per second on our laptops (your mileage may vary)!” from Google Code Blog...
  • 13. GWT 101: java to javascript? GWT compiler does the magic Optimized high performance javascript cross browser compability (upto ie6) not really mobile look’n feel :(
  • 15. gwt frameworks? gwt-mobile-webkit: database, storage, geolocation, widgets(?) http://code.google.com/p/gwt-mobile-webkit/ gwtmobile: GwtMobile-UI, Gwtmobile- Persistence, GwtMobile-PhoneGap(!) http://code.google.com/p/gwtmobile/ touch4j: Sencha, http://www.emitrom.com/gwt4touch mgwt: UI Widgets, GWT-Phonegap http://code.google.com/p/mgwt/
  • 16. so what is mGWT mobile widget library on gwt native looking widgets for each platform maven friendly mvp ready (maven archetype) and with gwt-phonegap
  • 17. where to start? get the source https://code.google.com/p/mgwt or download the jar or just use maven <dependency> <groupId>com.googlecode.mgwt</groupId> <artifactId>mgwt</artifactId> <version>1.1.2</version> </dependency>
  • 18. Hello World!! public class MGWTEntryPoint implements EntryPoint { public void onModuleLoad() { // set viewport and other settings for mobile MGWT.applySettings(MGWTSettings.getAppSetting()); // build animation helper and attach it AnimationHelper animationHelper = new AnimationHelper(); RootPanel.get().add(animationHelper); // build some UI LayoutPanel layoutPanel = new LayoutPanel(); Button button = new Button("Hello mgwt"); layoutPanel.add(button); // animate animationHelper.goTo(layoutPanel, Animation.SLIDE); } }
  • 19. using other libs: ex. maps.. Google Maps Ver 2.0: http://code.google.com/p/gwt-google- apis/ Google Maps Ver 3.0: http://code.google.com/p/gwt-google- maps-v3/ No Javascript so far! <inherits name='com.google.gwt.maps.GoogleMaps' />
  • 20. add a litte spice: phonegap geolocation camera accelerator compass phonebook file system even nfc
  • 21. phonegap in action ... Button button = new Button("Hello mgwt"); button().addTapHandler(new TapHandler() { @Override public void onTap(TapEvent event) { phoneGap.getNotification().alert("Done!!"); } }); layoutPanel.add(button); ...
  • 22. phonegap, in real action phoneGap.getGeolocation().watchPosition(geolocationOptions, new MyGeolocationCallback(){ @Override public void onSuccess(Position position) { // check accuracy if (position.getCoordinates().getAccuracy() > 11) { raceView.getLabel().setText("Error: Accuracy"); } // geolocation returns mps, multiply with 3.6 to convert to kph double speed = 3.6 * position.getCoordinates().getSpeed(); if (speed > 0.2) {// if going raceView.getLabel().setText(speed + "km @" + position.getCoordinates().getAccuracy()); currentLocation = position; // got the position now can start! start(); // stop if the threshold is reached if (isGoing && speed >= 60) { MgwtAppEntryPoint.phoneGap.getGeolocation().clearWatch(geolocationWatcher); endLocation = position; calculate(); } } else {// if stoped raceView.getLabel().setText("get ready!!"); isGoing = false; } } @Override public void onFailure(PositionError error) { MgwtAppEntryPoint.phoneGap.getNotification().alert("Problem getting location"); } });
  • 23. even more... public void onTap(TapEvent event) { final MCheckBox check = ((MCheckBox) event.getSource()); if (check.getValue()) { if (TWITTER.equalsIgnoreCase(type)) profileView.getBrowser().showWebPage(Service.BASE_URL + "auth/twitter"); else if (FACEBOOK.equalsIgnoreCase(type)) profileView.getBrowser().showWebPage(Service.BASE_URL + "auth/facebook"); profileView.getBrowser().addLocationChangeHandler(new ChildBrowserLocationChangedHandler() { @Override public void onLocationChanged(ChildBrowserLocationChangedEvent event) { //Do the login... } }); } } }
  • 24. going fancy, mvp! code your UI in the View preferably in xml via UIBinder and your logic in the controller (activity) sound familiar? easy navigation lots of boilerplate code
  • 26. connecting to backend GWT-RPC (yeah, it rocks), but in native package? JSONP with with RequestBuilder & Autobean JsonpRequestBuilder jsonp = new JsonpRequestBuilder(); String url = URL.encode(JSON_URL + "/sendData/" + “HelloWorld”); jsonp.requestObject(url, new AsyncCallback<JavaScriptObject>() { @Override public void onFailure(Throwable caught) { MgwtAppEntryPoint.phoneGap.getNotification().alert(caught.getMessage()); } @Override public void onSuccess(JavaScriptObject result) { JSONObject jsObj = new JSONObject(result); AutoBean<Score[]> bean = AutoBeanCodex.decode(factory, Score[].class, jsObj.toString()); Score[] scores = bean.as(); scoresCallback.onResponse(scores); } });
  • 27. accessing native js can use any existing javascript use javascript in type safe way BUT!! don’t mess touch events!! AND beware you are not in the safe and optimized zone anymore!!
  • 28. JSNI public native static String key(int index) /*-{ return $wnd.localStorage.key(index); }-*/; public native static void setItem(String key, String value) /*-{ $wnd.localStorage.setItem(key, value); }-*/; public native static String getItem(String key) /*-{ return $wnd.localStorage.getItem(key); }-*/; public native static void removeItem(String key) /*-{ $wnd.localStorage.removeItem(key); }-*/; public native static void clear() /*-{ $wnd.localStorage.clear(); }-*/;
  • 29. building my swipe panel just like the one in sencha wrapped swipeview from cubiq
  • 33. gwtquery coming from jQuery, no problem! public void onModuleLoad() { //Hide the text and set the width and append an h1 element $("#text").hide() .css("width", "400px") .prepend("<h1>GwtQuery Rocks !</h1>"); //add a click handler on the button $("button").click(new Function(){ public void f() { //display the text with effects and animate its background color $("#text").as(Effects) .clipDown() .animate("backgroundColor: 'yellow'", 500) .delay(1000) .animate("backgroundColor: '#fff'", 1500); } }); }
  • 34. skinning default themes for Android (>4.0) iOS/iOS retina (<7.0) Blackberry easy to create yours https://code.google.com/p/mgwt/wiki/Styling //append your own css as last thing in the head MGWTStyle.injectStyleSheet("yourcssfile.css");
  • 35. wait, css in java?!? .mgwt-Button { display: inline-block; float: left; width: 145px; height: 100px; border: 1px solid rgba(0,0,0,0.23); background: #ff6600; border-radius: 6px; box-shadow: inset -1px 0px 0px rgba(255,255,255,0.41), inset 1px 0px 0px rgba(255,255,255,0.21), inset 0px -1px 0px rgba(0,0,0,0.21), inset 0px 1px 0px rgba(255,255,255,0.41), 0px 1px 2px rgba(0,0,0,0.21); text-align: center; font-size: 14px; margin: 5px; font-weight: bold; text-shadow: 0px 1px 1px rgba(0,0,0,0.49); color: white; line-height: 124px; }
  • 36. debugging first class java debugging in your IDE GWT pretty compile and debug javascript in your browser use source maps and debug java in your browser!! use remote debugging to debug on mobile devices
  • 37. what about others? iOS, works like charm.. pretty much native android, near native experience blackberry windows phone tablets? desktop??
  • 38. what can i really build? anything! but why not going native for games many widgets.. lists, carousels, forms dev friendly, you know java? just dive in! make use of current js windows phone? seriously?!?
  • 39. </slides> GDG Istanbul (every 3. or 4. Saturday) Interested in OSGi? No? ok, i thought so… and GWT.create at San Francisco murat@muratyener.com @yenerm devchronicles.com
  • 40. 40% discount with promo code VBK43 when ordering through wiley.com valid until end of December 2015
  • 41. who (the hell) am I?!? Java (Spring/EE) developer Microservices Jersey Coders Mentor Conference Speaker
  • 42. Cross-platform Mobile Development Develop once run on multiple platforms Choose just ‘one’ language
  • 45. Lets see some code UI coded in Java Rendered in native UI
  • 46. Codename One Compile to native C# JDK 1.3 iOS Windows Phone C Java 5
  • 47. Lets see some code Familiar to Swing and GWT coders Java 8 next release
  • 48. Oracle Mobile Application Framework (MAF) Only Jdeveloper or Eclipse Lightweight JVM
  • 49. Lets see some code Flow define GUI Device feature via DeviceManager