[Android] Prevent NPE

Geoffrey Métais git at videolan.org
Thu Feb 18 14:50:56 CET 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Feb 18 14:31:33 2016 +0100| [8e99366318e64916dc0af14382bd3f3bbac8aec5] | committer: Geoffrey Métais

Prevent NPE

> https://code.videolan.org/videolan/vlc-android/commit/8e99366318e64916dc0af14382bd3f3bbac8aec5
---

 .../vlc/gui/dialogs/NetworkServerDialog.java       | 26 ++++++++++++----------
 1 file changed, 14 insertions(+), 12 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 b924b75..1f6196c 100644
--- a/vlc-android/src/org/videolan/vlc/gui/dialogs/NetworkServerDialog.java
+++ b/vlc-android/src/org/videolan/vlc/gui/dialogs/NetworkServerDialog.java
@@ -121,18 +121,20 @@ public class NetworkServerDialog extends DialogFragment implements AdapterView.O
     @Override
     public void onViewCreated(View view, Bundle savedInstanceState) {
         super.onViewCreated(view, savedInstanceState);
-        mEditAddress.setText(mUri.getHost());
-        if (!TextUtils.isEmpty(mUri.getUserInfo()))
-            mEditUsername.setText(mUri.getUserInfo());
-        if (!TextUtils.isEmpty(mUri.getPath()))
-            mEditFolder.setText(mUri.getPath().substring(1));
-        if (!TextUtils.isEmpty(mName))
-            mEditServername.setText(mName);
-
-        int position = getProtocolSpinnerPosition(mUri.getScheme().toUpperCase());
-        mSpinnerProtocol.setSelection(position);
-        int port = mUri.getPort();
-        mEditPort.setText(port != -1 ? String.valueOf(port) : getPortForProtocol(position));
+        if (mUri != null) {
+            mEditAddress.setText(mUri.getHost());
+            if (!TextUtils.isEmpty(mUri.getUserInfo()))
+                mEditUsername.setText(mUri.getUserInfo());
+            if (!TextUtils.isEmpty(mUri.getPath()))
+                mEditFolder.setText(mUri.getPath().substring(1));
+            if (!TextUtils.isEmpty(mName))
+                mEditServername.setText(mName);
+
+            int position = getProtocolSpinnerPosition(mUri.getScheme().toUpperCase());
+            mSpinnerProtocol.setSelection(position);
+            int port = mUri.getPort();
+            mEditPort.setText(port != -1 ? String.valueOf(port) : getPortForProtocol(position));
+        }
     }
     private void saveServer() {
         String name = (TextUtils.isEmpty(mEditServername.getText().toString())) ?



More information about the Android mailing list