[Android] Clean browser adapter binding code

Geoffrey Métais git at videolan.org
Thu Feb 4 17:49:11 CET 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Feb  4 17:48:40 2016 +0100| [5c9a810afe4cae5ebe384b2f00367e801498c4cb] | committer: Geoffrey Métais

Clean browser adapter binding code

> https://code.videolan.org/videolan/vlc-android/commit/5c9a810afe4cae5ebe384b2f00367e801498c4cb
---

 vlc-android/res/layout/directory_view_item.xml              |  1 -
 .../org/videolan/vlc/gui/browser/BaseBrowserAdapter.java    | 10 ++--------
 .../src/org/videolan/vlc/gui/browser/FilePickerAdapter.java |  2 +-
 .../org/videolan/vlc/gui/browser/StorageBrowserAdapter.java | 13 +------------
 4 files changed, 4 insertions(+), 22 deletions(-)

diff --git a/vlc-android/res/layout/directory_view_item.xml b/vlc-android/res/layout/directory_view_item.xml
index a0486c8..eff9214 100644
--- a/vlc-android/res/layout/directory_view_item.xml
+++ b/vlc-android/res/layout/directory_view_item.xml
@@ -58,7 +58,6 @@
             android:layout_marginLeft="15dp"
             android:contentDescription="@string/cover_art"
             android:visibility="@{type != 2 ? View.VISIBLE : View.GONE}"
-            android:background="@drawable/icon"
             android:text="@{protocole}"
             android:textSize="11sp"
             android:textColor="@color/whitetransparent"/>
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.java b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.java
index d243505..5b3ee62 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.java
@@ -28,8 +28,6 @@ import android.support.v7.widget.RecyclerView;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
-import android.widget.CheckBox;
-import android.widget.TextView;
 
 import org.videolan.libvlc.Media;
 import org.videolan.vlc.R;
@@ -108,7 +106,7 @@ public class BaseBrowserAdapter extends  RecyclerView.Adapter<RecyclerView.ViewH
             vh.binding.setProtocole(getProtocol(media));
         vh.binding.executePendingBindings();
 
-        vh.icon.setBackgroundResource(getIconResId(media));
+        vh.binding.dviIcon.setBackgroundResource(getIconResId(media));
 
         vh.setContextMenuListener();
     }
@@ -131,16 +129,12 @@ public class BaseBrowserAdapter extends  RecyclerView.Adapter<RecyclerView.ViewH
     }
 
     public class MediaViewHolder extends ViewHolder implements View.OnLongClickListener {
-        public CheckBox checkBox;
-        public TextView icon;
         DirectoryViewItemBinding binding;
 
         public MediaViewHolder(View v) {
             super(v);
             binding = DataBindingUtil.bind(v);
             binding.setHolder(this);
-            checkBox = (CheckBox) v.findViewById(R.id.browser_checkbox);
-            icon = (TextView) v.findViewById(R.id.dvi_icon);
             v.findViewById(R.id.layout_item).setTag(R.id.layout_item, this);
         }
 
@@ -155,7 +149,7 @@ public class BaseBrowserAdapter extends  RecyclerView.Adapter<RecyclerView.ViewH
         protected void openStorage() {
             MediaWrapper mw = new MediaWrapper(((Storage) getItem(getAdapterPosition())).getUri());
             mw.setType(MediaWrapper.TYPE_DIR);
-            fragment.browse(mw, getAdapterPosition(), checkBox.isChecked());
+            fragment.browse(mw, getAdapterPosition(), binding.browserCheckbox.isChecked());
         }
 
         public void onCheckBoxClick(View v){
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/FilePickerAdapter.java b/vlc-android/src/org/videolan/vlc/gui/browser/FilePickerAdapter.java
index c625903..63c50c9 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/FilePickerAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/FilePickerAdapter.java
@@ -49,7 +49,7 @@ public class FilePickerAdapter extends BaseBrowserAdapter {
         vh.binding.setType(TYPE_MEDIA);
         vh.binding.setProtocole(null);
 
-        vh.icon.setBackgroundResource(getIconResId(media));
+        vh.binding.dviIcon.setBackgroundResource(getIconResId(media));
     }
 
     //TODO update with different filter types in other cases than subtitles selection
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserAdapter.java b/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserAdapter.java
index 0c4676f..fe77ce0 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserAdapter.java
@@ -67,17 +67,6 @@ public class StorageBrowserAdapter extends BaseBrowserAdapter {
                 (isRoot && (mMediaDirsLocation == null || mMediaDirsLocation.isEmpty())) ||
                 mMediaDirsLocation.contains(storagePath));
         vh.binding.setCheckEnabled(!((StorageBrowserFragment) fragment).mScannedDirectory);
-        vh.checkBox.setOnClickListener(new View.OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                boolean isChecked = ((CheckBox) v).isChecked();
-                String path = ((Storage) getItem(vh.getAdapterPosition())).getUri().getPath();
-                if (isChecked)
-                    addDir(path);
-                else
-                    removeDir(path);
-            }
-        });
         if (hasContextMenu)
             vh.setContextMenuListener();
     }
@@ -147,7 +136,7 @@ public class StorageBrowserAdapter extends BaseBrowserAdapter {
     protected void openMediaFromView(MediaViewHolder holder, View v) {
         MediaWrapper mw = new MediaWrapper(((Storage) getItem(holder.getAdapterPosition())).getUri());
         mw.setType(MediaWrapper.TYPE_DIR);
-        fragment.browse(mw, holder.getAdapterPosition(), holder.checkBox.isChecked());
+        fragment.browse(mw, holder.getAdapterPosition(), holder.binding.browserCheckbox.isChecked());
     }
 
     protected void checkBoxAction(View v, String path){



More information about the Android mailing list