Skip to content
Snippets Groups Projects
Commit 5c9a810a authored by Geoffrey Métais's avatar Geoffrey Métais
Browse files

Clean browser adapter binding code

parent 462aafd9
No related branches found
No related tags found
No related merge requests found
......@@ -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"/>
......
......@@ -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){
......
......@@ -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
......
......@@ -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){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment