Xtendroid

xtendroid

Xtendroid is a domain-specific-language for Android that I created for productive Android development

Toby Kurien Android apps android java xtend xtendroid library github open source domain specific language dsl

Xtendroid is an open source Android DSL I wrote to make writing Android apps easier, more productive, and most importantly, much more fun! Its main function is to remove boilerplate code that is associated with Android development.

Xtendroid allows Android developers to write code the way they think about it (i.e. pseudo-code), rather than the way Android's compiler and packager expects it. At the end of the day you are writing the exact same code, because the full source code gets generated from the simpler code you write.

Here is some sample Xtendroid code (the equivalent Java source is several screens long):

@AndroidActivity(R.layout.activity_main) class MainActivity {

   @OnCreate   // Run this method when widgets are ready
   def init() {
        // make a progress dialog
        val pd = new ProgressDialog(this)
        pd.message = "Loading quote..."

        // set up the button to load quotes
        mainLoadQuote.onClickListener = [
           // load quote in the background, showing progress dialog
           async(pd) [
              // get the data in the background
              getData('http://www.iheartquotes.com/api/v1/random')
           ].then [result|
              // update the UI with new data
              mainQuote.text = Html.fromHtml(result)
           ].onError [error|
              // handle any errors by toasting it
              toast("Error: " + error.message)
           ].start()
        ]
   }

}

I have been using Xtendroid in my professional apps for several years, and it has made a huge difference to productivity. Find out more about Xtendroid at the github project page