SlideShare uma empresa Scribd logo
1 de 40
Baixar para ler offline
droidQuery
The Android port of jQuery
Presented by Phil Brown
Overview
1)
2)
3)
4)
5)

What, Why and How?
Understand the Syntax
UI Traversal & Manipulation
Asynchronous Rest Client (Ajax)
Everything Else
1) What, Why, and How?
WHAT IS droidQuery?
❏ A port of the popular javascript library jQuery.
❏ jQuery is:
“... a fast, small, and feature-rich JavaScript library [that]
makes things like HTML document traversal and
manipulation, event handling, animation, and Ajax* much
simpler with an easy-to-use API.”
-- www.jquery.com
❏ A java library that makes things like layout traversal and
manipulation, event handling, animation, and Ajax simple to
implement on Android 2.2+.
WHY DOES IT EXIST?
❏ Makes developing apps faster
❏ Chaining Method calls
❏ Fewer Lines of Code
❏ Simplifies common tasks
❏ Asynchronous RESTful API calls
❏ Animations
❏ Etc
❏ Familiar syntax for web developers to learn Android
development.
Example
Without droidQuery:

With droidQuery:

OnClickListener listener = new
OnClickListener() {
public void onClick(View v){
Log.i(“test”, “clicked”);
}
};
Button b1 =
(Button) findViewById(R.id.b1);
b1.setOnClickListener(listener);
Button b2 =
(Button) findViewById(R.id.b2);
b2.setOnClickListener(listener);
Button b3 =
(Button) findViewById(R.id.b3);
b3.setOnClickListener(listener);

$.with(this, R.id.b1, R.id.b2, R.id.b3)
.click(new Function() {
public void invoke($ d, Object… args){
Log.i(“test”, “clicked”);
}
});
HOW DOES IT WORK?
❏
❏

❏
❏
❏

Ported From the jQuery Documentation
Made to be as syntactically like jQuery as possible
❏ No generics
❏ $ for class name
Reflection/Proxying Techniques for advanced CSS, Animation, and
Event handling
Asynchronous Rest API based on Apache HTTPClient
Uses NineOldAndroids to support animations and attributes for low APIs
What are my alternatives?
❏
❏

No other library offers all of the features that droidQuery provides.
Many libraries support Asynchronous Network Tasks
❏ Android Volley
❏ Spring for Android
❏ AndroidAnnotations
❏ Picasso
❏ Image Specific
❏ Android Query
❏ Also provides APIs similar to jQuery, but syntax is very different.

❏

For animations supporting lower APIs, you can use NineOldAndroids.
2) Understand the Syntax
(And a comparison to jQuery)
In jQuery:
❏

The variable ‘$’ is used as an alias to the jQuery function, and as such is
commonly used to access variables and functions within jQuery.
❏

❏

$(“#myButton”).click(function(event) {
console.log(“element clicked!”);
});

droidQuery’s main class is $.java.
❏

$.with(myButton).click(new Function() {
public void invoke($ d, Object… args) {
Log.i(“droidQuery”, “view clicked!”);
}
};
droidQuery Syntax
❏
❏
❏

$.java
Function
Instantiation using $.with(...)
❏ Modeled after picasso*
❏ Accepts Context, View, View[], List<View>, Context and
vararg int ids, etc

❏

Assumes common callback syntax for event handling:
❏ Listeners should be an inner interface of the Object
❏ public interface OnFoobarListener {
public void|boolean onFoobar();
}

* - http://square.github.io/picasso/
3) UI Traversal & Manipulation
Selectors
❏
❏
❏

Select one or multiple UI elements
Powerful shortcut for manipulating both individual views and groups of views
There are many selector methods provided by droidQuery, including:
❏
❏
❏
❏
❏
❏
❏
❏
❏

.selectAll()
.selectByType()
.selectChildren()
.selectEmpties()
.selectFocused()
.selectHidden()
.selectImages()
.selectOnlyChilds()
.selectParents()

❏
❏
❏
❏
❏

.selectVisible()
.union()*
.intersect()*
.id()
.ids()

* - special case that accepts a second
droidQuery instance as a parameter.
Selector Example
//Show hidden Views, Hide Shown Views
$ hidden = $.with(this).selectHidden();
$.with(this).selectShown().hide();
hidden.show();
//Edit views that contain a LinearLayout as only subview
$.with(this)
.selectByType(“android.widget.LinearLayout”)
.selectOnlyChilds()
.selectParents().attr(“backgroundColor”, Color.RED);
Manipulate the Selection
Once a selection has been made, these (and other) methods will manipulate each
View in the selection. Think of them as setters on all the Views in the selection.
❏
❏
❏
❏
❏
❏
❏
❏
❏

.attr(“name”, value)
.val(Object)
.text(int), .text(String)
.html(int), .html(String)
.mask(...)
.id(int)
.focus()
.focusOut()
.tag(Object)

❏
❏
❏

