Bläddra i källkod

added try...catch

yattoz 4 år sedan
förälder
incheckning
a9a3186d83

+ 0 - 1
app/build.gradle Visa fil

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

+ 0 - 1
app/src/main/java/fr/forum_thalie/tsumugi/MainActivity.kt Visa fil

@@ -15,7 +15,6 @@ import fr.forum_thalie.tsumugi.playerstore.PlayerStore
15 15
 
16 16
 import java.util.Timer
17 17
 import android.view.MenuItem
18
-import com.google.android.material.snackbar.Snackbar
19 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 Visa fil

@@ -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
 }