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

Travelling Across Asia - Our Journey from Java ...

Travelling Across Asia - Our Journey from Java to Kotlin

Given at Android Makers FR - Paris, 2018

Amal Kakaiya

April 23, 2018
Tweet

More Decks by Amal Kakaiya

Other Decks in Programming

Transcript

  1. Java Kotlin AutoValue/Lombok Data classes Streams support Standard lib functions

    Retrolambda Built in lambda support Butterknife Kotterknife/delegate properties # TravellingAcrossAsia @K4KYA
  2. TESTS ARE AN EASY WAY TO GET STARTED BUT NOT

    VERY EXCITING # TravellingAcrossAsia @K4KYA
  3. private fun mapToIds(items: List<Item>): List<String> { val ids = mutableListOf<String>()

    for (item in items) { ids.add(item.id) } return ids } # TravellingAcrossAsia @K4KYA
  4. private fun mapToIds(items: List<Item>): List<String> { val ids = items.map

    { it.id } return ids } # TravellingAcrossAsia @K4KYA
  5. private final mapToId(Ljava/util/List;)Ljava/ util/List; L0 LINENUMBER 2 L0 ALOAD 1

    CHECKCAST java/lang/Iterable ASTORE 2 ———————— 75 more lines ———————— # TravellingAcrossAsia @K4KYA
  6. private final List mapToId(List items) { Iterable $receiver$iv = (Iterable)items;

    Collection destination$iv$iv = (Collection)(new ArrayList(CollectionsKt.collectionSizeOrDefault($receiver$ iv, 10))); Iterator var5 = $receiver$iv.iterator(); while(var5.hasNext()) { Object item$iv$iv = var5.next(); Item it = (Item)item$iv$iv; String var12 = it.id; destination$iv$iv.add(var12); } return (List)destination$iv$iv; } # TravellingAcrossAsia @K4KYA
  7. val extraOptions = items .map { "Item $it" } .takeIf

    { showExtraOptions } # TravellingAcrossAsia @K4KYA
  8. Iterable $receiver$iv = (Iterable)items; Collection $receiver$iv = (Collection)(new ArrayList(CollectionsKt.collectionSizeOrDefault($receiver$iv, 10)));

    Iterator var8 = $receiver$iv.iterator(); while(var8.hasNext()) { Object item$iv$iv = var8.next(); String it = (String)item$iv$iv; String var17 = "Item " + it; $receiver$iv.add(var17); } List var10000 = (List)$receiver$iv; List extraOptions = showExtraOptions ? var10000 : null; # TravellingAcrossAsia @K4KYA
  9. Iterable $receiver$iv = (Iterable)items; Collection $receiver$iv = (Collection)(new ArrayList(CollectionsKt.collectionSizeOrDefault($receiver$iv, 10)));

    Iterator var8 = $receiver$iv.iterator(); while(var8.hasNext()) { Object item$iv$iv = var8.next(); String it = (String)item$iv$iv; String var17 = "Item " + it; $receiver$iv.add(var17); } List var10000 = (List)$receiver$iv; List extraOptions = showExtraOptions ? var10000 : null; # TravellingAcrossAsia @K4KYA
  10. val extraOptions = if (showExtraOptions) items .map { "Item $it"

    } else null # TravellingAcrossAsia @K4KYA
  11. CONSIDER NULLABILITY WHEN IMPLEMENTING A JAVA INTERFACE private val passwordActionListener

    = TextView.OnEditorActionListener { _: TextView, _: Int, _: KeyEvent -> login(password()) } # TravellingAcrossAsia @K4KYA
  12. CONSIDER NULLABILITY WHEN IMPLEMENTING A JAVA INTERFACE private val passwordActionListener

    = TextView.OnEditorActionListener { _: TextView, _: Int, _: KeyEvent -> login(password()) } # TravellingAcrossAsia @K4KYA
  13. CONSIDER NULLABILITY WHEN IMPLEMENTING A JAVA INTERFACE private val passwordActionListener

    = TextView.OnEditorActionListener { _: TextView, _: Int, _: KeyEvent -> login(password()) } # TravellingAcrossAsia @K4KYA
  14. CONSIDER NULLABILITY WHEN IMPLEMENTING A JAVA INTERFACE private val passwordActionListener

    = TextView.OnEditorActionListener { _: TextView, _: Int, _: KeyEvent -> login(password()) } # TravellingAcrossAsia @K4KYA
  15. CONSIDER NULLABILITY WHEN IMPLEMENTING A JAVA INTERFACE private val passwordActionListener

    = TextView.OnEditorActionListener { _: TextView, _: Int, _: KeyEvent? -> login(password()) } # TravellingAcrossAsia @K4KYA
  16. CONSIDER NULLABILITY WHEN IMPLEMENTING A JAVA INTERFACE private val passwordActionListener

    = TextView.OnEditorActionListener { _: TextView, _: Int, _: KeyEvent? -> login(password()) } # TravellingAcrossAsia @K4KYA
  17. CONVERTING CODE class VerifyActivity: BaseActivity<VerifyPresenter>, VerifyScreen { override val message:

    String = getString(R.string.verify_error) # TravellingAcrossAsia @K4KYA
  18. CONVERTING CODE class VerifyActivity: BaseActivity<VerifyPresenter>, VerifyScreen { override val message:

    String get() = getString(R.string.verify_error) # TravellingAcrossAsia @K4KYA