Import Aliases
An import alias is basically an alias that will be used to import many packages (and eventually enums), in one commands. Here is the list of import aliases
hyperpoet
to import packages from my Http Client Librarygmage
to import packages from my Image Processing libraryjsoup
to import packages from Jsouptimeunit
to import enums from java TimeUit classtime
to import dates Java classesjson
to import packages fromgroovy.json
xml
to import packages fromgroovy.xml
chart
to import classes from the chart library, wrapper of MPAndroidChartbitmap
to import classes from Android SDK Bitmap
To use one, simply import it like you would import any package:
import gmage
An import alias can have a script that runs when imported to (for example) add some functions in some objects, by using Groovy meta-programming
Here are some example of codes with added functions for some import aliases
Bitmap
You can use android Bitmap class to manipulate images
import bitmap
f = file("image.png")
b = f.toBitmap()
b = b.scaled(105,105)
// default format is PNG
b.writeInto(file("result.png"))
b.writeInto(file("result.png"), JPEG)
Example:
import hyperpoet
API_URL = "https://jsonplaceholder.typicode.com/"
client = new HttpPoet(url: API_URL, contentType: ContentType.JSON, acceptContentType: ContentType.JSON)
data = client.get("/posts")
println data.title