Implementing multi-select on a Recycler View can be tricky and complicated. However, by the end of this tutorial, you’ll understand how to implement multi selection of items in a recycler view and do whatever you want (delete, share, copy etc) with the selected items . Aim: To demystify multiple item …
Read More »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
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: Open & Abstract Classes and Inheritance
In object-oriented programming, inheritance enables new objects to take on the properties of existing objects. We can have a class that can inherit properties and methods from the parent class when we inherit classes, we do not need to specify the method and properties again, in the new class (child class or subclass). In …
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: Function or Methods Example
Simple Function. neither accepts nor return any variable or value fun helloWorld(){ println("Hello World") } Function that takes a parameter but returns no value fun stringFunction (text : String){ for (c in text){ println("$c ") //KOTLIN -> K O T L I N } } fun intFunction(int : Integer){ println(int) …
Read More »Kotlin: Break and Continue Statements
Break and Continue Statements allow us to define jumps in our code and they are used inside Loops breakstatement allow us to jump to the end of the loop and halt any further iterations. This is useful whenever we are interested in the first occurrence of something. val string = …
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 »Kotlin: Array vs List – Similarities and Differences
// Initializing array and list val array = arrayOf(1, 2, 3) val list = listOf("apple", "ball", "cow") val mixedArray = arrayOf(true, 2.5, 1, 1.3f, 12000L, 'a') // mixed Array val mixedList = listOf(false, 3.5, 2, 1.4f, 13000L, 'b') // mixed List Arrays An array is a container object that holds …
Read More »