Android query


Published on

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

follow me on:

Published in: Technology, News & Politics
  • Be the first to comment

Android query

  1. 1. Android Query Makes Android codingsimpler, easier, and more fun! Michal CoPLaS Pavlasek
  2. 2. About meJava, Android, Grails (etc...) developerIm not creator of Android Query :)Just fan of it
  3. 3. Android QueryLight-weight library for doing asynchronous tasks and manipulating UI elements in Android Inspired by jQuery, a javascript framework for web site, hence the name "Query".
  4. 4. Android Query Things I really like:Less CodeChainingAJAX CallbackImage LoadingIn-app Version CheckMultiple UI, One Piece of Code
  5. 5. Less Code - Beforepublic void renderContent(Content content, View view) { ImageView tbView = (ImageView) view.findViewById(; 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(; if(nameView != null){ nameView.setText(content.getPname()); } TextView timeView = (TextView) view.findViewById(; if(timeView != null){ long now = System.currentTimeMillis(); timeView.setText(FormatUtility.relativeTime(now, content.getCreate())); timeView.setVisibility(View.VISIBLE); } TextView descView = (TextView) view.findViewById(; if(descView != null){ descView.setText(content.getDesc()); descView.setVisibility(View.VISIBLE); }}
  6. 6. Less Code - Afterpublic void renderContent(Content content, View view) { AQuery aq = new AQuery(view);, "someMethod");; System.currentTimeMillis(), content.getCreate())).visible();;}
  7. 7. ChainingAll "set" methods in AQuery returns itself.String name = "My name in black text, redbackground, visible, and invoke nameClickedwhen clicked";, "nameClicked");
  8. 8. AJAX Callback - JSON Examplepublic void asyncJson(){ //perform a Google search in just a few lines of code String url = ""; 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 }}
  9. 9. Image LoadingSimpleMemory & File CachingDown SamplingZoomable (WebView)Fallback ImagePreloadingAnimationDynamic Aspect RatioAvoid Duplicated Simultaneous FetchesCustom Callback
  10. 10. Image "");//this image is huge, avoid memory cachingboolean memCache = false;boolean fileCache = true; "", memCache, fileCache);"" + item.fromId + "/picture?type=large", true, true, 0, 0, null, Aquery.FADE_IN);See more:
  11. 11. In-app Version Check@Overridepublic void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); MarketService ms = new MarketService(this); ms.level(MarketService.MINOR).checkVersion();}See more:
  12. 12. Multiple UI, One Piece of Codepublic void renderContent(Content content, View view) { //this is a phone! //this view exists "Welcome to my Mobile App!"); //this button exist in tablet layout only, but its ok //AQuery will ignore all the operations on this view"Open a new tab!");}
  13. 13. And many more...BindingXML ParsingAuthenticationAlleviate FragmentationExtendableLight WeightNon-intrusiveOpen Source
  14. 14. More info