Optimize strState Handling by Removing Redundant try-catch (#3409)

Refactored the code for handling the `strState` string to remove the redundant `try-catch` block. Updated to use safe call with the Elvis operator for improved readability and efficiency. This change simplifies the code and reduces the need for exception handling in this context.
This commit is contained in:
Tamim Hossain authored and GitHub committed 2024-08-03 10:30:38 +08:00
1 parent b6959b5990
commit 146d20ce86
1 file changed
+1 -5
@@ -98,11 +98,7 @@ class MainRecyclerAdapter(val activity: MainActivity) : RecyclerView.Adapter<Mai
}
}
val strState = try{
"${outbound?.getServerAddress()?.dropLast(3)}*** : ${outbound?.getServerPort()}"
}catch(e: Exception){
""
}
val strState = "${outbound?.getServerAddress()?.dropLast(3)}*** : ${outbound?.getServerPort() ?: ""}"
holder.itemMainBinding.tvStatistics.text = strState