Home / Programming / Kotlin

Kotlin

Background Processing in Android using Async Task Loader

AsyncTaskLoader is a subclass of Loader, unlike AsyncTask’s, AsyncTaskLoader prevent duplication of background threads and eliminate duplication of zombie (dead or destroyed) activities. First, let’s talk about Loaders. What are Loaders? The Loader API lets you load data from a content provider or any other data source for display in an FragmentActivity or Fragment – Developer.Android.com …

Read More »

Kotlin Data Classes

In this tutorial we are going to discuss kotlin data classes, and show some examples on how you can use them in your app. We frequently create classes whose main purpose is to hold data. In such a case some standard functionality and utility functions are often mechanically derivable from …

Read More »

Kotlin Interface Examples

Kotlin Interface Examples

An interface defines a contract for classes. An interface is similar to an Abstract class just that, an Abstract class is a collection of abstract methods and variables. Let’s say we have an interface called Driveable. interface Driveable { fun drive() // declaring 'abstract' is implicit and unnecessary } we can …

Read More »

Kotlin: Class Examples

Class without a Constructor but with default variable (or properties or data) class Person { val name : String = "Peter" // Default Variable var age : Int = 30 // Default Variable } fun main (args: Array<String>){ val person = Person() // this line tell kotlin to instantiate a …

Read More »

Kotlin ArrayList and Loops Example

Kotlin ArrayList Kotlin ArrayList is also very similar to Java Arraylist. ArrayList<T> is the resizable-array implementation of the List interface. The ArrayList class has only a few methods in addition to the methods available in the List interface. val myArrayList = arrayListOf("John", "Fred", "McKinsey", "Morgan", "Sarah") //an arraylist of my friends val newFriendList …

Read More »