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
hyperpoetto import packages from my Http Client Librarygmageto import packages from my Image Processing libraryjsoupto import packages from Jsouptimeunitto import enums from java TimeUit classtimeto import dates Java classesjsonto import packages fromgroovy.jsonxmlto import packages fromgroovy.xmlchartto import classes from the chart library, wrapper of MPAndroidChartbitmapto 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