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
2024-08-03 08:30:38 +06:00
committed by GitHub
parent b6959b5990
commit 146d20ce86
@@ -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