Sunteți pe pagina 1din 22
Kotlin : Short fun Story Tale
Kotlin : Short fun Story Tale
Kotlin : Short fun Story Tale
Kotlin : Short fun Story Tale
Kotlin : Short fun Story Tale

Kotlin :

Short fun Story Tale

Kotlin : Short fun Story Tale
Kotlin : Short fun Story Tale
Kotlin : Short fun Story Tale
Kotlin : Short fun Story Tale
Budi Oktaviyan Suryanto Associate Mobile Developer Co-Founder of Kotlin ID Sidiq Permana @nouvrizky10
Budi Oktaviyan Suryanto Associate Mobile Developer Co-Founder of Kotlin ID Sidiq Permana @nouvrizky10
Budi Oktaviyan Suryanto Associate Mobile Developer Co-Founder of Kotlin ID Sidiq Permana @nouvrizky10
Budi Oktaviyan Suryanto Associate Mobile Developer Co-Founder of Kotlin ID Sidiq Permana @nouvrizky10

Budi Oktaviyan Suryanto

Associate Mobile Developer

Co-Founder of Kotlin ID

Sidiq Permana @nouvrizky10
Sidiq Permana
@nouvrizky10
Budi Oktaviyan Suryanto Associate Mobile Developer Co-Founder of Kotlin ID Sidiq Permana @nouvrizky10
Budi Oktaviyan Suryanto Associate Mobile Developer Co-Founder of Kotlin ID Sidiq Permana @nouvrizky10
Budi Oktaviyan Suryanto Associate Mobile Developer Co-Founder of Kotlin ID Sidiq Permana @nouvrizky10
Budi Oktaviyan Suryanto Associate Mobile Developer Co-Founder of Kotlin ID Sidiq Permana @nouvrizky10
Budi Oktaviyan Suryanto Associate Mobile Developer Co-Founder of Kotlin ID Sidiq Permana @nouvrizky10
Budi Oktaviyan Suryanto Associate Mobile Developer Co-Founder of Kotlin ID Sidiq Permana @nouvrizky10
Null Safety can be fun Courtesy by http://www.nick-asia.com/
Null Safety can be fun Courtesy by http://www.nick-asia.com/
Null Safety can be fun Courtesy by http://www.nick-asia.com/
Null Safety can be fun Courtesy by http://www.nick-asia.com/
Null Safety can be fun Courtesy by http://www.nick-asia.com/
Null Safety can be fun Courtesy by http://www.nick-asia.com/
Null Safety can be fun Courtesy by http://www.nick-asia.com/
Null Safety can be fun Courtesy by http://www.nick-asia.com/

Null Safety can be fun

Courtesy by http://www.nick-asia.com/

WHAT IS KOTLIN ? Statically typed programming language for modern multi platform applications build for
WHAT IS KOTLIN ? Statically typed programming language for modern multi platform applications build for
WHAT IS KOTLIN ? Statically typed programming language for modern multi platform applications build for

WHAT IS KOTLIN ?

Statically typed programming language for modern multi

platform applications build for JVM, Android, Browser and

Native

? Statically typed programming language for modern multi platform applications build for JVM, Android, Browser and
? Statically typed programming language for modern multi platform applications build for JVM, Android, Browser and
? Statically typed programming language for modern multi platform applications build for JVM, Android, Browser and
? Statically typed programming language for modern multi platform applications build for JVM, Android, Browser and
THE REASON WHY YOU SHOULD GIVE IT A TRY
THE REASON WHY YOU SHOULD GIVE IT A TRY
THE REASON WHY YOU SHOULD GIVE IT A TRY

THE REASON WHY YOU SHOULD GIVE IT A TRY

THE REASON WHY YOU SHOULD GIVE IT A TRY
THE REASON WHY YOU SHOULD GIVE IT A TRY
THE REASON WHY YOU SHOULD GIVE IT A TRY
THE REASON WHY YOU SHOULD GIVE IT A TRY
THE REASON WHY YOU SHOULD GIVE IT A TRY
THE REASON WHY YOU SHOULD GIVE IT A TRY
THE REASON WHY YOU SHOULD GIVE IT A TRY
THE EVOLUTION OF HOLY findViewById() TextView tvResult = (TextView) findViewById(R.id.tv_result); Lovely Java
THE EVOLUTION OF HOLY findViewById() TextView tvResult = (TextView) findViewById(R.id.tv_result); Lovely Java
THE EVOLUTION OF HOLY findViewById() TextView tvResult = (TextView) findViewById(R.id.tv_result); Lovely Java

THE EVOLUTION OF HOLY findViewById()

TextView tvResult = (TextView) findViewById(R.id.tv_result);

Lovely Java

@BindView(R.id.tv_result) TextView tvResult;

Georgeous ButterKnife

MainActivityBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_main); MainViewModel viewModel = new MainViewModel(); binding.setViewModel(viewModel);

<TextView android:id="@+id/tv_result" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@{viewModel.name}" />

The Great DataBinding

val tvResult = findViewById(R.id.tv_result) as? TextView

The Pure Kotlin