.image(Drawable), .image(Bitmap), .image(String)
.image(String, int, int, error)
❏ Set Image to Asset, File, or URL
.image(List<String>, int, int, error)
❏ Set different Strings for different views in the
selection
UI Manipulation Example 1
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null)
layout = LayoutInflater.from(mContext)
.inflate(R.layout.cell, parent, false);
Message data = getItem(position);
$.with(layout, R.id.title).text(data.getTitle())
.id(R.id.image).image(data.getImageUrl());
return convertView;
}
UI Manipulation Example 2
String[] urls = new String[] { “http://bit.ly/mmlogo.png”,
“http://bit.ly/mmicon.png”,
“http://bit.ly/mmthumb.png” };
int px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
48, getResources().getDisplayMetrics());
$.with(this, R.id.logo, R.id.icon, R.id.thumb)
.image(Arrays.asList(urls), px, px, new Function() {
public void invoke($ d, Object… args) {
Log.e(“Images”, args[0].toString());
}
});
Getter Shortcuts
The setter methods discussed previously become getters (for the first View in
the selection) when the last parameter is removed.
$ d = $.with(this,
CharSequence text0
CharSequence text1
CharSequence text2

android.R.id.text1);
= d.text();
= (CharSequence) d.attr(“text”);
= (CharSequence) d.val();
CSS
❏

Current CSS-related Methods*
include:
❏ .height()
❏ .width()
❏ .innerHeight()
❏ .innerWidth()
❏ .outerHeight()
❏ .outerWidth()
❏ .offset()
❏ .position()
❏ .scrollLeft()
❏ .scrollTop()

❏

Future CSS-Related Methods
include:
❏ .css(String)
❏ .addClass(...)
❏ .hasClass(...)
❏ .removeClass(...)

* All of these methods can be used to get
or set the attribute
Animations
$.with(this, R.id.logo)
.animate(“{ width:48dp, height:48dp }”,
400,
$.Easing.BOUNCE,
new Function() {
public void invoke($ d, Object… args) {
d.toast(“Animation Complete”, 1);
}
});
Animations, cont’d
❏

Uses a JSON string specifying animation properties, end values, and
units.
❏ Units can be any of: px, %, em, dp, dip, sp, in, mm, pt, or none
(defaults to px)
❏ Property names must be accessible using Getters or Setters (or via
ViewHelper, from NineOldAndroids).

❏

Additionally, an AnimationOptions Object is passed that provides
parameters and callbacks for the animation, including duration,
interpolator, etc - making these animation highly customizable and
responsive.
Animation Longhand
AnimationOptions options = new AnimationOptions();
options.duration(400)
.easing($.Easing.ACCELERATE_DECELERATE)
.debug(true)
.reverse(true)
.repeatCount(2)
.progress(new Function() {
public void invoke($ d, Object… args) {
Log.i(“animate”, args[0]+“=”+args[1]);
}
}));
$.with(this).selectImages()
.animate(“{ width:200%, height:200% }”, options);
Animation Shortcuts
droidQuery includes shortcuts for common animations including:
❏
❏
❏
❏
❏
❏
❏
❏

.fadeIn()
.fadeOut()
.fadeTo()
.fadeToggle()
.slideLeft()
.slideUp()
.slideRight()
.slideDown()
4) Asynchronous Rest Client
(Port of Ajax)
The $.ajax() Method
This method is used to start an asynchronous REST request. There are
multiple parameter types this accepts, however primarily developers will use
one of:
❏
❏

