Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
Title Page
Copyright
Kotlin Blueprints
Credits
About the Authors
Acknowledgments
About the Reviewer
www.PacktPub.com
Why subscribe?
Customer Feedback
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
The Power of Kotlin
Kotlin – a better Java
Why not other languages?
Why Kotlin?
Concise yet expressive code
Enhanced robustness
Excellent IDE support from day one
Beyond being a better Java
Kotlin is in the winning camp
Go native strategy
Kotlin's winning strategy
Summary
Geospatial Messenger – Spring Boot
Why Spring Boot?
Leveraging Kotlin in Spring Boot applications
Extension functions
Constructor injection
Leveraging Null safety
Functional bean declaration DSL
Let's build our geospatial messenger
Preview
Features
Architecture
Setting up the IDE
Creating a project
Project structure
Setting up the build script
Adding Kotlin dependency
Adding Spring Boot dependencies
Exposed library
Gradle dependency
Defining the table
Connecting to the database
CRUD operations
Explaining PostGIS
Installation
Gradle dependency
Object mapping
Gradle dependency
Completing the Gradle script
Coding the application
Frontend
HTML
CSS
JavaScript
Rendering the map
Plotting messages on the map
Listening to message saved events
Complete JavaScript
Application class
Backend
Application configuration
Data classes
Exposed integration
Exposed objects
Extras for geospatial support
Service/Controller
Repository
CrudRepository
Event broadcaster
Extension functions
Testing
Gradle dependency
Test cases
Pro-tips
All-open compiler plugin
Spring starter
Playing with the Java to Kotlin converter
Migrating to Kotlin
Should I rewrite the existing Java code in Kotlin?
What if I want to rewrite Java to Kotlin?
Summary
Social Media Aggregator Android App
Setting up Kotlin
Setting up the Kotlin plugin for Android Studio
Getting started
Converting Java code to Kotlin code
Creating a social media aggregator
Using datatypes and conversion
String interpolation
String utility methods
Classes
Constructors
Data classes
Inheritance
Singletons
lateinit versus lazy initialization
lateinit
The lazy property
Control flow
The when() expression
Getters and setters
Declaring a property
Interfaces
Kotlin Android extension
Ditching the findViewById() method
View extensions
Fragment LayoutInflater extension
The Standard.kt function
The with() function
The apply() function
The let() function
Functions in Kotlin
Single-expression function
Inline function
Default and named parameters
Default parameter
Named parameter
Destructing declaration
Android context
Null-Safety
Why Kotlin is called null-safe
Safe call operator (?.)
Elvis operator (?:)
Force unwrap (!!)
Smart casts
The is and !is operators
The as operator
Companion object
Fragment instantiation using companion objects
Dealing with constants
Object expressions and declarations
Delegated properties
Dealing with Shared Preferences
Setting up an item click on RecyclerView
Anko - Kotlin's buddy for Android
Setting up Anko
Displaying toast()
Starting an activity made easy
Anko layout
Summary
Weather App Using Kotlin for JavaScript
Creating your first Kotlin and JavaScript project
Choosing an IDE
Creating a project
Creating an HTML page
Creating a Main.kt file
Running the project
Developing a weather forecast web app
Creating a UI with dummy data
Simple HTML approach
Creating UI using Kotlin
What is DSL?
Using Kotlinx.html
Refactoring the HTML code using DSL
Calling a weather API
Reading data from input elements
Data classes
Showing data to the user
Showing weather details
Named parameters
Extension functions
Giving final touches
Adding CSS
Interoperability with JavaScript
Summary
Chat Application with Server-Side JavaScript Generation
Creating our first Node.js app using Kotlin
Choosing an IDE
Installing Node.js
Installing the Node.js plugin
Creating a project
Creating a chat application
Setting up the Node.js server
Specifying the output files
Examining the compilation output
Specifying the router
Starting the node server
Creating a login page
Creating an index.ejs file
Using DSL
Using kotlinx.html
Lambda functions
Reading the nickname
Passing nickname to the server
Smart cast
Registering a callback
Establishing a socket connection
Setting up Socket.IO
Listening to events
Emitting the event
Incrementing and decrementing operator overloading
Showing a list of online users
Using the data class
Using the Pair class
Iterating list
Sending and receiving a message
Null safety
Force unwraps
Using the let function
Named parameter
Disconnecting a socket
Styling the page using CSS
Summary
News Feed – REST API
What is REST?
What is Ktor?
Why Ktor?
Understanding unopinionated applications
Asynchronous nature
Highly testable
Deploying the Ktor app
Let's build our news application
News provider
Fetching news sources
Fetching news articles
Preview
Features
Architecture
Setting up the IDE
Prerequisites
Creating the project
Project structure
Deploying
Deploying in IntelliJ IDEA
Setting up the build script
Adding Kotlin dependency
Adding Ktor dependencies
Configuring logging
Adding Fuel
What is Fuel?
Adding Gradle dependency
Quick sample
Asynchronous mode
Blocking mode
Completing Gradle script
Let's code!
Application configuration
Deployment block
Application block
Application main
Installing routing
Simple routing
Modular routing
Understanding route paths
Path parameters
Testing
Adding Gradle dependency
Testing the application
Testing the index URL
Testing JSON using Postman
Testing news sources using Postman
Testing news sources using Postman
Summary
CSV Reader in Kotlin Native
What is Kotlin Native?
Target platforms
Multiplatform Kotlin
Installing Kotlin Native
Installing from the source
Installing from binaries
Testing the installation
Memory management
Building our app
Writing the main function
Reading command-line arguments
Opening the file
Reading the file contents
Counting unique entries
Converting to Kotlin string
Splitting strings
Printing the result
Complete code
Running the program
Understanding the dataset
Compiling the program
Executing the program
Multiplatform Kotlin
Project structure
Common module
Platform module
Regular module
Overview of the dependency structure
Setting up a multiplatform project
Creating a multiplatform project with an IDE
Creating a multiplatform project without an IDE
Summary
Dictionary Desktop Application - TornadoFX
Introducing TornadoFX
Java-based desktop frameworks
TornadoFX special additions
Creating a type-safe UI versus FXML
Type-safe styling
Other improvements
Let's build our dictionary application
What we will build
Words API
Definition API
Features of our application
Setting up the IDE
Prerequisites
Installing the TornadoFX plugin
Creating the project
Project structure
Let's code!
Application class
Type-safe CSS
Dependency injection
Property delegate
Consuming the REST API
Defining the Model
Implementing the JSONModel interface
REST client
Configuring the client
Controllers
Views
Layouts
VBox layout
HBox layout
Other layouts
Forms
Background operations
Printing the result
Complete View
Launching the application
Summary
← Prev
Back
Next →
← Prev
Back
Next →