• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Android query

Android query



Slides from Android dev meeting in Zilina, Slovakia about AndroidQuery.

Slides from Android dev meeting in Zilina, Slovakia about AndroidQuery.

follow me on:



Total Views
Views on SlideShare
Embed Views



2 Embeds 3

https://twitter.com 2
http://www.slashdocs.com 1


Upload Details

Uploaded via as OpenOffice

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.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment

    Android query Android query Presentation Transcript

    • Android Query Makes Android codingsimpler, easier, and more fun! Michal CoPLaS Pavlasek www.pavlasek.sk/devel/ twitter.com/pavlasek
    • About meJava, Android, Grails (etc...) developerIm not creator of Android Query :)Just fan of it
    • Android QueryLight-weight library for doing asynchronous tasks and manipulating UI elements in Android http://code.google.com/p/android-query/ Inspired by jQuery, a javascript framework for web site, hence the name "Query".
    • Android Query Things I really like:Less CodeChainingAJAX CallbackImage LoadingIn-app Version CheckMultiple UI, One Piece of Code
    • Less Code - Beforepublic void renderContent(Content content, View view) { ImageView tbView = (ImageView) view.findViewById(R.id.icon); if(tbView != null){ tbView.setImageBitmap(R.drawable.icon); tbView.setVisibility(View.VISIBLE); tbView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { someMethod(v); } }); } TextView nameView = (TextView) view.findViewById(R.id.name); if(nameView != null){ nameView.setText(content.getPname()); } TextView timeView = (TextView) view.findViewById(R.id.time); if(timeView != null){ long now = System.currentTimeMillis(); timeView.setText(FormatUtility.relativeTime(now, content.getCreate())); timeView.setVisibility(View.VISIBLE); } TextView descView = (TextView) view.findViewById(R.id.desc); if(descView != null){ descView.setText(content.getDesc()); descView.setVisibility(View.VISIBLE); }}
    • Less Code - Afterpublic void renderContent(Content content, View view) { AQuery aq = new AQuery(view); aq.id(R.id.icon).image(R.drawable.icon).visible().clicked(this, "someMethod"); aq.id(R.id.name).text(content.getPname()); aq.id(R.id.time).text(FormatUtility.relativeTime( System.currentTimeMillis(), content.getCreate())).visible(); aq.id(R.id.desc).text(content.getDesc()).visible();}
    • ChainingAll "set" methods in AQuery returns itself.String name = "My name in black text, redbackground, visible, and invoke nameClickedwhen clicked";aq.id(R.id.name).text(name).background(R.color.red).textColor(R.color.black).enabled(true).visible().clicked(this, "nameClicked");
    • AJAX Callback - JSON Examplepublic void asyncJson(){ //perform a Google search in just a few lines of code String url = "http://www.google.com/uds/GnewsSearch?q=Obama&v=1.0"; aq.ajax(url, JSONObject.class, this, "jsonCallback");}public void jsonCallback(String url, JSONObject json,AjaxStatus status){ if(json != null){ //successful ajax call }else{ //ajax error }}
    • Image LoadingSimpleMemory & File CachingDown SamplingZoomable (WebView)Fallback ImagePreloadingAnimationDynamic Aspect RatioAvoid Duplicated Simultaneous FetchesCustom Callback
    • Image Loadingaq.id(R.id.image1).image( "http://www.vikispot.com/z/images/vikispot/android-w.png");//this image is huge, avoid memory cachingboolean memCache = false;boolean fileCache = true;aq.id(R.id.image1).image( "http://www.vikispot.com/z/images/vikispot/android-w.png", memCache, fileCache);aq.id( R.id.image).image("https://graph.facebook.com/" + item.fromId + "/picture?type=large", true, true, 0, 0, null, Aquery.FADE_IN);See more: http://code.google.com/p/android-query/wiki/ImageLoading
    • In-app Version Check@Overridepublic void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); MarketService ms = new MarketService(this); ms.level(MarketService.MINOR).checkVersion();}See more: http://code.google.com/p/android-query/wiki/Service
    • Multiple UI, One Piece of Codepublic void renderContent(Content content, View view) { //this is a phone! //this view exists aq.id(R.id.textInMobileLayoutOnly).text( "Welcome to my Mobile App!"); //this button exist in tablet layout only, but its ok //AQuery will ignore all the operations on this view aq.id(R.id.butttonInTabletOnly).text("Open a new tab!");}
    • And many more...BindingXML ParsingAuthenticationAlleviate FragmentationExtendableLight WeightNon-intrusiveOpen Source
    • More info http://code.google.com/p/android-query/ http://twitter.com/AndroidQueryhttp://groups.google.com/group/android-query