NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

- KTX extensions
- Jetpack Compose
- Jetpack Security
- RecyclerView
- Coroutines







Android KTX Extensions

AndroidKTX is a set of extensions which can harness the power of Kotlin language features for Android App Development. KTX is a part of Jetpack and it is divided into modules. Android KTX has one core module and a few other modules which are more domain-specific.
Android KTX in two parts:
● What kotlin features do these extensions take advantage of?
● Android KTX modules

Kotlin features
● Extension functions
● Extension properties
● Lambdas
● Named parameters
● Parameter default values
● Coroutines

Extension functions
Extension functions — extending pre-defined functions, not inheriting them and adding more functionality to it makes your functions known as an extension function.

Extension properties
Extension properties — Just like extension functions, we have extension properties, data inside a function can be modified and makes it easy to use. The only thing we have to keep in mind while working with extension properties is that it cannot save the state, but will need to use existing functions to request or modify the state of the object. This revokes use of initializers.


Lambdas
Lambdas — no name function, these can be passed as an expression without declaring it.

Named parameters
Named parameters — There are situations when we need to pass lots of arguments to a function. Sometimes, it is possible that we jumble or miss any arguments, and this leads to the error and we had to check the implementation of that function and correct it. With this named parameters now we can pass arguments using the parameters name, no need to pass arguments in the correct order.

Parameter default values
Parameter default values — Sometimes, we had to pass lots of arguments and this eventually increases the development time. Now, with the default values of parameters, we don’t need to pass the argument if the default value satisfies our conditions. We can simply skip the parameters whose default values we want to use.


Coroutines
Coroutines — Working with multiple threads is always hard to manage and increases the development time as well. Either we need to put some delay or make a network connection or a database query, we always need to do work in an asynchronous way. Coroutines simply take our work to another thread and get it done while the user is busy on the main thread either watching an amazing loading animation or interacting with other components.

Android KTX module
● Core KTX
● Collection KTX
● Fragment KTX
● Lifecycle KTX
● LiveData KTX
● Navigation KTX
● Palette KTX
● Reactive Streams KTX
● Shared Preference KTX
● Room KTX
● SQLite KTX
● ViewModel KTX
● WorkManager KTX
● Utils
Jetpack Compose

Android team decided to use a different pattern called Declarative UI pattern. With Declarative UI, developers are declaring what the UI looks like by describing the views and their properties. The UI has a state and each time the state changes, the UI updates and recreates it’s UI elements.
Jetpack Compose is Android’s modern toolkit for building native Android applications. Jetpack Compose simplifies and accelerates UI development on Android. It does more with less code and avoids entire classes of bugs, so code is simple and easy to maintain. Every time the state changes, the UI automatically gets updated.

Jetpack Security
The Security library provides an implementation of the security best practices related to reading and writing data at rest, as well as key creation and verification.
The library uses the builder pattern to provide safe default settings for the following security levels:
● Strong security that balances great encryption and good performance. This level of security is appropriate for consumer apps, such as banking and chat apps, as well as enterprise apps that perform certificate revocation checking.
● Maximum security. This level of security is appropriate for apps that require a hardware-backed keystore and user presence for providing key access.

RecyclerView

● RecyclerView: user interface container in xml layout.
● ItemView: Single item view define in xml layout.
● Data Model: Set Data models in the constructor or a setter method.
● RecyclerView.Adapter: Adapter class creates view holders as needed.
● RecyclerView.ViewHolder: responsible to display single item in list.
● onBindViewHolder(): binds view holders data by assigning view holder position.
● getItemCount(): Tell the Adapter how many items it has at any given time.
● getItemViewType(): Map the data model to the corresponding view.
● onCreateViewHolder(): Based on view type, create the corresponding ViewHolder
Coroutines

Coroutines = Co + Routines
Here, Co means cooperation and Routines means functions.
It means that when functions cooperate with each other, we call it as Coroutines.
A coroutine is a concurrency design pattern that you can use on Android to simplify code that executes asynchronously.
On Android, coroutines help to manage long-running tasks that might otherwise block the main thread and cause your app to become unresponsive.

Coroutines Features
Coroutines are recommended solution for asynchronous programming on Android.
Lightweight: You can run many coroutines on a single thread due to support for suspension, which doesn't block the thread where the coroutine is running. Suspending saves memory over blocking while supporting many concurrent operations.
Fewer memory leaks: Use structured concurrency to run operations within a scope.
Built-in cancellation support: Cancellation is propagated automatically through the running coroutine hierarchy.
Jetpack integration: Many Jetpack libraries include extensions that provide full coroutines support. Some libraries also provide their own coroutine scope that you can use for structured concurrency.


     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.