groovy-shell-user-manual

User manual of the Groovy Shell android app

View on GitHub

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

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