val tvResult = find<TextView>(R.id.tv_result)

The Cool Anko

as? TextView The Pure Kotlin val tvResult = find<TextView>(R.id.tv_result) The Cool Anko
as? TextView The Pure Kotlin val tvResult = find<TextView>(R.id.tv_result) The Cool Anko
as? TextView The Pure Kotlin val tvResult = find<TextView>(R.id.tv_result) The Cool Anko
as? TextView The Pure Kotlin val tvResult = find<TextView>(R.id.tv_result) The Cool Anko
All Hail Android Extensions ! tvResult.text = "Result" No need findViewById or ViewInjection Anymore !
All Hail Android Extensions ! tvResult.text = "Result" No need findViewById or ViewInjection Anymore !
All Hail Android Extensions ! tvResult.text = "Result" No need findViewById or ViewInjection Anymore !

All Hail Android Extensions!

All Hail Android Extensions ! tvResult.text = "Result" No need findViewById or ViewInjection Anymore ! Courtesy

tvResult.text = "Result"

No need findViewById or ViewInjection Anymore !

! tvResult.text = "Result" No need findViewById or ViewInjection Anymore ! Courtesy by http://www.nick-asia.com/
! tvResult.text = "Result" No need findViewById or ViewInjection Anymore ! Courtesy by http://www.nick-asia.com/
! tvResult.text = "Result" No need findViewById or ViewInjection Anymore ! Courtesy by http://www.nick-asia.com/
! tvResult.text = "Result" No need findViewById or ViewInjection Anymore ! Courtesy by http://www.nick-asia.com/

Courtesy by http://www.nick-asia.com/

