[Android] Fix network server editing
Geoffrey Métais
git at videolan.org
Tue Mar 24 17:17:55 CET 2020
vlc-android | branch: 3.2.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Mar 24 17:16:52 2020 +0100| [302e361e75d7cdcc2c35ecdfedf1383dcff981cd] | committer: Geoffrey Métais
Fix network server editing
Fix #1072
> https://code.videolan.org/videolan/vlc-android/commit/302e361e75d7cdcc2c35ecdfedf1383dcff981cd
---
.../org/videolan/vlc/gui/dialogs/NetworkServerDialog.kt | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/dialogs/NetworkServerDialog.kt b/vlc-android/src/org/videolan/vlc/gui/dialogs/NetworkServerDialog.kt
index 68d9aad25..6d387d5f9 100644
--- a/vlc-android/src/org/videolan/vlc/gui/dialogs/NetworkServerDialog.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/dialogs/NetworkServerDialog.kt
@@ -16,12 +16,17 @@ import android.widget.*
import androidx.appcompat.app.AppCompatDialog
import androidx.fragment.app.DialogFragment
import com.google.android.material.textfield.TextInputLayout
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
+import kotlinx.coroutines.withContext
import org.videolan.medialibrary.interfaces.media.AbstractMediaWrapper
import org.videolan.vlc.R
import org.videolan.vlc.gui.DialogActivity
import org.videolan.vlc.gui.MainActivity
import org.videolan.vlc.repository.BrowserFavRepository
+import org.videolan.vlc.util.AppScope
import org.videolan.vlc.util.runIO
+import org.videolan.vlc.util.runOnMainThread
class NetworkServerDialog : DialogFragment(), AdapterView.OnItemSelectedListener, TextWatcher, View.OnClickListener {
@@ -136,10 +141,11 @@ class NetworkServerDialog : DialogFragment(), AdapterView.OnItemSelectedListener
else
editServername.text.toString()
val uri = Uri.parse(url.text.toString())
- if (::networkUri.isInitialized) {
- runIO(Runnable { mBrowserFavRepository.deleteBrowserFav(networkUri) })
+ AppScope.launch {
+ if (::networkUri.isInitialized) mBrowserFavRepository.deleteBrowserFav(networkUri).join()
+ mBrowserFavRepository.addNetworkFavItem(uri, name, null).join()
+ dismiss()
}
- mBrowserFavRepository.addNetworkFavItem(uri, name, null)
}
private fun updateUrl() {
@@ -238,10 +244,7 @@ class NetworkServerDialog : DialogFragment(), AdapterView.OnItemSelectedListener
override fun onClick(v: View) {
when (v.id) {
- R.id.server_save -> {
- saveServer()
- dismiss()
- }
+ R.id.server_save -> saveServer()
R.id.server_cancel -> dismiss()
}
}
More information about the Android
mailing list