Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Kotlin para Desarrolladores Android - DroidconDO17

Kotlin para Desarrolladores Android - DroidconDO17

Charla sobre Kotlin para Desarrolladores Android dada en la Droidcon en Santo Domingo.

Enlace de la demo:
https://github.com/DevPicon/test-android-marvel-comic

Enlace de los gist:
https://gist.github.com/DevPicon/58911d67b05d25106ca3d7699934ce14

Enlace a la información en la web oficial:
http://droidcon.do/schedule/#session-4

Armando Picón

March 03, 2017
Tweet

More Decks by Armando Picón

Other Decks in Programming

Transcript

  1. public class Person{ private String name; private int age; public

    Person(String name, String age){ this.name = name; this.age = age; } public String getName(){ return this.name; } public int getAge(){ return this.age; } } Gist: https://gist.github.com/DevPicon/58911d67b05d25106ca3d7699934ce14
  2. class Persona constructor(name:String, age: Int){ val name = name var

    age = age } Gist: https://gist.github.com/DevPicon/58911d67b05d25106ca3d7699934ce14
  3. // Clase simplificada class Persona(val name: String, var age: Int)

    Gist: https://gist.github.com/DevPicon/58911d67b05d25106ca3d7699934ce14
  4. // Data class data class Persona(val name: String, var age:

    Int) Gist: https://gist.github.com/DevPicon/58911d67b05d25106ca3d7699934ce14
  5. List people = new ArrayList<Person>(); people.add(new Person(“Armando”,35)); people.add(new Person(“Erik”,26)); people.add(new

    Person(“Adrian”,30)); forEach(Person person: people){ if(person.getName().equals(“Erik”)){ return person; } } Gist: https://gist.github.com/DevPicon/58911d67b05d25106ca3d7699934ce14
  6. val people = listOf<Person>( Person("Adrian", 30), Person("Erik",26), Person("Armando", 35)) val

    person = people.find { it.name == "Erik" } println(person) Gist: https://gist.github.com/DevPicon/58911d67b05d25106ca3d7699934ce14
  7. val numberList = listOf(1, 2, 3, 4, 5) val squared

    = list.map( i -> i * i) assertTrue(squared.containsAll(listOf(1,4,9,16,25))) squared.forEach { println(it) } Gist: https://gist.github.com/DevPicon/58911d67b05d25106ca3d7699934ce14
  8. public class MyActivity extends AppCompatActivity{ @Override public void onCreate(Bundle saveInstanceState){

    super.onCreate(saveInstanceState); setContentView(R.layout.main_activity); TextView myTextView = (TextView) findViewById(R.id.my_textview); myTextView.setText(“¡Hola Android!”); } } Gist: https://gist.github.com/DevPicon/58911d67b05d25106ca3d7699934ce14
  9. class MyActivity : AppCompatActivity{ override fun onCreate(saveInstanceState:Bundle){ super.onCreate(saveInstanceState); setContentView(R.layout.main_activity); val

    myTextView = findViewById(R.id.my_textview) as TextView; myTextView.text = “¡Hola kotlin!” } } Gist: https://gist.github.com/DevPicon/58911d67b05d25106ca3d7699934ce14
  10. fun ImageView.loadImage(url: String?){ if(url != null){ Glide.with(this.context) .load(url) .fitCenter() .into(this)

    } } myImageView.loadImage(“!insert an url here!”) Gist: https://gist.github.com/DevPicon/58911d67b05d25106ca3d7699934ce14
  11. var message : String? = null fun sayHello(message:String?){ if(message !=

    null){ println(message) } } Gist: https://gist.github.com/DevPicon/58911d67b05d25106ca3d7699934ce14