THE LISTENER JOURNEY btnMain.setOnClickListener(new View.OnClickListener() { @Override public void onClick( final View
THE LISTENER JOURNEY btnMain.setOnClickListener(new View.OnClickListener() { @Override public void onClick( final View
THE LISTENER JOURNEY btnMain.setOnClickListener(new View.OnClickListener() { @Override public void onClick( final View

THE LISTENER JOURNEY

btnMain.setOnClickListener(new View.OnClickListener() { @Override

public void onClick(final View view) {

Lovely Java (AGAIN)

// TODO coba godain janda sebelah rumah

}

});

Java (AGAIN) // TODO coba godain janda sebelah rumah } }); @OnClick(R.id.btn_main) public void onBtnMainClick() {

@OnClick(R.id.btn_main) public void onBtnMainClick() {

}); @OnClick(R.id.btn_main) public void onBtnMainClick() { Georgeous ButterKnife (AGAIN) // TODO jaga mata kalau lagi
}); @OnClick(R.id.btn_main) public void onBtnMainClick() { Georgeous ButterKnife (AGAIN) // TODO jaga mata kalau lagi

Georgeous ButterKnife (AGAIN)

// TODO jaga mata kalau lagi di mall

}

public void onBtnMainClick() { Georgeous ButterKnife (AGAIN) // TODO jaga mata kalau lagi di mall }
LAMBDA EXPRESSION btnMain.setOnClickListener { TODO( "Sederhana lebih seru gan" ) } Courtesy by
LAMBDA EXPRESSION btnMain.setOnClickListener { TODO( "Sederhana lebih seru gan" ) } Courtesy by
LAMBDA EXPRESSION btnMain.setOnClickListener { TODO( "Sederhana lebih seru gan" ) } Courtesy by

LAMBDA EXPRESSION

btnMain.setOnClickListener { TODO("Sederhana lebih seru gan")

}

EXPRESSION btnMain.setOnClickListener { TODO( "Sederhana lebih seru gan" ) } Courtesy by http://www.nick-asia.com/

Courtesy by http://www.nick-asia.com/

EXPRESSION btnMain.setOnClickListener { TODO( "Sederhana lebih seru gan" ) } Courtesy by http://www.nick-asia.com/
EXPRESSION btnMain.setOnClickListener { TODO( "Sederhana lebih seru gan" ) } Courtesy by http://www.nick-asia.com/
EXPRESSION btnMain.setOnClickListener { TODO( "Sederhana lebih seru gan" ) } Courtesy by http://www.nick-asia.com/
EXPRESSION btnMain.setOnClickListener { TODO( "Sederhana lebih seru gan" ) } Courtesy by http://www.nick-asia.com/
THE MAGIC OF with() with(movie) { } val text = " $name on $year "
THE MAGIC OF with() with(movie) { } val text = " $name on $year "
THE MAGIC OF with() with(movie) { } val text = " $name on $year "

THE MAGIC OF with()

with(movie) {

}

val text = "$name on $year" tvTitle.text = text

THE MAGIC OF with() with(movie) { } val text = " $name on $year " tvTitle.text
THE MAGIC OF with() with(movie) { } val text = " $name on $year " tvTitle.text
THE MAGIC OF with() with(movie) { } val text = " $name on $year " tvTitle.text
THE MAGIC OF with() with(movie) { } val text = " $name on $year " tvTitle.text
THE FABULOUS when() and for range Makes loop for range GREAT AGAIN! when (type) {
THE FABULOUS when() and for range Makes loop for range GREAT AGAIN! when (type) {
THE FABULOUS when() and for range Makes loop for range GREAT AGAIN! when (type) {

THE FABULOUS when() and for range

Makes loop for

range

GREAT AGAIN!

when (type) { 1 -> return "Perawan"

2 -> return "Janda"

for (index in mantans.indices) {

if (mantan in 1

100) {

println("Mantan ke $index")

else -> return "Gak Jelas!"

}

}

}

Sorry, we have better than the old lady b**ch

switch

case

-> return "Gak Jelas!" } } } Sorry, we have better than the old lady b**ch
-> return "Gak Jelas!" } } } Sorry, we have better than the old lady b**ch
-> return "Gak Jelas!" } } } Sorry, we have better than the old lady b**ch
-> return "Gak Jelas!" } } } Sorry, we have better than the old lady b**ch
PAINLESS FOR DOING BACKGROUND doAsync { Simplifying the AsyncTask val result = URL(apiUrl).readText() uiThread {
PAINLESS FOR DOING BACKGROUND doAsync { Simplifying the AsyncTask val result = URL(apiUrl).readText() uiThread {
PAINLESS FOR DOING BACKGROUND doAsync { Simplifying the AsyncTask val result = URL(apiUrl).readText() uiThread {

PAINLESS FOR DOING BACKGROUND

doAsync {

Simplifying the AsyncTask

val result = URL(apiUrl).readText()

uiThread {

tvResult.text = result

}

}

URL(apiUrl).readText() uiThread { tvResult.text = result } } async(UI) { val users: Deferred<List<User>>
URL(apiUrl).readText() uiThread { tvResult.text = result } } async(UI) { val users: Deferred<List<User>>
URL(apiUrl).readText() uiThread { tvResult.text = result } } async(UI) { val users: Deferred<List<User>>

async(UI) {

val users: Deferred<List<User>> = bg { getUsers() }

showUsers(users.await())

}

{ val users: Deferred<List<User>> = bg { getUsers() } showUsers(users.await()) } Coroutine in Action!

Coroutine in Action!

THEY ARE ALREADY USING KOTLIN And many more… including YOU (maybe)
THEY ARE ALREADY USING KOTLIN And many more… including YOU (maybe)
THEY ARE ALREADY USING KOTLIN And many more… including YOU (maybe)

THEY ARE ALREADY USING KOTLIN

THEY ARE ALREADY USING KOTLIN And many more… including YOU (maybe)
THEY ARE ALREADY USING KOTLIN And many more… including YOU (maybe)
THEY ARE ALREADY USING KOTLIN And many more… including YOU (maybe)
THEY ARE ALREADY USING KOTLIN And many more… including YOU (maybe)
THEY ARE ALREADY USING KOTLIN And many more… including YOU (maybe)
THEY ARE ALREADY USING KOTLIN And many more… including YOU (maybe)
THEY ARE ALREADY USING KOTLIN And many more… including YOU (maybe)
THEY ARE ALREADY USING KOTLIN And many more… including YOU (maybe)
THEY ARE ALREADY USING KOTLIN And many more… including YOU (maybe)

And many more… including YOU (maybe)

THEY ARE ALREADY USING KOTLIN And many more… including YOU (maybe)
THEY ARE ALREADY USING KOTLIN And many more… including YOU (maybe)
The Tools With Kotlin Plugin No Plugin Needed!
The Tools With Kotlin Plugin No Plugin Needed!
The Tools With Kotlin Plugin No Plugin Needed!

The Tools

With Kotlin Plugin No Plugin Needed!
With Kotlin Plugin
No Plugin Needed!
The Tools With Kotlin Plugin No Plugin Needed!
HOW DO YOU START ? 1. Learn Kotlin as Language secara “ KAFFAH ” a.k.a
HOW DO YOU START ? 1. Learn Kotlin as Language secara “ KAFFAH ” a.k.a
HOW DO YOU START ? 1. Learn Kotlin as Language secara “ KAFFAH ” a.k.a

HOW DO YOU START ?

1. Learn Kotlin as Language secara KAFFAH” a.k.a Menyeluruh

2. Understanding about LAMBDA Expression

3. And Yeah… FUNCTIONAL PROGRAMMING

4. Start Your Android Project with

about LAMBDA Expression 3. And Yeah… FUNCTIONAL PROGRAMMING 4. Start Your Android Project with Kotlin enabled
about LAMBDA Expression 3. And Yeah… FUNCTIONAL PROGRAMMING 4. Start Your Android Project with Kotlin enabled
about LAMBDA Expression 3. And Yeah… FUNCTIONAL PROGRAMMING 4. Start Your Android Project with Kotlin enabled

Kotlin enabled

about LAMBDA Expression 3. And Yeah… FUNCTIONAL PROGRAMMING 4. Start Your Android Project with Kotlin enabled
LET’S CODE!
LET’S CODE!
LET’S CODE!

LET’S CODE!

LET’S CODE!
LET’S CODE!
LET’S CODE!
LET’S CODE!
LET’S CODE!