售 价:¥
温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印
为你推荐
Title Page
Copyright and Credits
Kotlin Programming Cookbook
Packt Upsell
Why subscribe?
PacktPub.com
Contributors
About the authors
About the reviewer
Packt is searching for authors like you
Preface
Who this book is for
What this book covers
To get the most out of this book
Download the example code files
Conventions used
Sections
Getting ready
How to do it…
How it works…
There's more…
See also
Get in touch
Reviews
Installation and Working with Environment
Introduction
Creating Kotlin Android project
Getting ready
How to do it...
There's more...
How to use Gradle to run Kotlin code
Getting ready
How to do it...
There's more...
See also
How to run a Kotlin compiled class
Getting ready
How to do it...
How it works...
There's more...
How to build a self-executable JAR with Gradle and Kotlin
Getting ready
How to do it...
How it works...
Reading console input in Kotlin
Getting ready
How to do it...
How it works...
Converting Java code to Kotlin and vice versa
Getting ready
How to do it...
How it works...
How to write an idiomatic logger in Kotlin
Getting ready
How to do it...
How it works...
There's more...
See also
Escaping for Java identifiers that are keywords in Kotlin
Getting ready
How to do it...
How it works...
Disambiguating using the "as" keyword to locally rename the clashing entity
Getting ready
How to do it...
Doing bit manipulations in Kotlin
Getting ready
How to do it...
Or
and
xor
inv
shl
shr
ushr
How it works...
Parsing String to Long, Double, or Int
Getting ready
How to do it...
Converting String to Long
Converting string to Long using string.toLongOrNull()
Converting with special radix
Parsing string to Long with special radix
How it works...
There's more...
Using String templates in Kotlin
How to do it...
How it works...
There’s more...
Control Flow
Introduction
Assigning result to an expression using the if keyword
Getting ready
How to do it...
There's more...
Using range with the when expression
Getting ready
How to do it...
How it works...
There's more...
Using when with custom objects
Getting ready
How to do it...
How it works...
Using try–catch as an expression
Getting ready
How to do it...
How it works...
There's more...
How to write a swap function in Kotlin using the also function
Getting ready
How to do it...
How it works...
There's more...
How to throw a custom exception in Kotlin
Getting ready
How to do it...
How it works...
How to make a multiconditional loop in Kotlin
Getting ready
How to do it...
How it works...
Classes and Objects
Introduction
Initializing body of constructor
Getting ready
How to do it...
Converting one data type into another
Getting ready
How to do it...
How it works...
How to type check an object
Getting ready
How to do it...
How it works...
There's more...
How to work with an abstract class in Kotlin
Getting ready
How to do it...
How it works...
How to iterate over a class's properties in Kotlin
Getting ready
How to do it...
How it works...
There's more...
How to work with inline properties
Getting ready
How to do it...
How it works...
How to work with nested class
Getting ready
How to do it...
How it works...
There's more...
Getting class in Kotlin
How to do it...
There's more...
Working with delegated properties
Getting ready
How to do it...
There's more...
Working with enums
Getting ready
How to do it...
There's more...
Functions
Introduction
Specifying default values in functions
Getting ready
How to do it...
There's more...
Using named arguments in functions
Getting ready
How to do it...
Creating the RecyclerView Adapter in Kotlin
Getting ready
How to do it...
How it works...
There's more...
Creating getter setters in Kotlin
Getting ready
How to do it...
There's more...
Passing variable arguments to a function
Getting ready
How to do it...
How it works...
There's more...
Passing a function as a parameter to another
Getting ready
How to do it...
How it works...
Declaring a static function
Getting ready
How to do it...
Using the use keyword in Kotlin
Getting ready
How to do it...
How it works...
Working with closures
Getting ready
How to do it...
There's more...
Function literals with receivers
Getting ready
How to do it...
Working with anonymous functions
Getting ready
How to do it...
Object-Oriented Programming
Introduction
Working with interfaces in Kotlin
Getting ready
How to do it…
There's more…
How to implement complicated interfaces with multiple overridden methods in Kotlin
Getting ready
How to do it…
How to extend a class in Kotlin (Inheritance and Extension functions)
Getting ready
How to do it…
Extension functions
How it works…
There's more…
How to work with Generics in Kotlin
Getting ready
How to do it…
There's more…
How to implement polymorphism in Kotlin
Getting ready
How to do it…
Restricting class hierarchies
Getting ready
How to do it…
How it works…
There's more…
Collections Framework
Introduction
How to merge two collections
Getting ready
How to do it…
Splitting original collection into pair of collections
Getting ready
How to do it…
How it works…
There's more…
Sorting a list by specified comparator
Getting ready
How to do it…
How it works…
Sorting in descending order
Getting ready
How to do it…
How it works…
Parsing a JSON response using Gson
Getting ready
How to do it…
There's more…
How to filter and map using lambda expressions
Getting ready
How to do it…
How to sort a list of objects and keep null objects at the end
Getting ready
How to do it…
How it works…
How to implement a lazy list in Kotlin
Getting ready
How to do it…
How it works…
How to pad a string in Kotlin
Getting ready
How to do it…
How it works…
How to flatten an array or map
Getting ready
How to do it…
How it works…
How to sort collection by multiple fields in Kotlin
Getting ready
How to do it…
How it works…
How to use limit in Kotlin list
Getting ready
How to do it…
How to create a 2D array in Kotlin
Getting ready
How to do it…
There's more…
How to skip the first "n" entries in Kotlin
Getting ready
How to do it…
How it works…
Handling File Operations in Kotlin
Introduction
Reading from files using InputReader
Getting ready
How to do it…
How it works…
There's more…
Reading all lines in a file using InputReader
Getting ready
How to do it…
How it works…
Reading line by line using InputReader
Getting ready
How to do it…
How it works…
Reading from files using BufferedReader
Getting ready
How to do it…
How it works…
Reading all lines in a file using BufferedReader
Getting ready
How to do it…
How it works…
Reading line by line using bufferedReader
Getting ready
How to do it…
How it works…
There's more…
Reading string and JSON over network
Getting ready
How to do it…
How it works…
Anko Commons and Extension Function
Introduction
Setting up Anko with Gradle
Getting ready
How to do it…
Extending Android framework using extension function
Getting ready
How to do it…
How it works…
There's more…
Using extensions as properties
Getting ready
How to do it…
How it works…
There's more…
Using intents with Anko
Getting ready
How to do it…
How it works…
Making a call intent using Anko
Getting ready
How to do it…
How it works…
Sending a text intent using Anko
Getting ready
How to do it…
How it works…
Browsing the web browser using Anko
Getting ready
How to do it…
How it works…
Sharing some text using intents in Anko
Getting ready
How to do it…
How it works…
Sending an email using Anko
Getting ready
How to do it…
How it works…
Creating Android dialogs with Anko
Getting ready
How to do it…
Showing an alert dialog with a list of text items
Getting ready
How to do it…
How it works…
Using Anko in Views
Getting ready
How to do it…
Logging using Anko
Getting ready
How to do it…
Handling dimensions with Anko
Getting ready
How to do it…
Version checking on Android
Getting ready
How to do it…
How it works…
Anko Layouts
Introduction
Setting up Anko library for Anko layouts in Gradle
Getting ready
How to do it…
How it works…
There's more…
Creating user-interface programmatically
Getting ready
How to do it…
How it works…
Working with the old code of XML layouts
Getting ready
How to do it…
How it works…
There's more…
Using the provided AnkoComponent interface
Getting ready
How to do it…
How it works…
There's more…
Setting theme for Android views in Anko
Getting ready
How to do it…
Setting layout parameters for Anko views
Getting ready
How to do it…
How it works…
Adding listeners to Anko views
Getting ready
How to do it…
How it works…
There's more…
Inserting XML layouts into DSL
Getting ready
How to do it…
Converting XML files into DSL
Getting ready
How to do it…
Showing Snackbar
Getting ready
How to do it…
Showing Toasts
Getting started
How to do it…
Accessing views using synthetic properties
Getting ready
How to do it…
Accessing views of view groups using extension functions
Getting ready
How to do it…
How it works...
Databases and Dependency Injection
Introduction
Using SQLite database in Kotlin
Getting ready
How to do it…
Creating database tables
Getting ready
How to do it…
Injecting dependencies in Kotlin
Getting ready
How to do it…
How it works…
Reading data from database
Getting ready
How to do it…
Converting database cursor into list of objects
Getting ready
How to do it…
Using parseOpt for nullable object
Getting ready
How to do it…
Inserting data into database
Getting ready
How to do it…
Creating singletons in Kotlin
Getting ready
How to do it…
How it works…
Using Dagger 2 with Kotlin
Getting ready
How to do it…
Using Butterknife with Kotlin
Getting ready
How to do it…
There's more…
Networking and Concurrency
Introduction
How to fetch data over network
Getting ready
How to do it…
There's more…
How to create data class in Kotlin
Getting ready
How to do it…
There's more…
How to copy data class with modifications
Getting ready
How to do it…
There's more…
How to parse JSON data from network to data class
Getting ready
How to do it…
How to download a file in Kotlin
Getting ready
How to do it…
How to use RxJava and Retrofit with Kotlin
Getting ready
How to do it…
How to make an endless list using RecyclerView
Getting ready
How to do it…
How it works…
How to use Anko to run background tasks with Kotlin in Android
Getting ready
How to do it…
How it works…
How to use coroutines to achieve multithreading
Getting ready
How to do it…
There's more…
Lambdas and Delegates
Introduction
Click listeners using lambdas
Getting ready
How to do it…
How it works…
There's more…
Using lazy delegate in Kotlin
Getting ready
How to do it…
How it works…
Using the observable delegate
Getting ready
How to do it…
There's more…
Using vetoable delegate
Getting ready
How to do it…
How it works…
There's more…
Writing your own delegates
Getting ready
How to do it…
How it works…
Using the lateinit modifier
Getting ready
How to do it…
There's more…
Working with SharedPreferences
Getting ready
How to do it…
There's more…
Creating a chain of multiple lets in Kotlin
Getting ready
How to do it…
Creating global variables
Getting ready
How to do it…
Testing
Introduction
Unit testing Kotlin code
Getting ready
How to do it…
How it works…
Unit testing with Mockito
Getting ready
How to do it…
There's more…
Spy object
Mockito limitations
Running instrumentation tests
Getting ready
How to do it…
There's more…
Writing JUnit rules in Kotlin (@Rule)
Getting ready
How to do it…
How it works…
Acceptance tests using Espresso Kotlin
Getting ready
How to do it…
There's more…
Writing assertEquals in Kotlin
Getting ready
How to do it…
Web Services with Kotlin
Introduction
How to run the application on Tomcat
How to do it…
Setting up dependencies for building RESTful services
Getting ready
How to do it…
How to create a REST controller
Getting ready
How to do it…
There's more…
Creating the Application class for Spring Boot
Getting ready
How to do it…
Other Books You May Enjoy
Leave a review - let other readers know what you think
买过这本书的人还买过
读了这本书的人还在读
同类图书排行榜