Skip to content

Instantly share code, notes, and snippets.

@Gazer
Created December 29, 2014 16:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Gazer/2bce6d18ad43215b7b76 to your computer and use it in GitHub Desktop.
Save Gazer/2bce6d18ad43215b7b76 to your computer and use it in GitHub Desktop.
Groovy on Android
@CompileStatic
public class MainActivity extends ActionBarActivity {
TextView textView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textView = findViewById(R.id.text) as TextView;
def model = new Model();
model.items.add("ok");
model.items.add("otro");
model.items.each { String key ->
Log.d("ACA", "Tengo $key");
}
// Fluent.groovy from https://gist.github.com/melix/355185ffbc1332952cc8
Fluent.async {
new URL('http://google.com').getText("utf-8")
}.then { text ->
textView.setText(text as String);
}
}
}
@CompileStatic
class Model {
String name = "Hola";
List<String> items = []
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment