[Android] BrowserAdapter: check item != null once

Edward Wang git at videolan.org
Thu Aug 21 16:59:03 CEST 2014


vlc-ports/android | branch: master | Edward Wang <edward.c.wang at compdigitec.com> | Thu Aug 21 10:58:46 2014 -0400| [efd33709d06873983706b4d884e6a10013ae0842] | committer: Edward Wang

BrowserAdapter: check item != null once

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=efd33709d06873983706b4d884e6a10013ae0842
---

 .../src/org/videolan/vlc/gui/BrowserAdapter.java   |   50 ++++++++++----------
 1 file changed, 26 insertions(+), 24 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/BrowserAdapter.java b/vlc-android/src/org/videolan/vlc/gui/BrowserAdapter.java
index e620365..c78781e 100644
--- a/vlc-android/src/org/videolan/vlc/gui/BrowserAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/BrowserAdapter.java
@@ -78,32 +78,34 @@ public class BrowserAdapter extends ArrayAdapter<File>
         final File item = getItem(position);
         final MediaDatabase dbManager = MediaDatabase.getInstance();
 
-        if(item != null && item.getPath().equals(ADD_ITEM_PATH)) {
-            holder.text.setText(R.string.add_custom_path);
-            holder.check.setVisibility(View.GONE);
-        } else if(item != null && item.getName() != null) {
-            holder.text.setText(getVisibleName(item));
-            holder.check.setVisibility(View.VISIBLE);
-            holder.check.setOnCheckedChangeListener(null);
-            holder.check.setTag(item);
-            holder.check.setEnabled(true);
-            holder.check.setChecked(false);
-
-            List<File> dirs = dbManager.getMediaDirs();
-            for (File dir : dirs) {
-                if (dir.getPath().equals(item.getPath())) {
-                    holder.check.setEnabled(true);
-                    holder.check.setChecked(true);
-                    break;
-                } else if (dir.getPath().startsWith(item.getPath()+"/")) {
-                    Log.i(TAG, dir.getPath() + " startWith " + item.getPath());
-                    holder.check.setEnabled(false);
-                    holder.check.setChecked(true);
-                    break;
+        if(item != null) {
+            if(item.getPath().equals(ADD_ITEM_PATH)) {
+                holder.text.setText(R.string.add_custom_path);
+                holder.check.setVisibility(View.GONE);
+            } else if(item.getName() != null) {
+                holder.text.setText(getVisibleName(item));
+                holder.check.setVisibility(View.VISIBLE);
+                holder.check.setOnCheckedChangeListener(null);
+                holder.check.setTag(item);
+                holder.check.setEnabled(true);
+                holder.check.setChecked(false);
+
+                List<File> dirs = dbManager.getMediaDirs();
+                for (File dir : dirs) {
+                    if (dir.getPath().equals(item.getPath())) {
+                        holder.check.setEnabled(true);
+                        holder.check.setChecked(true);
+                        break;
+                    } else if (dir.getPath().startsWith(item.getPath()+"/")) {
+                        Log.i(TAG, dir.getPath() + " startWith " + item.getPath());
+                        holder.check.setEnabled(false);
+                        holder.check.setChecked(true);
+                        break;
+                    }
                 }
-            }
 
-            holder.check.setOnCheckedChangeListener(onCheckedChangeListener);
+                holder.check.setOnCheckedChangeListener(onCheckedChangeListener);
+            }
         }
 
         return view;



More information about the Android mailing list