This presentation shows tools and technologies used in Android Development such as Kotlin, Retrofit, and Room. It also shows different architectural patterns such as MVC, MVP, and MVVM
With the announcement on officially supporting Kotlin for Android, this presentation tries to compare Java and Kotlin to encourage people to switch to Kotlin
eMan Dev Meetup: Kotlin - A Language we should know it exists (part 02/03) 18...eMan s.r.o.
This document provides an overview of the Kotlin programming language. It defines Kotlin as a statically typed language that targets the JVM and JavaScript, is 100% interoperable with Java, and was created by JetBrains as a better alternative to Java. The document then covers 10 features of Kotlin, including null safety, data classes, extension functions, smart casts, and support for functional programming patterns. It provides code examples to demonstrate how these features work in Kotlin.
The document introduces the Kotlin programming language developed by JetBrains. It provides an overview of Kotlin's motivation, features, syntax and tooling. Key points include Kotlin being a statically typed JVM language intended for industrial use, its focus on common sense features from other languages, and full interoperability with Java.
Practical tips for building apps with kotlinAdit Lal
This document provides an overview of Kotlin and best practices for building apps with Kotlin. Some key points:
- Kotlin is a statically typed language that runs on the JVM and is fully interoperable with Java. It adds features like null safety, lambdas, and concise syntax.
- Kotlin is perfect for Android development as it is compiled to Java bytecode and has full support for Android APIs. The migration process from Java to Kotlin is gradual.
- Best practices for Kotlin include using features like data classes, when expressions, higher order functions, and Android extensions to write more concise and readable code compared to Java.
Kotlin is a statically typed programming language that runs on the Java Virtual Machine and is fully interoperable with Java. It was developed by JetBrains as an alternative to Java for Android development, with improvements like null safety, lambdas, and concise syntax. Kotlin aims to be a safer language than Java by eliminating NullPointerExceptions and adding features like data classes, extensions, and higher-order functions. These features allow for more readable, concise code compared to Java.
Save time with kotlin in android developmentAdit Lal
Kotlin is a statically typed programming language that is fully interoperable with Java and improves on Java in several ways such as null safety, concise syntax, and functional programming features. The document provides an overview of Kotlin and how it can help improve Android development by reducing code verbosity and allowing for more concise implementations of common patterns compared to Java. It also provides guidance on incrementally migrating existing Java/Android projects to Kotlin.
Android Architecture Components with KotlinAdit Lal
The document discusses the Android Architecture Components including Lifecycle, LiveData, ViewModel, Room, and Paging. Lifecycle allows observing lifecycle states and automatically responding to configuration changes. LiveData allows building data objects that notify views of data changes. ViewModel stores UI-related data to survive configuration changes. Room provides an abstraction layer over SQLite to allow for more robust database access. Paging provides efficient loading of lists and data. The components help create scalable and testable applications by isolating and decoupling concerns.
Say Goodbye To Java: Getting Started With Kotlin For Android DevelopmentAdam Magaña
Kotlin is officially endorsed by Google for Android development but what is all the fuss about? Why should accomplished Java developers care? Here I explore some of the history, fundamentals, and tools that Kotlin provides for Android developers.
With the announcement on officially supporting Kotlin for Android, this presentation tries to compare Java and Kotlin to encourage people to switch to Kotlin
eMan Dev Meetup: Kotlin - A Language we should know it exists (part 02/03) 18...eMan s.r.o.
This document provides an overview of the Kotlin programming language. It defines Kotlin as a statically typed language that targets the JVM and JavaScript, is 100% interoperable with Java, and was created by JetBrains as a better alternative to Java. The document then covers 10 features of Kotlin, including null safety, data classes, extension functions, smart casts, and support for functional programming patterns. It provides code examples to demonstrate how these features work in Kotlin.
The document introduces the Kotlin programming language developed by JetBrains. It provides an overview of Kotlin's motivation, features, syntax and tooling. Key points include Kotlin being a statically typed JVM language intended for industrial use, its focus on common sense features from other languages, and full interoperability with Java.
Practical tips for building apps with kotlinAdit Lal
This document provides an overview of Kotlin and best practices for building apps with Kotlin. Some key points:
- Kotlin is a statically typed language that runs on the JVM and is fully interoperable with Java. It adds features like null safety, lambdas, and concise syntax.
- Kotlin is perfect for Android development as it is compiled to Java bytecode and has full support for Android APIs. The migration process from Java to Kotlin is gradual.
- Best practices for Kotlin include using features like data classes, when expressions, higher order functions, and Android extensions to write more concise and readable code compared to Java.
Kotlin is a statically typed programming language that runs on the Java Virtual Machine and is fully interoperable with Java. It was developed by JetBrains as an alternative to Java for Android development, with improvements like null safety, lambdas, and concise syntax. Kotlin aims to be a safer language than Java by eliminating NullPointerExceptions and adding features like data classes, extensions, and higher-order functions. These features allow for more readable, concise code compared to Java.
Save time with kotlin in android developmentAdit Lal
Kotlin is a statically typed programming language that is fully interoperable with Java and improves on Java in several ways such as null safety, concise syntax, and functional programming features. The document provides an overview of Kotlin and how it can help improve Android development by reducing code verbosity and allowing for more concise implementations of common patterns compared to Java. It also provides guidance on incrementally migrating existing Java/Android projects to Kotlin.
Android Architecture Components with KotlinAdit Lal
The document discusses the Android Architecture Components including Lifecycle, LiveData, ViewModel, Room, and Paging. Lifecycle allows observing lifecycle states and automatically responding to configuration changes. LiveData allows building data objects that notify views of data changes. ViewModel stores UI-related data to survive configuration changes. Room provides an abstraction layer over SQLite to allow for more robust database access. Paging provides efficient loading of lists and data. The components help create scalable and testable applications by isolating and decoupling concerns.
Say Goodbye To Java: Getting Started With Kotlin For Android DevelopmentAdam Magaña
Kotlin is officially endorsed by Google for Android development but what is all the fuss about? Why should accomplished Java developers care? Here I explore some of the history, fundamentals, and tools that Kotlin provides for Android developers.
This document provides an introduction and overview of the Kotlin programming language. It begins with an agenda and quote about Kotlin being a good choice for Spring applications. The remainder of the document covers what Kotlin is, its main features like type inference, functional programming support, interoperability with Java, and language concepts like properties, classes, inheritance, interfaces, functions, collections and more. Code examples are provided to illustrate many of the language features. Resources for learning more about Kotlin are listed at the end.
The document compares the programming languages Swift and Kotlin. It provides background on the speakers and an outline of the topics to be discussed, including brief introductions to Swift and Kotlin, common language features between the two, demonstrations of code samples, and conclusions. IDEs like Xcode, Android Studio, and AppCode will also be demonstrated.
Feel of Kotlin (Berlin JUG 16 Apr 2015)intelliyole
Kotlin is a statically typed programming language that targets the JVM, Android and web. It has been in development since 2010 by JetBrains. Kotlin code is concise, expressive and safe to develop with. It is interoperable with Java code and has equivalent performance, with a smooth learning curve that maintains existing Java investments. JetBrains uses Kotlin in their own products and tools. The document provides examples of Kotlin features like classes, traits, null safety, extension functions, operator overloading, and HTML builders.
The document outlines an agenda for a workshop on developing a weather app with Kotlin. The schedule includes introductions to Kotlin, a project presentation and setup, and two hands-on sessions. There will be a coffee break in between the introductory and hands-on portions. Attendees will learn about Kotlin features like type inference, null safety, collections, and Android extensions and apply them by developing the weather app.
Kotlin is a better alternative to Java that fixes many of Java's weaknesses. It removes unnecessary syntax like semicolons and checked exceptions, adds powerful features like type inference, lambdas, and when expressions, and compiles to JVM bytecode so it can interoperate with existing Java code and libraries. Kotlin is fully supported by JetBrains and can also target JavaScript, making it a practical and modern option for JVM development.
The Jetbrain's Kotlin language cheat sheet, created by ekito and launched for the Toulouse's devfest - https://www.ekito.fr/people/kotlin-cheat-sheet/
This paper helps you keep the main feature of the Kotlin language, under the hand. Just download it & print it !
I used these slides to present the benefits of using Kotlin to a group of people I work with. The presentation focuses on comparing Kotlin to Java, and in particular showing how Kotlin can help in writing safer, more concise and readable code. I used a few java gotchas/puzzles to demonstrate how Kotlin may prevent us from doing silly things.
The document discusses how OCL (Object Constraint Language) is integrated with and used for code generation in Eclipse. It covers how OCL delegates are generated for EMF models, how OCL expressions can be loaded and used in Xtext editors, and how OCL is integrated with UML and Papyrus modeling tools for validation and code generation purposes including generating Java code from UML models with OCL constraints. It notes that OCL is increasingly useful with IDE tools and model-driven code generation capabilities.
From object oriented to functional domain modelingCodemotion
"From object oriented to functional domain modeling" by Mario Fusco
Malgrado l'introduzione delle lambda, la gran parte degli sviluppatori Java non è ancora abituata agli idiomi della programmazione funzionale e quindi non è pronta a sfruttare a pieno le potenzialità di Java 8. In particolare non è ancora comune vedere dati e funzioni usate insieme quando si modella un dominio di business. Lo scopo del talk è mostrare come alcuni principi di programmazione funzionale quali l'impiego di oggetti e strutture dati immutabili, l'uso di funzioni senza side-effect e il loro reuso mediante composizione, possono anche essere validi strumenti di domain modelling.
- Eclipse OCL was originally Java-based using runtime parsing and interpretation, but is moving to using model-to-text generation to directly generate Java code for improved performance.
- The new Eclipse OCL architecture in Juno uses the Xtext editor to embed OCL text and the Pivot model to represent OCL at runtime, generating Java code via Acceleo templates rather than interpreting OCL.
- OCL is an executable constraint language standardized by OMG, while Xbase is a Java-like implementation language supported by Eclipse; both are almost useless without being embedded in a modeling context.
Kotlin advanced - language reference for android developersBartosz Kosarzycki
StxNext Lightning Talks - Mar 11, 2016
Kotlin Advanced - language reference for Android developers
This presentation contains the second talk on Kotlin language we had at STXNext. We try go deeper into language specifics and look at the positive impact new syntax can have on boilerplate removal and readability improvement.
Kotlin really shines in Android development when one looks at “Enum translation”, “Extension functions”, “SAM conversions”, “Infix notation”, “Closures” and “Fluent interfaces” applied to lists. The talk, however, compares language-specifics of Java & Kotlin in terms of “Type Variance”, “Generics” and “IDE tools” as well.
We present real-world example based on Stx-Insider project written in Kotlin which incorporates Dagger 2, Kotterknife, Retrofit2 and is composed of 5+ Activities.
Full agenda
Live templates
Enum translation
Calling extension functions from Kotlin/Java
Constructors with backing fields
Warnings
F-bound polymorphism
Variance (Covariance/Contravariance)
Variance comparison in Kotlin/Java/Scala
Annotation processing - KAPT
SAM conversions
Type equality
Lambda vs Closure
Reified generics
Fluent interfaces
Infix notation
Static extension methods in Kotlin
Generic types
Sealed classes
Dokka - documentation in Kotlin
J2K converter
Real-world example
Reflection
Presentation is accompanied with an example project (StxInsider):
https://github.com/kosiara/stx-insider
Kotlin is a statically typed language for the JVM, Android, and browser that was created by JetBrains in response to limitations in Java. It focuses on interoperability with Java code and libraries. Kotlin allows avoiding null pointer exceptions, supports functional and procedural programming, and concise code. It is the official language for Android app development. The document discusses Kotlin basics like variables, strings, functions, classes, data classes, and control flows and how to configure Kotlin in Android Studio projects.
Develop your next app with kotlin @ AndroidMakersFr 2017Arnaud Giuliani
Kotlin is a fully interoperable programming language for building Android and multiplatform applications. It is statically typed, concise, and designed to interoperate seamlessly with Java. Kotlin aims to combine the best of both object-oriented and functional programming, and provides features to write safer and more concise code compared to Java, such as null safety, type inference, and extension functions. The document provides an overview of Kotlin's features and how it compares to other languages like Java and Swift, and demonstrates how to set up a Kotlin project using Gradle build system.
Kotlin is a JVM language developed by Jetbrains. Its version 1.0 (production ready) was released at the beginning of the year and made some buzz within the android community. This session proposes to discover this language, which takes up some aspects of groovy or scala, and that is very close to swift in syntax and concepts. We will see how Kotlin boosts the productivity of Java & Android application development and how well it accompanies reactive development.
"JavaScript in 2016" by Eduard Tomàs
Some years ago in a far far away company, Brendan Eich created JavaScript. A lot of things happened since then. Times changed, the web grown, the language itself was updated, and we as a developers need to adapt too. Last year the last standard of the language arose: ECMAScript 2015 is here, and has some new and interesting features. In this talk we will show the most relevant ones, and also we will introduce some interesting patterns that you can use in JavaScript: you'll learn how to master the language and made JavaScript your best ally to conquest the world!
Introduction to kotlin for android app development gdg ahmedabad dev fest 2017Hardik Trivedi
The presentation was given in Ahmedabad GDG DevFest 2017. It has introduction to Kotlin for Android App Development.
Talk will is specially designed for beginners, who has heard about Kotlin but couldn’t explore it till date. The talk will take attendees to the journey where they can know Kotlin as a programming language. What Kotlin offers for Android? How to start the development using Kotlin, Features of Kotlin, Some of the disadvantages of Kotlin.
I will be discussing about following topics
- What’s Kotlin
- Why Kotlin
- Setting up Kotlin
- Features of Kotlin
- Syntax crash course
- Classes
- Features of function programming like Lamdabs and Higher order functions
- Usage of Anko
- Migrating from Java project to Kotlin
- Future of Kotlin
- Disadvantages of Kotlin
This document compares the Kotlin and Swift programming languages. It provides an overview of key features of each language such as variables, functions, classes, inheritance, protocols/traits, enums, null safety, type checks and extensions. It also includes code examples to illustrate similarities and differences between the two languages. The document concludes with a comparison of other features and a diagram showing how each language fits into a typical mobile application architecture.
Next Insurance was founded in the beginning of 2016 and first lines of our production code started accumulating in May 2016. In the beginning I have started writing in Java and experimenting with Kotlin, which saw its 1.0 release two months earlier. 6 months later, the development of our backend services has totally shifted to Kotlin. We still keep a few classes in Java just to make sure that the integration remains seamless but the vast majority of our codebase is written in Kotlin. In this talk I will cover the language features and why I think it is awesome, from null safety to smart casts and data classes. We will also look into the future with 1.1 async/await feature and more.
Kotlin provides a lot of features out of the box even though those are not supported by JVM. Have you ever wondered how Kotlin does it? If yes, then this presentation is for you.
Kotlin compiler tweaks our code in such a way that, JVM can execute it. this deck goes through lots of Kotlin features and explains how it looks at runtime for JVM compatibility. Of course we are not going to look into bytecode, instead we will look into the decompiled version of the bytecode generated by Kotlin compiler.
NOTE: This was presented at DevFest Kolkata 2019.
While Google is adding Kotlin as an official Android language, we're also expanding our research on this language. It’s developed by JetBrains, and the fact that these are the people behind a suite of IDEs, such as IntelliJ and ReSharper, really shines through in Kotlin. It’s pragmatic and concise and makes coding a satisfying and efficient experience.
Although Kotlin compiles to both JavaScript and soon machine code, I’ll focus on its prime environment, the JVM.
Please see my presentation to learn more!
This document provides an introduction and overview of the Kotlin programming language. It begins with an agenda and quote about Kotlin being a good choice for Spring applications. The remainder of the document covers what Kotlin is, its main features like type inference, functional programming support, interoperability with Java, and language concepts like properties, classes, inheritance, interfaces, functions, collections and more. Code examples are provided to illustrate many of the language features. Resources for learning more about Kotlin are listed at the end.
The document compares the programming languages Swift and Kotlin. It provides background on the speakers and an outline of the topics to be discussed, including brief introductions to Swift and Kotlin, common language features between the two, demonstrations of code samples, and conclusions. IDEs like Xcode, Android Studio, and AppCode will also be demonstrated.
Feel of Kotlin (Berlin JUG 16 Apr 2015)intelliyole
Kotlin is a statically typed programming language that targets the JVM, Android and web. It has been in development since 2010 by JetBrains. Kotlin code is concise, expressive and safe to develop with. It is interoperable with Java code and has equivalent performance, with a smooth learning curve that maintains existing Java investments. JetBrains uses Kotlin in their own products and tools. The document provides examples of Kotlin features like classes, traits, null safety, extension functions, operator overloading, and HTML builders.
The document outlines an agenda for a workshop on developing a weather app with Kotlin. The schedule includes introductions to Kotlin, a project presentation and setup, and two hands-on sessions. There will be a coffee break in between the introductory and hands-on portions. Attendees will learn about Kotlin features like type inference, null safety, collections, and Android extensions and apply them by developing the weather app.
Kotlin is a better alternative to Java that fixes many of Java's weaknesses. It removes unnecessary syntax like semicolons and checked exceptions, adds powerful features like type inference, lambdas, and when expressions, and compiles to JVM bytecode so it can interoperate with existing Java code and libraries. Kotlin is fully supported by JetBrains and can also target JavaScript, making it a practical and modern option for JVM development.
The Jetbrain's Kotlin language cheat sheet, created by ekito and launched for the Toulouse's devfest - https://www.ekito.fr/people/kotlin-cheat-sheet/
This paper helps you keep the main feature of the Kotlin language, under the hand. Just download it & print it !
I used these slides to present the benefits of using Kotlin to a group of people I work with. The presentation focuses on comparing Kotlin to Java, and in particular showing how Kotlin can help in writing safer, more concise and readable code. I used a few java gotchas/puzzles to demonstrate how Kotlin may prevent us from doing silly things.
The document discusses how OCL (Object Constraint Language) is integrated with and used for code generation in Eclipse. It covers how OCL delegates are generated for EMF models, how OCL expressions can be loaded and used in Xtext editors, and how OCL is integrated with UML and Papyrus modeling tools for validation and code generation purposes including generating Java code from UML models with OCL constraints. It notes that OCL is increasingly useful with IDE tools and model-driven code generation capabilities.
From object oriented to functional domain modelingCodemotion
"From object oriented to functional domain modeling" by Mario Fusco
Malgrado l'introduzione delle lambda, la gran parte degli sviluppatori Java non è ancora abituata agli idiomi della programmazione funzionale e quindi non è pronta a sfruttare a pieno le potenzialità di Java 8. In particolare non è ancora comune vedere dati e funzioni usate insieme quando si modella un dominio di business. Lo scopo del talk è mostrare come alcuni principi di programmazione funzionale quali l'impiego di oggetti e strutture dati immutabili, l'uso di funzioni senza side-effect e il loro reuso mediante composizione, possono anche essere validi strumenti di domain modelling.
- Eclipse OCL was originally Java-based using runtime parsing and interpretation, but is moving to using model-to-text generation to directly generate Java code for improved performance.
- The new Eclipse OCL architecture in Juno uses the Xtext editor to embed OCL text and the Pivot model to represent OCL at runtime, generating Java code via Acceleo templates rather than interpreting OCL.
- OCL is an executable constraint language standardized by OMG, while Xbase is a Java-like implementation language supported by Eclipse; both are almost useless without being embedded in a modeling context.
Kotlin advanced - language reference for android developersBartosz Kosarzycki
StxNext Lightning Talks - Mar 11, 2016
Kotlin Advanced - language reference for Android developers
This presentation contains the second talk on Kotlin language we had at STXNext. We try go deeper into language specifics and look at the positive impact new syntax can have on boilerplate removal and readability improvement.
Kotlin really shines in Android development when one looks at “Enum translation”, “Extension functions”, “SAM conversions”, “Infix notation”, “Closures” and “Fluent interfaces” applied to lists. The talk, however, compares language-specifics of Java & Kotlin in terms of “Type Variance”, “Generics” and “IDE tools” as well.
We present real-world example based on Stx-Insider project written in Kotlin which incorporates Dagger 2, Kotterknife, Retrofit2 and is composed of 5+ Activities.
Full agenda
Live templates
Enum translation
Calling extension functions from Kotlin/Java
Constructors with backing fields
Warnings
F-bound polymorphism
Variance (Covariance/Contravariance)
Variance comparison in Kotlin/Java/Scala
Annotation processing - KAPT
SAM conversions
Type equality
Lambda vs Closure
Reified generics
Fluent interfaces
Infix notation
Static extension methods in Kotlin
Generic types
Sealed classes
Dokka - documentation in Kotlin
J2K converter
Real-world example
Reflection
Presentation is accompanied with an example project (StxInsider):
https://github.com/kosiara/stx-insider
Kotlin is a statically typed language for the JVM, Android, and browser that was created by JetBrains in response to limitations in Java. It focuses on interoperability with Java code and libraries. Kotlin allows avoiding null pointer exceptions, supports functional and procedural programming, and concise code. It is the official language for Android app development. The document discusses Kotlin basics like variables, strings, functions, classes, data classes, and control flows and how to configure Kotlin in Android Studio projects.
Develop your next app with kotlin @ AndroidMakersFr 2017Arnaud Giuliani
Kotlin is a fully interoperable programming language for building Android and multiplatform applications. It is statically typed, concise, and designed to interoperate seamlessly with Java. Kotlin aims to combine the best of both object-oriented and functional programming, and provides features to write safer and more concise code compared to Java, such as null safety, type inference, and extension functions. The document provides an overview of Kotlin's features and how it compares to other languages like Java and Swift, and demonstrates how to set up a Kotlin project using Gradle build system.
Kotlin is a JVM language developed by Jetbrains. Its version 1.0 (production ready) was released at the beginning of the year and made some buzz within the android community. This session proposes to discover this language, which takes up some aspects of groovy or scala, and that is very close to swift in syntax and concepts. We will see how Kotlin boosts the productivity of Java & Android application development and how well it accompanies reactive development.
"JavaScript in 2016" by Eduard Tomàs
Some years ago in a far far away company, Brendan Eich created JavaScript. A lot of things happened since then. Times changed, the web grown, the language itself was updated, and we as a developers need to adapt too. Last year the last standard of the language arose: ECMAScript 2015 is here, and has some new and interesting features. In this talk we will show the most relevant ones, and also we will introduce some interesting patterns that you can use in JavaScript: you'll learn how to master the language and made JavaScript your best ally to conquest the world!
Introduction to kotlin for android app development gdg ahmedabad dev fest 2017Hardik Trivedi
The presentation was given in Ahmedabad GDG DevFest 2017. It has introduction to Kotlin for Android App Development.
Talk will is specially designed for beginners, who has heard about Kotlin but couldn’t explore it till date. The talk will take attendees to the journey where they can know Kotlin as a programming language. What Kotlin offers for Android? How to start the development using Kotlin, Features of Kotlin, Some of the disadvantages of Kotlin.
I will be discussing about following topics
- What’s Kotlin
- Why Kotlin
- Setting up Kotlin
- Features of Kotlin
- Syntax crash course
- Classes
- Features of function programming like Lamdabs and Higher order functions
- Usage of Anko
- Migrating from Java project to Kotlin
- Future of Kotlin
- Disadvantages of Kotlin
This document compares the Kotlin and Swift programming languages. It provides an overview of key features of each language such as variables, functions, classes, inheritance, protocols/traits, enums, null safety, type checks and extensions. It also includes code examples to illustrate similarities and differences between the two languages. The document concludes with a comparison of other features and a diagram showing how each language fits into a typical mobile application architecture.
Next Insurance was founded in the beginning of 2016 and first lines of our production code started accumulating in May 2016. In the beginning I have started writing in Java and experimenting with Kotlin, which saw its 1.0 release two months earlier. 6 months later, the development of our backend services has totally shifted to Kotlin. We still keep a few classes in Java just to make sure that the integration remains seamless but the vast majority of our codebase is written in Kotlin. In this talk I will cover the language features and why I think it is awesome, from null safety to smart casts and data classes. We will also look into the future with 1.1 async/await feature and more.
Kotlin provides a lot of features out of the box even though those are not supported by JVM. Have you ever wondered how Kotlin does it? If yes, then this presentation is for you.
Kotlin compiler tweaks our code in such a way that, JVM can execute it. this deck goes through lots of Kotlin features and explains how it looks at runtime for JVM compatibility. Of course we are not going to look into bytecode, instead we will look into the decompiled version of the bytecode generated by Kotlin compiler.
NOTE: This was presented at DevFest Kolkata 2019.
While Google is adding Kotlin as an official Android language, we're also expanding our research on this language. It’s developed by JetBrains, and the fact that these are the people behind a suite of IDEs, such as IntelliJ and ReSharper, really shines through in Kotlin. It’s pragmatic and concise and makes coding a satisfying and efficient experience.
Although Kotlin compiles to both JavaScript and soon machine code, I’ll focus on its prime environment, the JVM.
Please see my presentation to learn more!
The document discusses operator overloading in Kotlin using the example of a Coin enum and Wallet class. It defines a Coin enum with values for common coins (PENNY, NICKEL, etc) that each have a cents value. A Wallet class is defined with a plusAssign operator function that allows adding Coin values to the wallet amount. Examples are shown incrementing a wallet variable by adding Coin values like QUARTER to demonstrate operator overloading.
droidcon Transylvania - Kotlin CoroutinesArthur Nagy
We face challenges with threading on a daily basis. There are too many ways to do it, too many options. Do I use an AsyncTaks, a Runnable or RxJava, what do I do? All these available APIs lead to an almost inevitable callback hell.
This talk will introduce Kotlin Coroutines as an alternative solution to this problem. We’re going to explore simple ways to perform long-running tasks and computation heavy operations in an asynchronous way, without freezing or crashing your app, while keeping the code clean and readable at the same time.
The document provides code examples comparing Java and Kotlin implementations of common programming concepts and patterns. It shows how Kotlin simplifies concepts like listeners, constructors, properties, and null safety checks compared to Java.
SpringOne Platform 2017
Sébastien Deleuze, Pivotal
"In this new talk, I will explain why Spring <3 Kotlin and how you can leverage Spring official support for Kotlin (in Framework, Boot, Data) to build your next Spring project more efficiently and with more pleasure.
I will describe gradually how you can transform your Spring Boot 1.0 Java + Javascript project with into a Spring Boot 2.0 pure Kotlin project running on top of the new WebFlux functional web framework."
This document discusses how Kotlin can help improve Android app quality by eliminating common issues like crashes and null pointer exceptions. It highlights Kotlin features like non-nullable types, the safe call operator, and extension functions. Kotlin offers improvements over Java like optional and collection APIs without nullability and verbosity issues. It also maintains full interoperability with Java while providing better tools for static analysis and debugging.
Kotlin for Android - Vali Iorgu - mRreadyMobileAcademy
Kotlin is a programming language that runs on the Java Virtual Machine and is fully interoperable with Java. It aims to combine object-oriented and functional programming features and to improve developer productivity. Some key features of Kotlin include null safety, extension functions, inline functions and lambdas, and support for coroutines. It provides painless Java interoperability so existing Java code and libraries can be used from Kotlin.
Slides from a talk and live-coding session about Koin, a pragmatic and lightweight Dependency Injection framework for Kotlin. This talk was given at Auckland Android Community on Dec 5.
https://www.meetup.com/Android-Meetup/events/256734688/
An introduction to Kotlin for advanced Android beginners, covering command-line compilation of Kotlin files, conditional logic, val/var, basic functions, higher order functions, recursion.
Introduction to Koltin for Android Part I Atif AbbAsi
Welcome to Android Basics in Kotlin! In this course, you'll learn the basics of building Android apps with the Kotlin programming language. Along the way, you'll develop a collection of apps to start your journey as an Android developer.
Google is adding Kotlin as an official programming language for Android development. Kotlin is a language that runs on the JVM and has full interoperability with Java. It costs nothing to adopt! I will show some cool features of Kotlin, how it makes developing with Android easy and finally we'll see what happens under the hood when we write in Kotlin.
Kotlin was created by JetBrains to improve developer productivity and enjoyment when building tools like IntelliJ IDEA. Some key features of Kotlin include properties, smart casts, extension functions, and null safety. Kotlin works well for server-side development using frameworks like Kara and Exposed, as well as Android development using Android Extensions and Anko. To succeed with Kotlin, developers should take initiative by starting with tests and utilities in existing Java projects rather than waiting for new projects.
Kotlin what_you_need_to_know-converted event 4 with nigeriansjunaidhasan17
Kotlin is a cross-platform, statically typed programming language that runs on the JVM and JavaScript. It was developed by JetBrains as a pragmatic language for building production-grade applications. Kotlin is fully interoperable with Java and has many features that improve code safety, brevity, and readability compared to Java, like null safety, data classes, string templates, and extension functions. Popular companies like Google, Pinterest, and Square use Kotlin for Android development due to its interoperability with Java and improvements over Java.
This document provides an overview of Android and Kotlin for mobile app development. It discusses Android versions and history starting from 2008. It also covers Kotlin as a modern programming language that is fully compatible with Java and highly integrated with Android. The document demonstrates basic Kotlin syntax and concepts. It provides examples of how to write Android apps using Java or Kotlin in Android Studio, including activities, layouts, intents, and the recycler view. It also briefly introduces architectural concepts like MVVM and libraries like Retrofit for network requests.
Rapid Web API development with Kotlin and KtorTrayan Iliev
Introduction to Kotlin and Ktor with flow, async and channel examples. Ktor is an async web framework with minimal ceremony that leverages the advantages of Kotlin like coroutines and extensible functional DSLs..
Android & Kotlin - The code awakens #02Omar Miatello
This document provides an overview of key Kotlin concepts compared to Java, including:
- Null safety in Kotlin prevents null reference exceptions at compile time by distinguishing nullable and non-nullable types.
- The Elvis operator (?:) provides a shorthand for checking for null values and returning a default.
- Smart casts allow the compiler to infer the type of a variable after checking its type against an if or when condition without needing an explicit cast.
- Kotlin collections APIs provide concise ways to filter, map, sort and iterate over collections compared to Java by leveraging functions like filterNotNull(), sortedBy(), map(), forEach().
The document demonstrates these Kotlin features through code examples
From Java to Kotlin - The first month in practiceStefanTomm
The document discusses converting a Spring Boot application from Java to Kotlin. It highlights several benefits of Kotlin, such as null safety, data classes, higher-order functions, and concise APIs. It then demonstrates converting a sample Spring Boot app to Kotlin through a live coding demo. The demo shows reductions in lines of code and other optimizations in the Kotlin version. Overall, the document introduces Kotlin and illustrates how it can be used to build Spring Boot applications in a more expressive and concise way compared to Java.
Kotlin: forse è la volta buona (Trento)Davide Cerbo
Kotlin: perhaps this time is the right time
This document summarizes a presentation given at the Jug Day event in Trento, Italy on May 19, 2018. The presenter, Davide Cerbo, has over 10 years of experience in full-stack development. He discusses the history of Java and how Kotlin has evolved to address issues with Java, such as backward compatibility. Kotlin integrates seamlessly with Java at the source code level and reduces lines of code by about 40% compared to Java. It is considered a safer alternative to Java that is also easy to learn for Java developers.
Everything You Need to Know About X-Sign: The eSign Functionality of XfilesPr...XfilesPro
Wondering how X-Sign gained popularity in a quick time span? This eSign functionality of XfilesPro DocuPrime has many advancements to offer for Salesforce users. Explore them now!
UI5con 2024 - Bring Your Own Design SystemPeter Muessig
How do you combine the OpenUI5/SAPUI5 programming model with a design system that makes its controls available as Web Components? Since OpenUI5/SAPUI5 1.120, the framework supports the integration of any Web Components. This makes it possible, for example, to natively embed own Web Components of your design system which are created with Stencil. The integration embeds the Web Components in a way that they can be used naturally in XMLViews, like with standard UI5 controls, and can be bound with data binding. Learn how you can also make use of the Web Components base class in OpenUI5/SAPUI5 to also integrate your Web Components and get inspired by the solution to generate a custom UI5 library providing the Web Components control wrappers for the native ones.
E-commerce Development Services- Hornet DynamicsHornet Dynamics
For any business hoping to succeed in the digital age, having a strong online presence is crucial. We offer Ecommerce Development Services that are customized according to your business requirements and client preferences, enabling you to create a dynamic, safe, and user-friendly online store.
Unveiling the Advantages of Agile Software Development.pdfbrainerhub1
Learn about Agile Software Development's advantages. Simplify your workflow to spur quicker innovation. Jump right in! We have also discussed the advantages.
Preparing Non - Technical Founders for Engaging a Tech AgencyISH Technologies
Preparing non-technical founders before engaging a tech agency is crucial for the success of their projects. It starts with clearly defining their vision and goals, conducting thorough market research, and gaining a basic understanding of relevant technologies. Setting realistic expectations and preparing a detailed project brief are essential steps. Founders should select a tech agency with a proven track record and establish clear communication channels. Additionally, addressing legal and contractual considerations and planning for post-launch support are vital to ensure a smooth and successful collaboration. This preparation empowers non-technical founders to effectively communicate their needs and work seamlessly with their chosen tech agency.Visit our site to get more details about this. Contact us today www.ishtechnologies.com.au
Using Query Store in Azure PostgreSQL to Understand Query PerformanceGrant Fritchey
Microsoft has added an excellent new extension in PostgreSQL on their Azure Platform. This session, presented at Posette 2024, covers what Query Store is and the types of information you can get out of it.
Mobile App Development Company In Noida | Drona InfotechDrona Infotech
Drona Infotech is a premier mobile app development company in Noida, providing cutting-edge solutions for businesses.
Visit Us For : https://www.dronainfotech.com/mobile-application-development/
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemPeter Muessig
Learn about the latest innovations in and around OpenUI5/SAPUI5: UI5 Tooling, UI5 linter, UI5 Web Components, Web Components Integration, UI5 2.x, UI5 GenAI.
Recording:
https://www.youtube.com/live/MSdGLG2zLy8?si=INxBHTqkwHhxV5Ta&t=0
Artificia Intellicence and XPath Extension FunctionsOctavian Nadolu
The purpose of this presentation is to provide an overview of how you can use AI from XSLT, XQuery, Schematron, or XML Refactoring operations, the potential benefits of using AI, and some of the challenges we face.
Microservice Teams - How the cloud changes the way we workSven Peters
A lot of technical challenges and complexity come with building a cloud-native and distributed architecture. The way we develop backend software has fundamentally changed in the last ten years. Managing a microservices architecture demands a lot of us to ensure observability and operational resiliency. But did you also change the way you run your development teams?
Sven will talk about Atlassian’s journey from a monolith to a multi-tenanted architecture and how it affected the way the engineering teams work. You will learn how we shifted to service ownership, moved to more autonomous teams (and its challenges), and established platform and enablement teams.
Top Benefits of Using Salesforce Healthcare CRM for Patient Management.pdfVALiNTRY360
Salesforce Healthcare CRM, implemented by VALiNTRY360, revolutionizes patient management by enhancing patient engagement, streamlining administrative processes, and improving care coordination. Its advanced analytics, robust security, and seamless integration with telehealth services ensure that healthcare providers can deliver personalized, efficient, and secure patient care. By automating routine tasks and providing actionable insights, Salesforce Healthcare CRM enables healthcare providers to focus on delivering high-quality care, leading to better patient outcomes and higher satisfaction. VALiNTRY360's expertise ensures a tailored solution that meets the unique needs of any healthcare practice, from small clinics to large hospital systems.
For more info visit us https://valintry360.com/solutions/health-life-sciences
Liberarsi dai framework con i Web Component.pptxMassimo Artizzu
In Italian
Presentazione sulle feature e l'utilizzo dei Web Component nell sviluppo di pagine e applicazioni web. Racconto delle ragioni storiche dell'avvento dei Web Component. Evidenziazione dei vantaggi e delle sfide poste, indicazione delle best practices, con particolare accento sulla possibilità di usare web component per facilitare la migrazione delle proprie applicazioni verso nuovi stack tecnologici.
9. Setting up Kotlin for Android
1. Install the Kotlin Plugin
in Android Studio (If
Android Studio version <
3.0)
1. Add Kotlin classpath to
Project build.gradle
1. Add Kotlin Library and
Apply Kotlin Plugins in
App build.gradle
10. Kotlin Java
Basic Syntax - Variables
var hello = "Hello"
var world: String = "World"
val helloWorld = "Hello World!"
String hello = "Hello";
String world = "World";
final String helloWorld
= "Hello World!";
11. Kotlin Java
Basic Syntax - Comments
// This is a comment
/*
* This is also a comment
*/
// This is a comment
/*
* This is also a comment
*/
12. Kotlin Java
Basic Syntax - If-else
if (a > b) {
println("a")
} else if (b > a) {
println("b")
} else println("c")
if (a > b) {
System.out.println("a");
} else if (b > a) {
System.out.println("b");
} else println("c")
14. Kotlin Java
Basic Syntax - For Loops
for(x in 1..10){
// ...
}
for(item in items){
// ...
}
for(x in 10 downTo 0){
// ...
}
for((key, value) in map){
// ...
for(int i = 0; i < list.length; i++){
// ...
}
for(Object i : list){
// ...
}
for(Entry i : map){
String key = i.key;
String value = i.value;
// ...
}
15. Kotlin Java
Basic Syntax - While Loops
while(it.hasNext()){
println(it)
}
do{
// This
} while (condition)
while(it.hasNext()){
System.out.println(it);
}
do{
// This
} while (condition);
16. Kotlin Java
Basic Syntax - Functions
fun main(args: Array<String>){
}
fun getInt(): Int{
}
public static void main(String[] args){
}
int getInt(){
}
17. Kotlin Java
Basic Syntax - Classes
class Class(val name: String) public class Class{
String name;
public Class(String name){
this.name = name;
}
}
18. Kotlin Java
Kotlin Features - Data Classes
data class Model(var property: Object) class Model {
Object property;
Model(Object property){
this.property = property;
}
void setProperty(Object property) {
this.property = property;
}
Object getProperty() {
return property;
}
}
19. Kotlin Java
Kotlin Features - Objects
object Singleton {
var property
}
var property: Object = Singleton.property
class Singleton {
public Object property;
private static Singleton INSTANCE;
public static Singleton getInstance(){
if(INSTANCE == null) {
INSTANCE = new Singleton();
}
return INSTANCE;
}
}
Object property =
Singleton.getInstance().property;
20. Kotlin Java
Kotlin Features - Objects
var anonymousClass = object {
var x = 5
var y = 5
}
val num = anonymousClass.x
class NotAnonymousClass {
private int x = 5;
private int y = 5;
}
NotAnonymousClass obj =
new NotAnonymousClass();
int x = obj.x;
int y = obj.y;
21. Kotlin Features - Objects
class ClassWithSingleton {
object Singleton {
var property
}
}
val property =
ClassWithSingleton.Singleton.property
class ClassWithSingleton {
companion object {
var property
}
}
val property = ClassWithSingleton.property
22. Kotlin Java
Kotlin Features - Automatic Getters/Setters
class Model(var property: Object)
val model = Model()
model.property = "An Object"
val property = model.property
class Model {
private Object property;
Object getProperty() {
return property;
}
void setProperty(Object property) {
this.property = property;
}
}
Model model = new Model();
model.setProperty("An Object");
Object property = model.getProperty();
24. Kotlin Java
Kotlin Features - Null Safety
var nullable: String?
fun main(args: Array<String>) {
var length = nullable?.length
var forceLength = nullable!!.length
length = nullable.length ?: 0
}
String nullable;
public static void main(String[] args){
int length;
if(nullable != null) {
length = nullable.length();
}
length = nullable != null ?
nullable.length() : 0;
}
25. Kotlin Features - lateinit
var lateString: String = null //Error
fun main(args: Array<String>) {
lateString = "Hello!"
}
lateinit var lateString: String
fun main(args: Array<String>) {
lateString = "Hello!"
}
26. Kotlin Features - lazy loading
var lateString: String = null //Error
fun main(args: Array<String>) {
lateString = "Hello!"
}
val lateString: String by lazy { "Hello!" }
27. Kotlin Features - lazy loading
val greeting: String = null //Error
fun main(args: Array<String>) {
val name = "Kurt"
greeting = "Hello " + name + "!"
}
val greeting: String by lazy {
val name = "Kurt"
"Hello " + name + "!"
}
28. Kotlin Features - String Interpolation
val greeting: String = null //Error
fun main(args: Array<String>) {
val name = "Kurt"
greeting = "Hello $name!"
}
val greeting: String by lazy {
val name = "Kurt"
"Hello $name!"
}
29. Kotlin Features - Named Parameters
fun something(a: Boolean, b: Boolean, c: Boolean, d: Boolean){
return true
}
something(
a = true,
b = true,
c = true,
d = true
)
something(
d = true,
c = true,
b = true,
a = true
)
30. Kotlin Java
Kotlin Features - Default Parameters
fun something(
a: Boolean,
b: Boolean,
c: Boolean = false,
d: Boolean = true
){
return true
}
something(
a = true,
b = true,
)
something(
a = true,
b = true,
c = true
)
Boolean something(Boolean a, Boolean b,
Boolean c, Boolean d) {
return true;
}
Boolean something(Boolean a, Boolean b) {
return something(a, b, false, true);
}
Boolean something(Boolean a, Boolean b,
Boolean c) {
return something(a, b, c, true);
}
something(true, true);
31. Kotlin Java
Kotlin Features - Extension Functions
fun Int.percent(percentage: Int): Int {
return this * (percentage / 100);
}
val num = 100;
num.percent(5)
class IntUtil {
int percent(int value, int percentage) {
return value * (percentage / 100);
}
}
int num = 100;
IntUtil util = new IntUtil();
util.percent(num, 5);
32. Kotlin Java
Kotlin Features - Infix Functions
Infix fun Int.percentOf(value: Int): Int {
return value * (this / 100);
}
val num = 100;
5 percentOf num
class IntUtil {
int percentOf(int value, int percentage) {
return value * (percentage / 100);
}
}
int num = 100;
IntUtil util = new IntUtil();
util.percentOf(num, 5);
33. Kotlin Features - Single-Expression Functions
fun sum(x: Int, y: Int): Int {
return x + y
}
fun checkAndroidVersion(apiLevel: Int):
String {
return when(apiLevel) {
26 -> "Oreo"
25 -> "Nougat"
23 -> "Marshmallow"
21 -> "Lollipop"
...
}
}
fun sum(x: Int, y: Int): Int = x + y
fun checkAndroidVersion(apiLevel: Int): =
when(apiLevel) {
26 -> "Oreo"
25 -> "Nougat"
23 -> "Marshmallow"
21 -> "Lollipop"
...
}
}
34. Kotlin Java
Kotlin Features - Operator Overloading
class Point(val x: Int, val y: Int) {
...
operator fun plus(other: Point): P =
Point(x + other.x, y + other.y)
}
val point1 = Point(5, 10)
val point2 = Point(10, 20)
val point3 = point1 + point2
class Point {
int x;
int y;
...
Point plus(Point point) {
return new Point(this.x + point.x, this.y +
point.y);
}
}
Point point1 = new Point(5, 10);
Point point2 = new Point(16, 15);
Point point3 = point1.plus(point2);
35. Kotlin Java
Kotlin Features - Higher-Order Functions
fun doIfLollipop(func: () -> Unit) {
if(versionIsLollipop){
func()
}
}
doIfLollipop { println("I'm a Lollipop!") }
void doIfLollipop(Runnable callback) {
if(versionIsLollipop){
callback.run();
}
}
doIfLollipop(new Runnable() {
@Override
public void run() {
System.out.println("I'm a Lollipop!");
}
});
36. Kotlin Java
Kotlin Features - Higher-Order Functions
val list: List<Int> =
listOf(1,3,2,4,16,15,32)
list
.filter { it % 2 == 0 }
.map { it * 10 }
List<Integer> list = new ArrayList<>();
list.add(1);
list.add(5);
list.add(3);
list.add(8);
list.add(14);
List<Integer> filteredList = new ArrayList<>();
for(int i = 0; i < list.size(); i++){
if(list.get(i) % 2 == 0){
filteredList.add(list.get(i) * 10);
}
}
38. Android Components
● Activities
○ Entry point for interacting with the user
○ Represent a single screen
○ Keep track of the what is or should be on the screen
○ Provide a way for apps to implement user flows
39. Android Components
● Services
○ Keep your app running in the background
○ Are useful for long-running tasks like downloading
40. Android Components
● Broadcast Receivers
○ Enables apps to deliver events to apps outside the regular user flow
○ Usually used for system events like if a screen is turned off, or the wi-fi is turned on
○ Has no user interface but usually communicates with a status bar notification
41. Android Components
● Content Providers
○ Are a set of app data that you can store in the file system
○ Enables other apps to query or modify the data if it allows it
○ Are entry points to the app’s data
○ Uses Uniform Resource Identifiers (URI)
42. Android Components
● Intents
○ Are used to connect the different Android Components
○ Can carry information from its component
○ Has two types:
■ Explicit Intents - Specify what to be opened
■ Implicit Intents - Specify what to be done
44. UB Subjects App
Requirements:
● See the list of Subjects
● See the details of the Subject
○ Name of the subject
○ Short Description of the subject
○ See the List of Teachers teaching a subject
45. Displaying a List of Data
1. Create a layout with a RecyclerView
2. Create a layout for each List Item
2. Create a RecyclerViewAdapter and set it
46. Connecting to a Web Service / API
Using AsyncTask
class GetUserTask : AsyncTask<String, Int, User> {
override fun onPreExecute() {
...
}
override fun doInBackground(vararg args: String){
val httpClient = HttpClient()
httpClient.setUrl("https://my.url/user")
.setHeader(...)
.setMethod("POST")
.setParameters(...)
.execute()
...
}
override fun onPostExecute() {
...
}
}
val getUserTask = GetUserTask()
getUserTask.execute(myUserId)
Using Retrofit
interface UserApi {
@GET("user/{uid}")
fun getUser(@Query userId: String)
: Call<Response<User>>
}
val retrofit = Retrofit.Builder()
.baseUrl("https://my.url")
.build()
val service = retrofit.create(UserApi::class.java)
service.getUser(myUserId)
47. Persisting your Data - Defining your Structure
With Content Providers
class DatabaseContract {
abstract class Table1 : BaseColumns {
val TABLE_NAME = "nameOfTable";
val COLUMN_NAME_COL1 = "column1";
val COLUMN_NAME_COL2 = "column2";
val COLUMN_NAME_COL3 = "column3";
}
}
Using Room
@Entity(tableName = "tableName")
data class TableModel(
@PrimaryKey(autoGenerate = true)
var id: String = "",
var column1: String = "",
var column2: String = "",
var column3: Int = 1
)
48. Persisting your Data - Creating the Database
With Content Providers
class DatabaseHelper: SQLiteOpenHelper {
val DATABASE_VERSION = 1;
val DATABASE_NAME = "database.db";
val TEXT_TYPE = " TEXT";
val COMMA_SEP = ",";
val SQL_CREATE_ENTRIES = "CREATE TABLE " +
Table1.TABLE_NAME + " (" +
Table1._ID + " INTEGER PRIMARY KEY," +
Table1.COLUMN_NAME_COL1 + TEXT_TYPE + COMMA_SEP +
Table1.COLUMN_NAME_COL2 + TEXT_TYPE + COMMA_SEP +
Table1.COLUMN_NAME_COL3 + TEXT_TYPE + COMMA_SEP + " )";
val SQL_DELETE_ALL_ENTRIES = "DROP TABLE IF EXISTS " +
Table1.TABLE_NAME;
constructor(context: Context) : this(context, DATABASE_NAME, null,
DATABASE_VERSION)
override fun onCreate(SQLiteDatabase db) {
db.execSQL(SQL_CREATE_ENTRIES);
}
override fun onUpgrade(db: SQLiteDatabase, oldVersion: Int,
newVersion: Int) {
db.execSQL(SQL_DELETE_ALL_ENTRIES);
onCreate(db);
}
}
Using Room
@Database(
entities = arrayOf(
Subject::class,
Student::class,
StudentSubject::class
),
version = 3,
exportSchema = false
)
abstract class SubjectsDatabase : RoomDatabase()
db = Room.databaseBuilder(applicationContext,
SubjectsDatabase::class.java, "subjects_db")
.fallbackToDestructiveMigration()
.build()
49. Persisting your Data - Defining your Methods
With Content Providers
class ExampleProvider : ContentProvider {
lateinit var mOpenHelper: MainDatabaseHelper
lateinit var db: SQLiteDatabase
val DBNAME = "mydb"
fun onCreate(): Boolean {
mOpenHelper =
MainDatabaseHelper(getContext(),DBNAME,null,1)
return true
}
fun insert(Uri uri, ContentValues values): Cursor {
...
db = mOpenHelper.getWritableDatabase()
}
fun query(...) : Cursor {
...
}
fun update(...) : Cursor {
...
}
fun delete(...) : Cursor {
...
}
fun getType(...) : Cursor {
...
}
}
Using Room
@Dao
interface StudentDao {
@Query("SELECT * FROM student_subject INNER
JOIN student ON student.id =
student_subject.studentId WHERE
student_subject.subjectId LIKE
:arg0")
fun getStudents(subjectId: String):
LiveData<List<Student>>
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun saveStudent(student: Student)
}
50. Persisting your Data - Using the Database
With Content Providers
val dbHelper = DatabaseHelper(context)
val db = dbHelper.getWriteableDatabase()
val values = ContentValues()
values.put(DatabaseContract.Table1.COLUMN_NAME_COL1, "value1")
values.put(DatabaseContract.Table1.COLUMN_NAME_COL2, "value2")
values.put(DatabaseContract.Table1.COLUMN_NAME_COL3, "value3")
val newRowId = db.insert(DatabaseContract.Table1.TABLE_NAME,
null, values)
Using Room
val students =
studentDao.getStudents(subjectId)
Executor {
studentDao.saveStudent(student)
}
57. How do we test components in MVVM?
● User Interface & Interactions
○ Android UI Instrumentation test and mock the ViewModel
● ViewModel
○ JUnit test and mock the Repository
● Repository
○ JUnit test and mock the WebService and DatabaseDaos
● Dao
○ Integration Tests and use an in-memory database to make sure it doesn’t overwrite existing data
● Webservice
○ JUnit test along with MockWebServer just to check if it can receive responses