|
@@ -46,10 +46,10 @@ class NewsViewModel : ViewModel() {
|
46
|
46
|
coroutineScope.launch(Dispatchers.Main) {
|
47
|
47
|
Log.d(tag, "launching coroutine")
|
48
|
48
|
val parser = Parser()
|
|
49
|
+ try {
|
49
|
50
|
val articleList = parser.getArticles(urlToScrape)
|
50
|
51
|
newsArray.clear()
|
51
|
|
- for (i in 0 until min(articleList.size, maxNumberOfArticles))
|
52
|
|
- {
|
|
52
|
+ for (i in 0 until min(articleList.size, maxNumberOfArticles)) {
|
53
|
53
|
val item = articleList[i]
|
54
|
54
|
Log.d(tag, "i = $i / ${articleList.size}")
|
55
|
55
|
val news = News()
|
|
@@ -70,6 +70,10 @@ class NewsViewModel : ViewModel() {
|
70
|
70
|
// The list contains all article's data. For example you can use it for your adapter.
|
71
|
71
|
root?.isRefreshing = false
|
72
|
72
|
viewAdapter?.notifyDataSetChanged()
|
|
73
|
+ }catch (e: Exception)
|
|
74
|
+ {
|
|
75
|
+ e.printStackTrace()
|
|
76
|
+ }
|
73
|
77
|
}
|
74
|
78
|
}
|
75
|
79
|
}
|