Browse Source

[all] Updated according to the final drafts

master
Miguel Castiblanco 4 years ago
parent
commit
cd408283fc
  1. 10
      Chapter3/RssReader/app/src/main/java/co/starcarr/rssreader/MainActivity.kt
  2. 10
      Chapter4/RssReader/app/src/main/java/co/starcarr/rssreader/MainActivity.kt
  3. 2
      Chapter4/RssReader/app/src/main/java/co/starcarr/rssreader/adapter/ArticleAdapter.kt

10
Chapter3/RssReader/app/src/main/java/co/starcarr/rssreader/MainActivity.kt

@ -39,12 +39,18 @@ class MainActivity : AppCompatActivity() {
it.join()
}
// If the code below crashes, please change the filter
// to !it.isCompletedExceptionally until this issue is
// closed: https://github.com/Kotlin/kotlinx.coroutines/issues/220
val headlines = requests
.filter { !it.isCompletedExceptionally }
.filter { !it.isCancelled }
.flatMap { it.getCompleted() }
// If the counter doesn't work, please change the filter
// to it.isCompletedExceptionally until this issues is
// closed: https://github.com/Kotlin/kotlinx.coroutines/issues/220
val failed = requests
.filter { it.isCompletedExceptionally }
.filter { it.isCancelled }
.size
val newsCount = findViewById<TextView>(R.id.newsCount)

10
Chapter4/RssReader/app/src/main/java/co/starcarr/rssreader/MainActivity.kt

@ -56,12 +56,18 @@ class MainActivity : AppCompatActivity() {
it.join()
}
// If the code below crashes, please change the filter
// to !it.isCompletedExceptionally until this issue is
// closed: https://github.com/Kotlin/kotlinx.coroutines/issues/220
val articles = requests
.filter { !it.isCompletedExceptionally }
.filter { !it.isCancelled }
.flatMap { it.getCompleted() }
// If the counter doesn't work, please change the filter
// to it.isCompletedExceptionally until this issues is
// closed: https://github.com/Kotlin/kotlinx.coroutines/issues/220
val failed = requests
.filter { it.isCompletedExceptionally }
.filter { it.isCancelled }
.size
val obtained = requests.size - failed

2
Chapter4/RssReader/app/src/main/java/co/starcarr/rssreader/adapter/ArticleAdapter.kt

@ -8,7 +8,7 @@ import android.widget.TextView
import co.starcarr.rssreader.R
import co.starcarr.rssreader.model.Article
class ArticleAdapter(val name:String) : RecyclerView.Adapter<ArticleAdapter.ViewHolder>() {
class ArticleAdapter : RecyclerView.Adapter<ArticleAdapter.ViewHolder>() {
private val articles: MutableList<Article> = mutableListOf()

Loading…
Cancel
Save