Learn Kotlin for Android Development by Peter Späth
Author:Peter Späth
Language: eng
Format: epub
ISBN: 9781484244678
Publisher: Apress
restoreData(savedInstanceState) // new!
showData(Statistics.getStatistics())
}
The two new functions read:fun restoreData(savedInstanceState: Bundle?) {
savedInstanceState?.run {
getSerializable("statistics.data")?.run {
Statistics.data.clear()
Statistics.data.addAll( this as
ArrayList<Statistics.GameSessionRecord>)
}
}
}
override fun onSaveInstanceState(outState: Bundle?) {
super.onSaveInstanceState(outState)
outState?.putSerializable("statistics.data",
Statistics.data)
}
The ?.run{ } constructs make sure the run block gets executed only if the value in front of it is not null. If it gets executed, this contains exactly this value. Therefore the getSerializable() actually translates to this.getSerializable() and thus to the getSerializable() from the savedInstanceState object. The this as ... is needed because the getSerializable() by language design has lost its type information, so we must explicitly state the type.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
The Mikado Method by Ola Ellnestam Daniel Brolund(20601)
Hello! Python by Anthony Briggs(19897)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(18203)
Dependency Injection in .NET by Mark Seemann(18105)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(17574)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(17419)
Kotlin in Action by Dmitry Jemerov(17179)
Adobe Camera Raw For Digital Photographers Only by Rob Sheppard(16929)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(16234)
Grails in Action by Glen Smith Peter Ledbrook(15388)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(10391)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(8052)
Microservices with Go by Alexander Shuiskov(7816)
Practical Design Patterns for Java Developers by Miroslav Wengner(7718)
Test Automation Engineering Handbook by Manikandan Sambamurthy(7667)
Angular Projects - Third Edition by Aristeidis Bampakos(7159)
The Art of Crafting User Stories by The Art of Crafting User Stories(6610)
NetSuite for Consultants - Second Edition by Peter Ries(6531)
Demystifying Cryptography with OpenSSL 3.0 by Alexei Khlebnikov(6304)