[Android] Rely on adapter inner lists for media references
Geoffrey Métais
git at videolan.org
Wed Dec 21 10:39:21 CET 2016
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Dec 21 10:39:02 2016 +0100| [7e5dc932fd0e2a28cec1e5b712e6e31e25780df8] | committer: Geoffrey Métais
Rely on adapter inner lists for media references
> https://code.videolan.org/videolan/vlc-android/commit/7e5dc932fd0e2a28cec1e5b712e6e31e25780df8
---
vlc-android/res/layout/list_item.xml | 4 ++--
vlc-android/res/layout/video_grid_card.xml | 4 ++--
vlc-android/res/layout/video_list_card.xml | 4 ++--
vlc-android/src/org/videolan/vlc/gui/HistoryAdapter.java | 10 ++++++----
.../org/videolan/vlc/gui/audio/AudioBrowserAdapter.java | 15 ++++++++++-----
.../org/videolan/vlc/gui/browser/BaseBrowserAdapter.java | 9 ++++++---
.../src/org/videolan/vlc/gui/video/VideoGridFragment.java | 1 -
.../src/org/videolan/vlc/gui/video/VideoListAdapter.java | 10 ++++++----
8 files changed, 34 insertions(+), 23 deletions(-)
diff --git a/vlc-android/res/layout/list_item.xml b/vlc-android/res/layout/list_item.xml
index afc80eb..04a2498 100644
--- a/vlc-android/res/layout/list_item.xml
+++ b/vlc-android/res/layout/list_item.xml
@@ -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"
diff --git a/vlc-android/res/layout/video_grid_card.xml b/vlc-android/res/layout/video_grid_card.xml
index 31b08c0..9b5ec56 100644
--- a/vlc-android/res/layout/video_grid_card.xml
+++ b/vlc-android/res/layout/video_grid_card.xml
@@ -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"
diff --git a/vlc-android/res/layout/video_list_card.xml b/vlc-android/res/layout/video_list_card.xml
index c15cfa3..fcd5a68 100644
--- a/vlc-android/res/layout/video_list_card.xml
+++ b/vlc-android/res/layout/video_list_card.xml
@@ -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"
diff --git a/vlc-android/src/org/videolan/vlc/gui/HistoryAdapter.java b/vlc-android/src/org/videolan/vlc/gui/HistoryAdapter.java
index 3f2f7ab..ecab6dc 100644
--- a/vlc-android/src/org/videolan/vlc/gui/HistoryAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/HistoryAdapter.java
@@ -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));
}
}
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.java
index 60fbb04..1cf15b6 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.java
@@ -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) {
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 fd73dc2..6321102 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.java
@@ -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) {
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
index a919abc..3ddb3a4 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
@@ -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;
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
index 275455e..0f2753d 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
@@ -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) {
More information about the Android
mailing list