Browse Source

added try...catch

yattoz 4 years ago
parent
commit
a9a3186d83

+ 0 - 1
app/build.gradle View File

77
 
77
 
78
     // RSS parser library @ https://github.com/prof18/RSS-Parser
78
     // RSS parser library @ https://github.com/prof18/RSS-Parser
79
     implementation 'com.prof.rssparser:rssparser:2.0.4'
79
     implementation 'com.prof.rssparser:rssparser:2.0.4'
80
-    implementation 'com.github.ahorn:android-rss:1.0-rc1'
81
 
80
 
82
     def work_version = "2.2.0"
81
     def work_version = "2.2.0"
83
     implementation "androidx.work:work-runtime-ktx:$work_version"
82
     implementation "androidx.work:work-runtime-ktx:$work_version"

+ 0 - 1
app/src/main/java/fr/forum_thalie/tsumugi/MainActivity.kt View File

15
 
15
 
16
 import java.util.Timer
16
 import java.util.Timer
17
 import android.view.MenuItem
17
 import android.view.MenuItem
18
-import com.google.android.material.snackbar.Snackbar
19
 import fr.forum_thalie.tsumugi.alarm.RadioAlarm
18
 import fr.forum_thalie.tsumugi.alarm.RadioAlarm
20
 
19
 
21
 
20
 

+ 6 - 2
app/src/main/java/fr/forum_thalie/tsumugi/ui/news/NewsViewModel.kt View File

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