I'm starting developing for Android using Kotlin. I have a problem with some concepts.
I use "->" in a condition statement but I don't know what that means in this example:
XmlPullParser.START_TAG -> {...}
XmlPullParser.TEXT -> textValue = xpp.text
XmlPullParser.END_TAG -> {...}
All the code is:
val factory = XmlPullParserFactory.newInstance()
factory.isNamespaceAware = true
val xpp = factory.newPullParser()
xpp.setInput(xmlData.reader())
var eventType = xpp.eventType
var currentRecord = FeedEntry()
while (eventType != XmlPullParser.END_DOCUMENT) {
val tagName = xpp.name.toLowerCase()
when (eventType) {
XmlPullParser.START_TAG -> {
Log.d(TAG, "parse: Starting tag for " + tagName)
if (tagName == "entry") {
inEntry = true
}
}
XmlPullParser.TEXT -> textValue = xpp.text
XmlPullParser.END_TAG -> {
Log.d(TAG, "parse: Ending tag for " + tagName)
if (inEntry) {
when (tagName) {
"entry" -> {
applications.add(currentRecord)
inEntry = false
currentRecord = FeedEntry()
}
"name" -> currentRecord.name = textValue
"artist" -> currentRecord.artist = textValue
"releasedate" -> currentRecord.releaseDate = textValue
"summary" -> currentRecord.summary = textValue
"image" -> currentRecord.imageURL = textValue
}
}
}
}