File tree Expand file tree Collapse file tree 2 files changed +3
-6
lines changed
app/src/main/java/guide/graphql/toc/ui Expand file tree Collapse file tree 2 files changed +3
-6
lines changed Original file line number Diff line number Diff line change @@ -68,7 +68,6 @@ class ChaptersFragment : Fragment() {
68
68
binding.chapters.adapter = adapter
69
69
70
70
lifecycleScope.launchWhenStarted {
71
- // Loading
72
71
try {
73
72
val response = apolloClient.query(
74
73
ChaptersQuery ()
@@ -77,10 +76,8 @@ class ChaptersFragment : Fragment() {
77
76
throw Exception (" Response has errors" )
78
77
}
79
78
val chapters = response.data?.chapters ? : throw Exception (" Data is null" )
80
- // Success
81
79
adapter.updateChapters(chapters)
82
80
} catch (e: ApolloException ) {
83
- // Error
84
81
showErrorMessage(" GraphQL request failed" )
85
82
} catch (e: Exception ) {
86
83
showErrorMessage(e.message.orEmpty())
Original file line number Diff line number Diff line change @@ -58,18 +58,19 @@ class SectionsFragment : Fragment() {
58
58
binding.sections.adapter = adapter
59
59
60
60
lifecycleScope.launchWhenStarted {
61
- // Loading
62
61
binding.spinner.visibility = View .VISIBLE
63
62
binding.error.visibility = View .GONE
64
63
try {
65
64
val response = apolloClient.query(
66
65
SectionsQuery (id = args.chapterId)
67
66
).toDeferred().await()
67
+
68
68
if (response.hasErrors()) {
69
69
throw Exception (" Response has errors" )
70
70
}
71
+
71
72
val sections = response.data?.chapter?.sections ? : throw Exception (" Data is null" )
72
- // Success
73
+
73
74
if (sections.size > 1 ) {
74
75
adapter.updateSections(sections)
75
76
binding.spinner.visibility = View .GONE
@@ -78,7 +79,6 @@ class SectionsFragment : Fragment() {
78
79
throw Exception (" No sections" )
79
80
}
80
81
} catch (e: ApolloException ) {
81
- // Error
82
82
showErrorMessage(" GraphQL request failed" )
83
83
} catch (e: Exception ) {
84
84
showErrorMessage(e.message.orEmpty())
You can’t perform that action at this time.
0 commit comments