Improve RxJava Disposable Handling in V2RayServiceManager (#3767)

Refactored the RxJava disposable handling in the V2RayServiceManager to ensure proper disposal when the service stops. This change prevents potential memory leaks by disposing of the disposable only when it's initialized, using a more concise and reliable approach with Kotlin's let function.
This commit is contained in:
Tamim Hossain
2024-10-25 16:35:03 +06:00
committed by GitHub
parent 0e5b88de8f
commit 6f9bb6caa7

View File

@@ -428,10 +428,11 @@ object V2RayServiceManager {
}
private fun stopSpeedNotification() {
if (mDisposable != null) {
mDisposable?.dispose() //stop queryStats
mDisposable?.let {
it.dispose() //stop queryStats
mDisposable = null
updateNotification(currentConfig?.remarks, 0, 0)
}
}
}