Created
December 29, 2014 16:23
-
-
Save Gazer/2bce6d18ad43215b7b76 to your computer and use it in GitHub Desktop.
Groovy on Android
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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