116: Learning Kotlin – inline, noinline and crossinline

In this episode of learning kotlin, we look at 3 important keywords – inline, noinline and crossinline. The inline keyword is super common and you’ve probably run across this one at some point. What does it mean and when is it useful? We also look at the related but seldom used variants noinline and crossinline.

Download directly

Show Notes

Code Snippets:

Simple inlined function:

// Kotlin 
fun main(args: Array<String>) {
    functionA()
}

inline fun functionA() {
    println("awesomeness !")
}

Warning: Expected performance impact of inlining ‘public inline fun functionA() can be insignificant. Inlining works best for functions with lambda parameters

What the code looks like in Java:

public static final void main(String[] args) {
  String var1 = "awesomeness !";
  System.out.println(var1);
}

Function with lambda parameter:

fun main(args: Array<String>) {
    functionA({
        println("double awesomeness")
    })
}

inline fun functionA(lambda: () -> Unit) {
    println("awesomeness !")
    lambda.invoke()
}

What the code looks like in Java (without inline):

public static final void main(String[] args) {
    functionA(new Function() {
      println("double awesomeness")  
    });
}

public static final void functionA(Function0 lambda) {
    String var1 = "awesomeness !";
    System.out.println(var1);
    lambda.invoke();
}

What the code looks like in Java (with inline):

public static final void main(String[] args) {
    String var1 = "awesomeness !";
    System.out.println(var1);
    String var2 = "double awesomeness";
    System.out.println(var2);
}

Function0:

public interface Function0<out R> : Function<R> {
    /** Invokes the function. */
    public operator fun invoke(): R
}

Misc:

Sponsors

  • Microsoft AppCenter – Sign up now on appcenter.ms and spend less time managing your app lifecycle and more time coding.

Contact

115: Architecture Components with Akshay Chordiya

In this episode, we talk about the different parts of Android architecture components. We’ve had episodes on Room and the paging library, so in this one, we thought we’ll touch a little on Lifecycle Owners & Observers, ViewModels, and LiveData. Akshay Chordiya helps break it down. Listen on!

Download directly

Show Notes

Lifecycle

ViewModels

Code snippet for a ViewModelFactory:

class UserVMFactory(
        val user: MyUser
) : ViewModelProvider.Factory {
    override fun <T : ViewModel?> create(modelClass: Class<T>): T {
        return when {
            modelClass.isAssignableFrom(UserVM::class.java) ->
                UserVM(user) as T
            else -> throw IllegalArgumentException("Unknown ViewModel class")
        }
    }
}

LiveData

Misc

Sponsors

  • Microsoft AppCenter – Sign up now on appcenter.ms and spend less time managing your app lifecycle and more time coding.

Contact

114 : All About CI & CD on App Center w/ Patrick Nikoletich

In this episode, we talk to Patrick Nikoletich from Microsofts App Center team. We explore the intricacies of the Continuous Integration server system on the App Center platform. From what App Center is, all the way down into the weeds to how to get your app building on App Center in a few short steps. We also get into the nitty-gritty details around how you can customize your build with build hooks, install utilities and binaries, work with a command line interface, shell scripts, the App Center API much much more. This episode shows a new side of Microsoft that we have not seen in a long time and it’s a breath of fresh air.

Download Directly

Show Notes

  • VSTS: https://www.visualstudio.com/team-services/
  • Microsoft on GitHub: https://github.com/Microsoft
  • The App Center CLI: https://github.com/Microsoft/appcenter-cli
  • Azure function that automatically creates branch configurations for PR’s and communicates status back to Github.: https://github.com/pniko/function-appcenter-build-
  • App Center API: https://docs.microsoft.com/en-us/appcenter/api-docs/ & https://openapi.appcenter.ms/
  • Detox fo React Native Native: https://github.com/wix/detox
  • Azure Server Functions: https://azure.microsoft.com/en-us/services/functions/

Sponsors

  • Mapbox – Android developers don’t have to settle for a default same-map-no-matter-what option in their Android app. Mapbox offers complete map design control, allowing you to create beautiful custom maps to meet the needs of your Android users.

Contact

113: Chatting with Pinterest’s Christina Lee

In this episode we catch up with a highly energetic but sick Christina Lee about the delightful details in the Pinterest app, delving with the dark side (Swift), giving live coding presentation talks and touching on some Kotlin details like covariance and contravariance. Listen on for a power-packed 40 minutes.

Download directly

Show Notes

Sponsors

  • Mapbox – Android developers don’t have to settle for a default same-map-no-matter-what option in their Android app. Mapbox offers complete map design control, allowing you to create beautiful custom maps to meet the needs of your Android users.

Show Notes

Sponsors

  • Mapbox – Android developers don’t have to settle for a default same-map-no-matter-what option in their Android app. Mapbox offers complete map design control, allowing you to create beautiful custom maps to meet the needs of your Android users.

Contact

112: Effective Java v3 – Item #9 – Prefer try with resources to try finally

In this mini-fragment episode, Donn talks about Item #9 of the Effective Java (Third Edition) book – Prefer try with resources to try finally.

Please note, this episode references the third edition of the Effective Java book that recently came out. Previously we were doing the entire series on version 2, but we are now upgrading to version 3 of the book. We will not be re-doing any of the existing lessons, but if one was inserted in the mix, then we will do that lesson.

Listen on:

Download directly

Links

Sponsors

  • Mapbox – Android developers don’t have to settle for a default same-map-no-matter-what option in their Android app. Mapbox offers complete map design control, allowing you to create beautiful custom maps to meet the needs of your Android users.

Check them out today at mapbox.com/android

Contact