Skip to content

Commit

Permalink
Fix discovery fragment crash when error
Browse files Browse the repository at this point in the history
  • Loading branch information
layou233 committed Oct 12, 2024
1 parent 396e84f commit 98dae0c
Showing 1 changed file with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,23 @@ class DiscoveryFragment : Fragment(), SwipeRefreshLayout.OnRefreshListener {
} catch (e: Exception) {
val stackTrace = Log.getStackTraceString(e)
Log.e(TAG, stackTrace)
startActivity(
Intent(
binding.root.context, ErrorActivity::class.java
).putExtra(ErrorActivity.KEY_ERROR, stackTrace)
)
_binding?.let {
startActivity(
Intent(
it.root.context, ErrorActivity::class.java
).putExtra(ErrorActivity.KEY_ERROR, stackTrace)
)
}
return@launch
}
if (resultObject["code"] != 200) {
startActivity(
Intent(
binding.root.context, ErrorActivity::class.java
).putExtra(ErrorActivity.KEY_ERROR, "Unexpected code: $resultObject")
)
_binding?.let {
startActivity(
Intent(
it.root.context, ErrorActivity::class.java
).putExtra(ErrorActivity.KEY_ERROR, "Unexpected code: $resultObject")
)
}
} else {
adapter.servers = (resultObject["data"] as JSONArray).map {
val serverObject = it as JSONObject
Expand Down

0 comments on commit 98dae0c

Please sign in to comment.