Commit 7e5dc932 authored by Geoffrey Métais's avatar Geoffrey Métais

Rely on adapter inner lists for media references

parent 9fae2ccc
......@@ -28,8 +28,8 @@
card_view:cardUseCompatPadding="true"
android:background="?attr/background_default"
android:clickable="true"
android:onClick="@{(view) -> holder.onClick(view, media)}"
android:onLongClick="@{(view) -> holder.onLongClick(view, media)}" >
android:onClick="@{holder::onClick}"
android:onLongClick="@{holder::onLongClick}" >
<LinearLayout
android:id="@+id/layout_item"
android:layout_width="match_parent"
......
......@@ -49,8 +49,8 @@
android:clickable="true"
android:focusable="true"
android:longClickable="true"
android:onClick="@{(view) -> holder.onClick(view, media)}"
android:onLongClick="@{(view) -> holder.onLongClick(view, media)}"
android:onClick="@{holder::onClick}"
android:onLongClick="@{holder::onLongClick}"
android:paddingLeft="@dimen/left_right_1610_margin"
android:paddingRight="@dimen/left_right_1610_margin"
android:paddingBottom="@dimen/top_bottom_1610_margin"
......
......@@ -48,8 +48,8 @@
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:onClick="@{(view) -> holder.onClick(view, media)}"
android:onLongClick="@{(view) -> holder.onLongClick(view, media)}"
android:onClick="@{holder::onClick}"
android:onLongClick="@{holder::onLongClick}"
android:longClickable="true"
android:paddingTop="5dp"
android:paddingBottom="5dp"
......
......@@ -54,12 +54,14 @@ public class HistoryAdapter extends RecyclerView.Adapter<HistoryAdapter.ViewHold
binding = DataBindingUtil.bind(itemView);
}
public void onClick(View v, MediaWrapper mw){
mEventsHandler.onClick(v, getAdapterPosition(), mw);
public void onClick(View v){
int position = getAdapterPosition();
mEventsHandler.onClick(v, position, mMediaList.get(position));
}
public boolean onLongClick(View v, MediaWrapper mw) {
return mEventsHandler.onLongClick(v, getAdapterPosition(), mw);
public boolean onLongClick(View v) {
int position = getAdapterPosition();
return mEventsHandler.onLongClick(v, position, mMediaList.get(position));
}
}
......
......@@ -314,17 +314,22 @@ public class AudioBrowserAdapter extends RecyclerView.Adapter<AudioBrowserAdapte
}
public void onClick(View v) {
if (mIEventsHandler != null)
mIEventsHandler.onClick(v, getAdapterPosition(), vdb.getItem());
if (mIEventsHandler != null) {
int position = getAdapterPosition();
mIEventsHandler.onClick(v, position, mDataList[position]);
}
}
public void onMoreClick(View v) {
if (mIEventsHandler != null)
mIEventsHandler.onCtxClick(v, getAdapterPosition(), vdb.getItem());
if (mIEventsHandler != null) {
int position = getAdapterPosition();
mIEventsHandler.onCtxClick(v, position, mDataList[position]);
}
}
public boolean onLongClick(View view) {
return mIEventsHandler.onLongClick(view, getAdapterPosition(), vdb.getItem());
int position = getAdapterPosition();
return mIEventsHandler.onLongClick(view, position, mDataList[position]);
}
private void setCoverlay(boolean selected) {
......
......@@ -186,16 +186,19 @@ public class BaseBrowserAdapter extends RecyclerView.Adapter<BaseBrowserAdapter.
}
public void onClick(View v){
fragment.onClick(v, getAdapterPosition(), binding.getItem());
int position = getAdapterPosition();
fragment.onClick(v, position, mMediaList.get(position));
}
public void onMoreClick(View v) {
fragment.onCtxClick(v, getAdapterPosition(), binding.getItem());
int position = getAdapterPosition();
fragment.onCtxClick(v, position, mMediaList.get(position));
}
@Override
public boolean onLongClick(View v) {
return fragment.onLongClick(v, getAdapterPosition(), binding.getItem());
int position = getAdapterPosition();
return fragment.onLongClick(v, position, mMediaList.get(position));
}
private void setViewBackground(boolean focus, boolean selected) {
......
......@@ -63,7 +63,6 @@ import org.videolan.medialibrary.media.MediaWrapper;
import org.videolan.vlc.PlaybackService;
import org.videolan.vlc.R;
import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.gui.AudioPlayerContainerActivity;
import org.videolan.vlc.gui.MainActivity;
import org.videolan.vlc.gui.SecondaryActivity;
import org.videolan.vlc.gui.browser.MediaBrowserFragment;
......
......@@ -317,16 +317,18 @@ public class VideoListAdapter extends RecyclerView.Adapter<VideoListAdapter.View
itemView.setOnFocusChangeListener(this);
}
public void onClick(View v, MediaWrapper media) {
mEventsHandler.onClick(v, getAdapterPosition(), media);
public void onClick(View v) {
int position = getAdapterPosition();
mEventsHandler.onClick(v, position, mVideos.get(position));
}
public void onMoreClick(View v){
mEventsHandler.onCtxClick(v, getAdapterPosition(), null);
}
public boolean onLongClick(View v, MediaWrapper media) {
return mEventsHandler.onLongClick(v, getAdapterPosition(), media);
public boolean onLongClick(View v) {
int position = getAdapterPosition();
return mEventsHandler.onLongClick(v, position, mVideos.get(position));
}
private void setOverlay(boolean selected) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment