[Android] Hack to not override custom port
Geoffrey Métais
git at videolan.org
Fri Aug 12 18:42:16 CEST 2016
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Aug 12 18:41:48 2016 +0200| [3aa44c5de990a7a8de272c4e5560314929a4bee7] | committer: Geoffrey Métais
Hack to not override custom port
> https://code.videolan.org/videolan/vlc-android/commit/3aa44c5de990a7a8de272c4e5560314929a4bee7
---
.../vlc/gui/dialogs/NetworkServerDialog.java | 28 ++++++++++++++--------
1 file changed, 18 insertions(+), 10 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/dialogs/NetworkServerDialog.java b/vlc-android/src/org/videolan/vlc/gui/dialogs/NetworkServerDialog.java
index 46ba64a..945dd43 100644
--- a/vlc-android/src/org/videolan/vlc/gui/dialogs/NetworkServerDialog.java
+++ b/vlc-android/src/org/videolan/vlc/gui/dialogs/NetworkServerDialog.java
@@ -47,6 +47,8 @@ public class NetworkServerDialog extends DialogFragment implements AdapterView.O
Uri mUri;
String mName;
+ //Dummy hack because spinner callback is called right on registration
+ boolean mIgnoreFirstSpinnerCb = false;
public NetworkServerDialog() {}
@@ -105,16 +107,6 @@ public class NetworkServerDialog extends DialogFragment implements AdapterView.O
mPortTitle = (TextView) v.findViewById(R.id.server_port_text);
mProtocols = getResources().getStringArray(R.array.server_protocols);
- mSpinnerProtocol.setOnItemSelectedListener(this);
- mSave.setOnClickListener(this);
- mCancel.setOnClickListener(this);
-
- mEditPort.addTextChangedListener(this);
- mEditAddress.addTextChangedListener(this);
- mEditFolder.addTextChangedListener(this);
- mEditUsername.addTextChangedListener(this);
-
- updateUrl();
return v;
}
@@ -122,6 +114,7 @@ public class NetworkServerDialog extends DialogFragment implements AdapterView.O
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
if (mUri != null) {
+ mIgnoreFirstSpinnerCb = true;
mEditAddress.setText(mUri.getHost());
if (!TextUtils.isEmpty(mUri.getUserInfo()))
mEditUsername.setText(mUri.getUserInfo());
@@ -135,7 +128,18 @@ public class NetworkServerDialog extends DialogFragment implements AdapterView.O
int port = mUri.getPort();
mEditPort.setText(port != -1 ? String.valueOf(port) : getPortForProtocol(position));
}
+ mSpinnerProtocol.setOnItemSelectedListener(this);
+ mSave.setOnClickListener(this);
+ mCancel.setOnClickListener(this);
+
+ mEditPort.addTextChangedListener(this);
+ mEditAddress.addTextChangedListener(this);
+ mEditFolder.addTextChangedListener(this);
+ mEditUsername.addTextChangedListener(this);
+
+ updateUrl();
}
+
private void saveServer() {
String name = (TextUtils.isEmpty(mEditServername.getText().toString())) ?
mEditAddress.getText().toString() : mEditServername.getText().toString();
@@ -208,6 +212,10 @@ public class NetworkServerDialog extends DialogFragment implements AdapterView.O
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
+ if (mIgnoreFirstSpinnerCb) {
+ mIgnoreFirstSpinnerCb = false;
+ return;
+ }
boolean portEnabled = true, userEnabled = true;
String port = getPortForProtocol(position);
int addressHint = R.string.server_domain_hint;
More information about the Android
mailing list