AjaxOptions
❏ $.ajax(new AjaxOptions().url(“http://example.com”));
String
❏ Does not support Functions, but may be useful where either global
event handlers are already set, or where no callbacks are needed.
❏ $.ajax(“{ url:’http://www.example.com’,” +
“ type:’PUT’,” +
“ data:{foo:1, bar:’example’}” +
“}”);
AjaxOptions Example
$.ajax(new AjaxOptions()
.url(“http://www.weath.er/getTemperature”)
.data(“{“zipcode”:“55408”}”)
.error(new Function() {
public void invoke($ d, Object… args) {
AjaxError error = (AjaxError) args[0];
Log.e(“Ajax”, error.toString());
}
}).success(new Function() {
public void invoke($ d, Object… args) {
JSONObject json = (JSONObject) args[0];
Map<String, Object> data = $.map(json);
Log.e(“Ajax”, “Temp: ”+ data.get(“Celsius”));
}}));
Ajax: Global Event Handlers
Global Ajax Event Handlers:
Register/Respond to Ajax Events for global requests.
These are specified using the .global() method of the AjaxOptions Object.
❏ $.ajaxComplete()
❏ $.ajaxBeforeSend()
❏ $.ajaxError()
❏ $.ajaxStart()
❏ $.ajaxStop()
❏ $.ajaxSuccess()
Global Event Handlers Example
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
$.ajaxStart(new Function() {
public void invoke($ d, Object… args) {
setProgressBarIndeterminateVisibility(true);
}
});
$.ajaxStop(new Function() {
public void invoke($ d, Object… args) {
setProgressBarIndeterminateVisibility(false);
}
});
}
Other Ajax Methods
❏

❏
❏

Helper Methods
❏ $.serialize()
❏ $.serializeArray()
Low-Level Methods
❏ $.ajaxSetup()
Shorthand Methods
❏ $.get()
❏ $.getJSON()
❏ $.getScript()
❏ $.post()
❏ $.load()

AjaxOptions options = new AjaxOptions();
Integer[] timeouts = new Integer[]
{480,419,504,503,522,598,599};
options.error(new Function() {
public void invoke($ d, Object… args) {
AjaxError error = (AjaxError) args[0];
Log.e(“Ajax Error”, error.toString());
}
}.statusCode(timeouts, new function() {
public void invoke($ d, Object… args) {
Log.e(“Ajax Error”,“Timeout(“+args[0]+
“)”);
AjaxOptions o = (AjaxOptions) args[1];
$.ajax(o.statusCode(timeouts, $.noop()));
}
}));
$.ajaxSetup(options);
droidQuery Ajax Additions
Additionally, droidQuery provides advanced caching and redundancy handling.
❏ Caching
❏ Saves statically - not persistent across JVM sessions
❏ Customizable
❏ ON/OFF
❏ Timeout Interval
❏ Per-Request caching technique (timeout, never timeout, only delete when
cache is cleared)
❏ Direct access to cache
❏

Redundancy Handling
❏ Ensures that only one identical request goes out at the same time
❏ Customize how to handle redundant requests
❏ Respond-To-All (default), Respond-To-First, Off
5) Everything Else
(well, not everything...)
Events
❏

Refers to triggering and responding to
❏ User Input Events, such as clicks and swipes
❏ Changes to the layout

❏

Set or trigger an event using the following methods:
❏ .bind(), .on(), .one(), .change(), .click(), .longclick(), .swipe(), .
swipeLeft(), .swipeUp(), .swipeRight(), .swipeDown(), .focus(), .
focusout(), .keydown(), .keyup(), .keypress()

❏

Relies on standard Callback syntax to create proxies for the bind(),
on(), and one() methods.

❏

Using some of these methods will change a View’s existing
onTouchListener.
Event Example (1 of 2)
Function clickListener = new Function() {
public void invoke($ d, Object… args) {
d.toast(“a button was clicked!”, Toast.LENGTH_SHORT);
}
};
$ d = $.with(this).selectByType(Button.class);
//any of the below result in the same functionality
d.click(clickListener);
d.on(“click”, clickListener);
d.bind(“click”, null, clickListener);
//this will only work the first time each view:
d.one(“click”, clickListener);
Event Example (2 of 2)
//handle EditText edit changes
View editor = findViewById(R.id.myEditText);
$.with(editor).change(new Function() {
public void invoke($ d, Object… args) {
Log.i(“Change”, “EditText changed to: ” + d.text());
}
});
Forms
A Form layout allows quick creation of UI forms, plus simple validation.
<self.philbrown.view.Form
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:droidQuery="http://schemas.android.com/apk/res-auto"
android:id=”@+id/form”
android:layout_width=”match_parent”
android:layout_height=”match_parent” >
<EditText
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
droidQuery:layout_form_required=”true”/>
</self.philbrown.view.Form>

//Then in code:
boolean isValid = ((Form) findViewById(R.id.form)).validate();
Utilities
Many additional classes and methods are bundled with droidQuery that can
help simplify development:
❏

Methods
❏ .view(int)
❏ .each(Function)
❏ .parseJSON(String)
❏ .parseXML(String)
❏ .parseHTML(String)
❏ $.map(JSONObject)
❏ $.makeArray(JSONArray)
❏ .data(), .data(Object)

❏

Classes
❏ QuickMap/QuickEntry
❏

❏
❏
❏

Map<String, ?> map =
$.qm($.qe(“foo”, “bar”),
$.qe(“first”, 1));

SwipeInterceptorView
EventCenter
Callbacks
droidQuery Extensions
❏

Your project can be a droidQuery extension
1. Create a new library project
2. Create a new Object that extends $Extension
3. Override methods
4. Include in app build path
5. Access library code through droidQuery API

❏

Examples available on Github.
What’s next?
❏
❏
❏

❏
❏

Finish CSS Integration
Update javaQuery (http://bit.ly/javaquery)
iQuery (Objective-c++)
❏ UITextView *view = [[UITextView] alloc] init];
$ *d = new $(view);
NSString *text;
text = d->attr(@“text”, @“foobar”).attr(@“text”);
NSLog(@“text=’%@’”, text);
jQuery to (droid,java,i)Query generation?
Hybrid jQuery/(droid,java,i)Query apps?
Thank You
❏

droidQuery is still a work in progress. If you would like to contribute
❏ please start by watching the github repo (http://bit.ly/droidquery).
❏ Use the @Modified annotation packaged with the project, to mark
your changes to the code.

❏

Javadocs from most recent release are available at http://bit.ly/droidquerydocs.

❏

Open Source Libraries that are used by droidQuery include:
❏ NineOldAndroids - http://nineoldandroids.com/
❏ cwac-task - https://github.com/commonsguy/cwac-task
❏ jCSS-Parser - https://github.com/phil-brown/jCSS-Parser
droidQuery

Questions?
Phil Brown
@PhDBrown
https://plus.google.
com/+PhilBrown1/
phil.brown@mentormate.com

Mais conteúdo relacionado

Mais procurados

Drupal 7 Entity & Entity API
Drupal 7 Entity & Entity APIDrupal 7 Entity & Entity API
Drupal 7 Entity & Entity API均民 戴
 
CQRS and Event Sourcing in a Symfony application
CQRS and Event Sourcing in a Symfony applicationCQRS and Event Sourcing in a Symfony application
CQRS and Event Sourcing in a Symfony applicationSamuel ROZE
 
Decoupling the Ulabox.com monolith. From CRUD to DDD
Decoupling the Ulabox.com monolith. From CRUD to DDDDecoupling the Ulabox.com monolith. From CRUD to DDD
Decoupling the Ulabox.com monolith. From CRUD to DDDAleix Vergés
 
How I started to love design patterns
How I started to love design patternsHow I started to love design patterns
How I started to love design patternsSamuel ROZE
 
Test and profile your Windows Phone 8 App
Test and profile your Windows Phone 8 AppTest and profile your Windows Phone 8 App
Test and profile your Windows Phone 8 AppMichele Capra
 
After max+phonegap
After max+phonegapAfter max+phonegap
After max+phonegapyangdj
 
Introduction to CQRS and Event Sourcing
Introduction to CQRS and Event SourcingIntroduction to CQRS and Event Sourcing
Introduction to CQRS and Event SourcingSamuel ROZE
 
Jquery optimization-tips
Jquery optimization-tipsJquery optimization-tips
Jquery optimization-tipsanubavam-techkt
 
Hacking Your Way To Better Security - Dutch PHP Conference 2016
Hacking Your Way To Better Security - Dutch PHP Conference 2016Hacking Your Way To Better Security - Dutch PHP Conference 2016
Hacking Your Way To Better Security - Dutch PHP Conference 2016Colin O'Dell
 

Mais procurados (19)

Drupal 8: Fields reborn
Drupal 8: Fields rebornDrupal 8: Fields reborn
Drupal 8: Fields reborn
 
jQuery
jQueryjQuery
jQuery
 
Build your own entity with Drupal
Build your own entity with DrupalBuild your own entity with Drupal
Build your own entity with Drupal
 
Drupal 7 Entity & Entity API
Drupal 7 Entity & Entity APIDrupal 7 Entity & Entity API
Drupal 7 Entity & Entity API
 
Symfony2 your way
Symfony2   your waySymfony2   your way
Symfony2 your way
 
Zend framework service
Zend framework serviceZend framework service
Zend framework service
 
CQRS and Event Sourcing in a Symfony application
CQRS and Event Sourcing in a Symfony applicationCQRS and Event Sourcing in a Symfony application
CQRS and Event Sourcing in a Symfony application
 
Decoupling the Ulabox.com monolith. From CRUD to DDD
Decoupling the Ulabox.com monolith. From CRUD to DDDDecoupling the Ulabox.com monolith. From CRUD to DDD
Decoupling the Ulabox.com monolith. From CRUD to DDD
 
How I started to love design patterns
How I started to love design patternsHow I started to love design patterns
How I started to love design patterns
 
Soap tips
Soap tipsSoap tips
Soap tips
 
Test and profile your Windows Phone 8 App
Test and profile your Windows Phone 8 AppTest and profile your Windows Phone 8 App
Test and profile your Windows Phone 8 App
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
After max+phonegap
After max+phonegapAfter max+phonegap
After max+phonegap
 
Spine JS
Spine JSSpine JS
Spine JS
 
Backbone js
Backbone jsBackbone js
Backbone js
 
Introduction to CQRS and Event Sourcing
Introduction to CQRS and Event SourcingIntroduction to CQRS and Event Sourcing
Introduction to CQRS and Event Sourcing
 
Jquery optimization-tips
Jquery optimization-tipsJquery optimization-tips
Jquery optimization-tips
 
Hacking Your Way To Better Security - Dutch PHP Conference 2016
Hacking Your Way To Better Security - Dutch PHP Conference 2016Hacking Your Way To Better Security - Dutch PHP Conference 2016
Hacking Your Way To Better Security - Dutch PHP Conference 2016
 
Separation of concerns - DPC12
Separation of concerns - DPC12Separation of concerns - DPC12
Separation of concerns - DPC12
 

Semelhante a droidQuery: The Android port of jQuery

Practical AngularJS
Practical AngularJSPractical AngularJS
Practical AngularJSWei Ru
 
Android Best Practices
Android Best PracticesAndroid Best Practices
Android Best PracticesYekmer Simsek
 
Ajax tutorial
Ajax tutorialAjax tutorial
Ajax tutorialKat Roque
 
Developing your first application using FI-WARE
Developing your first application using FI-WAREDeveloping your first application using FI-WARE
Developing your first application using FI-WAREFermin Galan
 
Javascript Frameworks for Joomla
Javascript Frameworks for JoomlaJavascript Frameworks for Joomla
Javascript Frameworks for JoomlaLuke Summerfield
 
[Srijan Wednesday Webinars] Ruling Drupal 8 with #d8rules
[Srijan Wednesday Webinars] Ruling Drupal 8 with #d8rules[Srijan Wednesday Webinars] Ruling Drupal 8 with #d8rules
[Srijan Wednesday Webinars] Ruling Drupal 8 with #d8rulesSrijan Technologies
 
Developing your first application using FIWARE
Developing your first application using FIWAREDeveloping your first application using FIWARE
Developing your first application using FIWAREFIWARE
 
混搭移动开发:PhoneGap+JQurey+Dreamweaver
混搭移动开发:PhoneGap+JQurey+Dreamweaver混搭移动开发:PhoneGap+JQurey+Dreamweaver
混搭移动开发:PhoneGap+JQurey+Dreamweaveryangdj
 
Relevance trilogy may dream be with you! (dec17)
Relevance trilogy  may dream be with you! (dec17)Relevance trilogy  may dream be with you! (dec17)
Relevance trilogy may dream be with you! (dec17)Woonsan Ko
 
Building Applications Using Ajax
Building Applications Using AjaxBuilding Applications Using Ajax
Building Applications Using Ajaxs_pradeep
 
Android dev toolbox
Android dev toolboxAndroid dev toolbox
Android dev toolboxShem Magnezi
 
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)Igor Bronovskyy
 
jQuery and Rails: Best Friends Forever
jQuery and Rails: Best Friends ForeverjQuery and Rails: Best Friends Forever
jQuery and Rails: Best Friends Foreverstephskardal
 
Web UI test automation instruments
Web UI test automation instrumentsWeb UI test automation instruments
Web UI test automation instrumentsArtem Nagornyi
 
Understanding backbonejs
Understanding backbonejsUnderstanding backbonejs
Understanding backbonejsNick Lee
 

Semelhante a droidQuery: The Android port of jQuery (20)

Practical AngularJS
Practical AngularJSPractical AngularJS
Practical AngularJS
 
jQuery
jQueryjQuery
jQuery
 
jQuery for web development
jQuery for web developmentjQuery for web development
jQuery for web development
 
Jquery Basics
Jquery BasicsJquery Basics
Jquery Basics
 
Android Best Practices
Android Best PracticesAndroid Best Practices
Android Best Practices
 
Ajax tutorial
Ajax tutorialAjax tutorial
Ajax tutorial
 
Jquery beltranhomewrok
Jquery beltranhomewrokJquery beltranhomewrok
Jquery beltranhomewrok
 
Jquery beltranhomewrok
Jquery beltranhomewrokJquery beltranhomewrok
Jquery beltranhomewrok
 
Developing your first application using FI-WARE
Developing your first application using FI-WAREDeveloping your first application using FI-WARE
Developing your first application using FI-WARE
 
Javascript Frameworks for Joomla
Javascript Frameworks for JoomlaJavascript Frameworks for Joomla
Javascript Frameworks for Joomla
 
[Srijan Wednesday Webinars] Ruling Drupal 8 with #d8rules
[Srijan Wednesday Webinars] Ruling Drupal 8 with #d8rules[Srijan Wednesday Webinars] Ruling Drupal 8 with #d8rules
[Srijan Wednesday Webinars] Ruling Drupal 8 with #d8rules
 
Developing your first application using FIWARE
Developing your first application using FIWAREDeveloping your first application using FIWARE
Developing your first application using FIWARE
 
混搭移动开发:PhoneGap+JQurey+Dreamweaver
混搭移动开发:PhoneGap+JQurey+Dreamweaver混搭移动开发:PhoneGap+JQurey+Dreamweaver
混搭移动开发:PhoneGap+JQurey+Dreamweaver
 
Relevance trilogy may dream be with you! (dec17)
Relevance trilogy  may dream be with you! (dec17)Relevance trilogy  may dream be with you! (dec17)
Relevance trilogy may dream be with you! (dec17)
 
Building Applications Using Ajax
Building Applications Using AjaxBuilding Applications Using Ajax
Building Applications Using Ajax
 
Android dev toolbox
Android dev toolboxAndroid dev toolbox
Android dev toolbox
 
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
 
jQuery and Rails: Best Friends Forever
jQuery and Rails: Best Friends ForeverjQuery and Rails: Best Friends Forever
jQuery and Rails: Best Friends Forever
 
Web UI test automation instruments
Web UI test automation instrumentsWeb UI test automation instruments
Web UI test automation instruments
 
Understanding backbonejs
Understanding backbonejsUnderstanding backbonejs
Understanding backbonejs
 

Último

Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
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 2024The Digital Insurer
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 

Último (20)

Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
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
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 

droidQuery: The Android port of jQuery

  • 1. droidQuery The Android port of jQuery Presented by Phil Brown
  • 2. Overview 1) 2) 3) 4) 5) What, Why and How? Understand the Syntax UI Traversal & Manipulation Asynchronous Rest Client (Ajax) Everything Else
  • 3. 1) What, Why, and How?
  • 4. WHAT IS droidQuery? ❏ A port of the popular javascript library jQuery. ❏ jQuery is: “... a fast, small, and feature-rich JavaScript library [that] makes things like HTML document traversal and manipulation, event handling, animation, and Ajax* much simpler with an easy-to-use API.” -- www.jquery.com ❏ A java library that makes things like layout traversal and manipulation, event handling, animation, and Ajax simple to implement on Android 2.2+.
  • 5. WHY DOES IT EXIST? ❏ Makes developing apps faster ❏ Chaining Method calls ❏ Fewer Lines of Code ❏ Simplifies common tasks ❏ Asynchronous RESTful API calls ❏ Animations ❏ Etc ❏ Familiar syntax for web developers to learn Android development.
  • 6. Example Without droidQuery: With droidQuery: OnClickListener listener = new OnClickListener() { public void onClick(View v){ Log.i(“test”, “clicked”); } }; Button b1 = (Button) findViewById(R.id.b1); b1.setOnClickListener(listener); Button b2 = (Button) findViewById(R.id.b2); b2.setOnClickListener(listener); Button b3 = (Button) findViewById(R.id.b3); b3.setOnClickListener(listener); $.with(this, R.id.b1, R.id.b2, R.id.b3) .click(new Function() { public void invoke($ d, Object… args){ Log.i(“test”, “clicked”); } });
  • 7. HOW DOES IT WORK? ❏ ❏ ❏ ❏ ❏ Ported From the jQuery Documentation Made to be as syntactically like jQuery as possible ❏ No generics ❏ $ for class name Reflection/Proxying Techniques for advanced CSS, Animation, and Event handling Asynchronous Rest API based on Apache HTTPClient Uses NineOldAndroids to support animations and attributes for low APIs
  • 8. What are my alternatives? ❏ ❏ No other library offers all of the features that droidQuery provides. Many libraries support Asynchronous Network Tasks ❏ Android Volley ❏ Spring for Android ❏ AndroidAnnotations ❏ Picasso ❏ Image Specific ❏ Android Query ❏ Also provides APIs similar to jQuery, but syntax is very different. ❏ For animations supporting lower APIs, you can use NineOldAndroids.
  • 9. 2) Understand the Syntax (And a comparison to jQuery)
  • 10. In jQuery: ❏ The variable ‘$’ is used as an alias to the jQuery function, and as such is commonly used to access variables and functions within jQuery. ❏ ❏ $(“#myButton”).click(function(event) { console.log(“element clicked!”); }); droidQuery’s main class is $.java. ❏ $.with(myButton).click(new Function() { public void invoke($ d, Object… args) { Log.i(“droidQuery”, “view clicked!”); } };
  • 11. droidQuery Syntax ❏ ❏ ❏ $.java Function Instantiation using $.with(...) ❏ Modeled after picasso* ❏ Accepts Context, View, View[], List<View>, Context and vararg int ids, etc ❏ Assumes common callback syntax for event handling: ❏ Listeners should be an inner interface of the Object ❏ public interface OnFoobarListener { public void|boolean onFoobar(); } * - http://square.github.io/picasso/
  • 12. 3) UI Traversal & Manipulation
  • 13. Selectors ❏ ❏ ❏ Select one or multiple UI elements Powerful shortcut for manipulating both individual views and groups of views There are many selector methods provided by droidQuery, including: ❏ ❏ ❏ ❏ ❏ ❏ ❏ ❏ ❏ .selectAll() .selectByType() .selectChildren() .selectEmpties() .selectFocused() .selectHidden() .selectImages() .selectOnlyChilds() .selectParents() ❏ ❏ ❏ ❏ ❏ .selectVisible() .union()* .intersect()* .id() .ids() * - special case that accepts a second droidQuery instance as a parameter.
  • 14. Selector Example //Show hidden Views, Hide Shown Views $ hidden = $.with(this).selectHidden(); $.with(this).selectShown().hide(); hidden.show(); //Edit views that contain a LinearLayout as only subview $.with(this) .selectByType(“android.widget.LinearLayout”) .selectOnlyChilds() .selectParents().attr(“backgroundColor”, Color.RED);
  • 15. Manipulate the Selection Once a selection has been made, these (and other) methods will manipulate each View in the selection. Think of them as setters on all the Views in the selection. ❏ ❏ ❏ ❏ ❏ ❏ ❏ ❏ ❏ .attr(“name”, value) .val(Object) .text(int), .text(String) .html(int), .html(String) .mask(...) .id(int) .focus() .focusOut() .tag(Object) ❏ ❏ ❏ .image(Drawable), .image(Bitmap), .image(String) .image(String, int, int, error) ❏ Set Image to Asset, File, or URL .image(List<String>, int, int, error) ❏ Set different Strings for different views in the selection
  • 16. UI Manipulation Example 1 @Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) layout = LayoutInflater.from(mContext) .inflate(R.layout.cell, parent, false); Message data = getItem(position); $.with(layout, R.id.title).text(data.getTitle()) .id(R.id.image).image(data.getImageUrl()); return convertView; }
  • 17. UI Manipulation Example 2 String[] urls = new String[] { “http://bit.ly/mmlogo.png”, “http://bit.ly/mmicon.png”, “http://bit.ly/mmthumb.png” }; int px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 48, getResources().getDisplayMetrics()); $.with(this, R.id.logo, R.id.icon, R.id.thumb) .image(Arrays.asList(urls), px, px, new Function() { public void invoke($ d, Object… args) { Log.e(“Images”, args[0].toString()); } });
  • 18. Getter Shortcuts The setter methods discussed previously become getters (for the first View in the selection) when the last parameter is removed. $ d = $.with(this, CharSequence text0 CharSequence text1 CharSequence text2 android.R.id.text1); = d.text(); = (CharSequence) d.attr(“text”); = (CharSequence) d.val();
  • 19. CSS ❏ Current CSS-related Methods* include: ❏ .height() ❏ .width() ❏ .innerHeight() ❏ .innerWidth() ❏ .outerHeight() ❏ .outerWidth() ❏ .offset() ❏ .position() ❏ .scrollLeft() ❏ .scrollTop() ❏ Future CSS-Related Methods include: ❏ .css(String) ❏ .addClass(...) ❏ .hasClass(...) ❏ .removeClass(...) * All of these methods can be used to get or set the attribute
  • 20. Animations $.with(this, R.id.logo) .animate(“{ width:48dp, height:48dp }”, 400, $.Easing.BOUNCE, new Function() { public void invoke($ d, Object… args) { d.toast(“Animation Complete”, 1); } });
  • 21. Animations, cont’d ❏ Uses a JSON string specifying animation properties, end values, and units. ❏ Units can be any of: px, %, em, dp, dip, sp, in, mm, pt, or none (defaults to px) ❏ Property names must be accessible using Getters or Setters (or via ViewHelper, from NineOldAndroids). ❏ Additionally, an AnimationOptions Object is passed that provides parameters and callbacks for the animation, including duration, interpolator, etc - making these animation highly customizable and responsive.
  • 22. Animation Longhand AnimationOptions options = new AnimationOptions(); options.duration(400) .easing($.Easing.ACCELERATE_DECELERATE) .debug(true) .reverse(true) .repeatCount(2) .progress(new Function() { public void invoke($ d, Object… args) { Log.i(“animate”, args[0]+“=”+args[1]); } })); $.with(this).selectImages() .animate(“{ width:200%, height:200% }”, options);
  • 23. Animation Shortcuts droidQuery includes shortcuts for common animations including: ❏ ❏ ❏ ❏ ❏ ❏ ❏ ❏ .fadeIn() .fadeOut() .fadeTo() .fadeToggle() .slideLeft() .slideUp() .slideRight() .slideDown()
  • 24. 4) Asynchronous Rest Client (Port of Ajax)
  • 25. The $.ajax() Method This method is used to start an asynchronous REST request. There are multiple parameter types this accepts, however primarily developers will use one of: ❏ ❏ AjaxOptions ❏ $.ajax(new AjaxOptions().url(“http://example.com”)); String ❏ Does not support Functions, but may be useful where either global event handlers are already set, or where no callbacks are needed. ❏ $.ajax(“{ url:’http://www.example.com’,” + “ type:’PUT’,” + “ data:{foo:1, bar:’example’}” + “}”);
  • 26. AjaxOptions Example $.ajax(new AjaxOptions() .url(“http://www.weath.er/getTemperature”) .data(“{“zipcode”:“55408”}”) .error(new Function() { public void invoke($ d, Object… args) { AjaxError error = (AjaxError) args[0]; Log.e(“Ajax”, error.toString()); } }).success(new Function() { public void invoke($ d, Object… args) { JSONObject json = (JSONObject) args[0]; Map<String, Object> data = $.map(json); Log.e(“Ajax”, “Temp: ”+ data.get(“Celsius”)); }}));
  • 27. Ajax: Global Event Handlers Global Ajax Event Handlers: Register/Respond to Ajax Events for global requests. These are specified using the .global() method of the AjaxOptions Object. ❏ $.ajaxComplete() ❏ $.ajaxBeforeSend() ❏ $.ajaxError() ❏ $.ajaxStart() ❏ $.ajaxStop() ❏ $.ajaxSuccess()
  • 28. Global Event Handlers Example public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); $.ajaxStart(new Function() { public void invoke($ d, Object… args) { setProgressBarIndeterminateVisibility(true); } }); $.ajaxStop(new Function() { public void invoke($ d, Object… args) { setProgressBarIndeterminateVisibility(false); } }); }
  • 29. Other Ajax Methods ❏ ❏ ❏ Helper Methods ❏ $.serialize() ❏ $.serializeArray() Low-Level Methods ❏ $.ajaxSetup() Shorthand Methods ❏ $.get() ❏ $.getJSON() ❏ $.getScript() ❏ $.post() ❏ $.load() AjaxOptions options = new AjaxOptions(); Integer[] timeouts = new Integer[] {480,419,504,503,522,598,599}; options.error(new Function() { public void invoke($ d, Object… args) { AjaxError error = (AjaxError) args[0]; Log.e(“Ajax Error”, error.toString()); } }.statusCode(timeouts, new function() { public void invoke($ d, Object… args) { Log.e(“Ajax Error”,“Timeout(“+args[0]+ “)”); AjaxOptions o = (AjaxOptions) args[1]; $.ajax(o.statusCode(timeouts, $.noop())); } })); $.ajaxSetup(options);
  • 30. droidQuery Ajax Additions Additionally, droidQuery provides advanced caching and redundancy handling. ❏ Caching ❏ Saves statically - not persistent across JVM sessions ❏ Customizable ❏ ON/OFF ❏ Timeout Interval ❏ Per-Request caching technique (timeout, never timeout, only delete when cache is cleared) ❏ Direct access to cache ❏ Redundancy Handling ❏ Ensures that only one identical request goes out at the same time ❏ Customize how to handle redundant requests ❏ Respond-To-All (default), Respond-To-First, Off
  • 31. 5) Everything Else (well, not everything...)
  • 32. Events ❏ Refers to triggering and responding to ❏ User Input Events, such as clicks and swipes ❏ Changes to the layout ❏ Set or trigger an event using the following methods: ❏ .bind(), .on(), .one(), .change(), .click(), .longclick(), .swipe(), . swipeLeft(), .swipeUp(), .swipeRight(), .swipeDown(), .focus(), . focusout(), .keydown(), .keyup(), .keypress() ❏ Relies on standard Callback syntax to create proxies for the bind(), on(), and one() methods. ❏ Using some of these methods will change a View’s existing onTouchListener.
  • 33. Event Example (1 of 2) Function clickListener = new Function() { public void invoke($ d, Object… args) { d.toast(“a button was clicked!”, Toast.LENGTH_SHORT); } }; $ d = $.with(this).selectByType(Button.class); //any of the below result in the same functionality d.click(clickListener); d.on(“click”, clickListener); d.bind(“click”, null, clickListener); //this will only work the first time each view: d.one(“click”, clickListener);
  • 34. Event Example (2 of 2) //handle EditText edit changes View editor = findViewById(R.id.myEditText); $.with(editor).change(new Function() { public void invoke($ d, Object… args) { Log.i(“Change”, “EditText changed to: ” + d.text()); } });
  • 35. Forms A Form layout allows quick creation of UI forms, plus simple validation. <self.philbrown.view.Form xmlns:android="http://schemas.android.com/apk/res/android" xmlns:droidQuery="http://schemas.android.com/apk/res-auto" android:id=”@+id/form” android:layout_width=”match_parent” android:layout_height=”match_parent” > <EditText android:layout_width=”wrap_content” android:layout_height=”wrap_content” droidQuery:layout_form_required=”true”/> </self.philbrown.view.Form> //Then in code: boolean isValid = ((Form) findViewById(R.id.form)).validate();
  • 36. Utilities Many additional classes and methods are bundled with droidQuery that can help simplify development: ❏ Methods ❏ .view(int) ❏ .each(Function) ❏ .parseJSON(String) ❏ .parseXML(String) ❏ .parseHTML(String) ❏ $.map(JSONObject) ❏ $.makeArray(JSONArray) ❏ .data(), .data(Object) ❏ Classes ❏ QuickMap/QuickEntry ❏ ❏ ❏ ❏ Map<String, ?> map = $.qm($.qe(“foo”, “bar”), $.qe(“first”, 1)); SwipeInterceptorView EventCenter Callbacks
  • 37. droidQuery Extensions ❏ Your project can be a droidQuery extension 1. Create a new library project 2. Create a new Object that extends $Extension 3. Override methods 4. Include in app build path 5. Access library code through droidQuery API ❏ Examples available on Github.
  • 38. What’s next? ❏ ❏ ❏ ❏ ❏ Finish CSS Integration Update javaQuery (http://bit.ly/javaquery) iQuery (Objective-c++) ❏ UITextView *view = [[UITextView] alloc] init]; $ *d = new $(view); NSString *text; text = d->attr(@“text”, @“foobar”).attr(@“text”); NSLog(@“text=’%@’”, text); jQuery to (droid,java,i)Query generation? Hybrid jQuery/(droid,java,i)Query apps?
  • 39. Thank You ❏ droidQuery is still a work in progress. If you would like to contribute ❏ please start by watching the github repo (http://bit.ly/droidquery). ❏ Use the @Modified annotation packaged with the project, to mark your changes to the code. ❏ Javadocs from most recent release are available at http://bit.ly/droidquerydocs. ❏ Open Source Libraries that are used by droidQuery include: ❏ NineOldAndroids - http://nineoldandroids.com/ ❏ cwac-task - https://github.com/commonsguy/cwac-task ❏ jCSS-Parser - https://github.com/phil-brown/jCSS-Parser