Populating a list with a custom format is quite tiring when we do it the usual way in Android.
Note: This is just a quick comparison and discussion on how Jetpack Compose made our lives easier.
For example, we need to create a custom list like this in a usual way.
PS: The actual app is not laggy. I just converted the video to gif and reduce frames and size.
Step 1: We need to create an XML file for the card design item_character
:
Step 2: Add the Recycler View to the main XML file:
Step 3…
Let’s talk about a class first.
In Kotlin, all classes are final and public in nature.
Error in Line 5 because you cannot extend the class Shape
because it is final by default.
What you can do is add open
before the class
keyword to make it inheritable. You can also add the open
keyword before the fun
in declaring a method to override it in the subclass.
But what if you want a single class that can have both optional and required method to override in a class, you can use Abstract
.
What does it mean? For…
An application can have multiple threads, but the most important thread is the UI Thread / the main thread which is created when an application launched.
To simplify, the main thread will be the one who’s responsible for rendering what you see, the user interface, and the possible interaction between the user and the application (onClick, onKeyDown, etc).
But the main thread has its own limit just like your patience.
An interface is like an abstract class, the difference is that an interface cannot store state.
Interface Declaration
interface Cats{
fun doMeow()
}
How to use Interface
interface Cat {
val sound: Sound
fun doMeow() = sound.meow()}
class Siamese: Cat{
override val sound: Sound = Sound()
}
class Persian: Cat{
override val sound: Sound = Sound()
}
class Sound{
fun meow(){
print("Meow meow")
}
}
Note:
Multiple Interfaces in a Class
interface Cat { val sound: Sound var color: String var weight: Double fun doMeow() = sound.meow()…
In Kotlin, classes cannot be inherited, because they are marked as final in default. To make a class inheritable, add the reserved word open
before the word class
.
open class Keyboard{}
Inheritance Declaration
fun main() {
Mechanical()
}
class Mechanical: Keyboard("Mechanical")
open class Keyboard (type: String){
init {
print("Its a $type Keyboard")
}
}---------
OUTPUT:
Its a Mechanical Keyboard
Here we declared an inheritable class Keyboard
with a primary constructor type
then we extend this open class using the :
symbol to the Mechanical
class header so that it can inherit whatever inside theKeyboard
open class.
Overriding Methods and…
Classes can be declared in Kotlin using the word class
followed by its name and body inside curly braces.
class Moominvalley{
//class body
}
A class can have one or more Constructors, it can be declared as a Primary or a Secondary Constructor.
Primary Constructor Declaration
The primary constructor is part of the class header.
class Moominvalley(resident: String){//class body}
Secondary Constructor Declaration
class Moominvalley{
constructor(resident: String, kind: String){
print("Resident Name: $resident Kind: $kind")
}}
Initializer Block
init{}
will be always initialized
fun main() {
Moominvalley("Moominmama","Moomin")
}class Moominvalley(resident: String){ constructor(resident: String, kind: String ): this(resident){ println("Resident Name: $resident Kind…
How to setup Discord to Bitrise to send a custom build message in your server’s channel using webhook.
Bitrise is a Continuous Integration and Delivery (CI/CD) Platform as a Service (PaaS) with a main focus on mobile app development (iOS, Android, React Native, Flutter, and so on). It is a collection of tools and services to help you with the development and automation of your software projects.
— https://www.bitrise.io/
CICD practicies of continuous integration and continuous delivery helps DevOps teams ship higher quality software, faster, for improved software deployment.
— https://about.gitlab.com/blog/2019/06/27/positive-outcomes-ci-cd/
But first, you must set up your project in…
Why CI/CD is important?
Basahin nyo na lang to: https://medium.com/@james.richardson.987123/why-is-ci-cd-important-in-software-development-lifecycle-c75f52cbed83
Note: Kung pagod ka na mag manual build at magsend ng APK sa QA nyong magaling manipat ng mali, ito na ang sagot para sayo.
Rekta na agad!
buid.gradle :app
)develop, test,staging,master/prod
)If you want your utility/helper method to be like one of a property/method of the built-in classes, you can use this hax called extension function.
The typical way of creating a helper:
DateTimeHelper
, added a public method that converts your date and time to duration.DateTimeHelper.dateDuration(myStringDate)
to get the result.Another way to do this using an extension function:
A destructuring declaration creates multiple variables at once.
Here are some examples where you can use destructuring:
i.key i.value
in our loop, we’ve taken an instance and distributed the public member values to specific variables. …
Mobile Developer | Noob