[Android] [PATCH] focus on item in main video screen
Chegou Junior KEITA
chegoujk at gmail.com
Tue Apr 26 15:46:37 CEST 2016
---
vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.java | 4 ++++
.../src/org/videolan/vlc/gui/video/VideoListAdapter.java | 11 ++++++++++-
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.java b/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.java
index 6c59146..52e2aa2 100644
--- a/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.java
+++ b/vlc-android/src/org/videolan/vlc/gui/helpers/UiTools.java
@@ -34,6 +34,7 @@ import android.preference.PreferenceManager;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.Snackbar;
+import android.support.v4.content.ContextCompat;
import android.text.Html;
import android.text.TextUtils;
import android.util.DisplayMetrics;
@@ -55,6 +56,9 @@ import java.util.concurrent.atomic.AtomicInteger;
public class UiTools {
+ public static final int ITEM_FOCUS_ON = ContextCompat.getColor(VLCApplication.getAppContext(), R.color.orange800);
+ public static final int ITEM_FOCUS_OFF = ContextCompat.getColor(VLCApplication.getAppContext(), R.color.transparent);
+
private static final AtomicInteger sNextGeneratedId = new AtomicInteger(1);
private static final Handler sHandler = new Handler(Looper.getMainLooper());
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 4fe2880..029f098 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
@@ -42,6 +42,7 @@ import org.videolan.vlc.gui.SecondaryActivity;
import org.videolan.vlc.gui.helpers.AsyncImageLoader;
import org.videolan.vlc.gui.helpers.BitmapCache;
import org.videolan.vlc.gui.helpers.BitmapUtil;
+import org.videolan.vlc.gui.helpers.UiTools;
import org.videolan.vlc.media.MediaGroup;
import org.videolan.vlc.media.MediaWrapper;
import org.videolan.vlc.util.Strings;
@@ -340,7 +341,7 @@ public class VideoListAdapter extends RecyclerView.Adapter<VideoListAdapter.View
return super.getItemViewType(position);
}
- public class ViewHolder extends RecyclerView.ViewHolder implements View.OnLongClickListener {
+ public class ViewHolder extends RecyclerView.ViewHolder implements View.OnLongClickListener, View.OnFocusChangeListener {
boolean listmode;
ViewDataBinding binding;
@@ -376,5 +377,13 @@ public class VideoListAdapter extends RecyclerView.Adapter<VideoListAdapter.View
mFragment.mGridView.openContextMenu(getLayoutPosition());
return true;
}
+
+ @Override
+ public void onFocusChange(View v, boolean hasFocus) {
+ if (hasFocus)
+ itemView.setBackgroundColor(UiTools.ITEM_FOCUS_ON);
+ else
+ itemView.setBackgroundColor(UiTools.ITEM_FOCUS_OFF);
+ }
}
}
--
1.9.1
More information about the Android
mailing list