Kotlin transformation function
In Kotlin, transformation functions are used to convert or modify data in a variety of ways. These functions are typically applied to collections, sequences, or flows, allowing you to perform operations such as mapping, filtering, sorting, and more. Here are some commonly used transformation functions:
map: Transforms each element in a ...
Kotlin Flow Key Operators and Transformations.
In Kotlin, Flow is a type representing a stream of values that are sequentially emitted over time. Flow operators and transformations allow you to perform various operations on flows, such as filtering, transforming, combining, and handling errors. Let’s go through some key operators and transformations with examples:
1.map :
Applies a transfor...
Difference between LiveData, StateFlow, SharedFlow, Flow.
LiveData - Hot Stream
In LiveData, data emissions start as soon as an observer is attached. The data flow continues, and if the observer isn’t actively consuming it, it may miss out on some values. Here’s an example:
Understanding Active and Inactive Observers in LiveData
Active Observer:
An observer is considered active when the associated Li...
Hilt Dependency injection
Hilt is the next generation dependency injection framework from Google. It’s built on top of Dagger and simplifies DI greatly.Hilt provides a standard way
for your application to do DI by providing a container for every Android class in your project and automatically managing its lifecycle. Hilt is built on top
of the well-known DI library Dagg...
Animated-Vector-Drawable-Path-Morphing
Animated-Vector-Drawable-Path-Morphing
Here’s my attempt at gathering all the required information and compressing it to something you can easily understand what is all about Animated vector drawable and how this is helping to animate some of complex animation. The reason I selected this topic is that, Google ...
Spannable Text
Spannable Text
Spans are helpful to style text, it help us to change the color of specific portion of the text, help us to make specific portion to be clickable, resizable , there many other use cases where we make use of the spannable text. Frequently, you come across one common style where you want to change the color of some portion and make ...
Adding environment variables In Unix, Linux
@Adding environment variables In Unix, Linux Environment
In Linux Or Unix environment , All your environment variables are stored in the .bash_profile file which is stored in the root directory. Every time you want to add new environment variable, you will make changes to this file.
Say, you want to add an environment variable for username, you...
ViewModelScope
Why do we need View Model Scope ?
Lets take example of it,
class MainFragment : Fragment() {
fun loadData() = GlobalScope.launch { viewModel.startExecution() }
}
class YourViewModel : ViewModel() {
suspend fun startExecution() {
withContext(Dispatchers.IO) {
for (i in 0..10000000) {
...
Communicate with other fragments
Communicate with other fragments?
All Fragment-to-Fragment communication is done either through a shared ViewModel or through the associated Activity. Two Fragments should never communicate directly, The recommended way to communicate between fragments is to create a shared ViewModel object. Both fragments can access the ViewModel through their ...
Kotlin Scoping function
Kotlin let, run, also, apply, with
Kotlin’s standard library includes some often-used scope functions that are so abstract that even those who have been
programming in Kotlin for a while can have a hard time keeping them straight. In this guide, I am going to clarify four
of these scope functions in particular
Let’s understand each one of th...
18 post articles, 2 pages.