[Android] Show video filename when sorted by filename

Geoffrey Métais git at videolan.org
Tue Sep 11 18:28:41 CEST 2018


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Sep 11 18:27:15 2018 +0200| [9489d36b2306b74c2ae1760e508fe4ba936154db] | committer: Geoffrey Métais

Show video filename when sorted by filename

Fix #606

> https://code.videolan.org/videolan/vlc-android/commit/9489d36b2306b74c2ae1760e508fe4ba936154db
---

 vlc-android/res/layout/video_grid_card.xml                        | 6 +++++-
 vlc-android/res/layout/video_list_card.xml                        | 6 +++++-
 vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java | 1 +
 vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java  | 7 +++++++
 4 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/vlc-android/res/layout/video_grid_card.xml b/vlc-android/res/layout/video_grid_card.xml
index 3c0d23770..87edeac0b 100644
--- a/vlc-android/res/layout/video_grid_card.xml
+++ b/vlc-android/res/layout/video_grid_card.xml
@@ -21,6 +21,10 @@
             name="time"
             type="String" />
 
+        <variable
+            name="showFilename"
+            type="android.databinding.ObservableBoolean" />
+
         <variable
             name="max"
             type="int" />
@@ -103,7 +107,7 @@
             android:textColor="@color/grey50"
             android:layout_marginLeft="@dimen/very_small_margin"
             android:layout_marginStart="@dimen/half_default_margin"
-            android:text="@{media.title}"
+            android:text="@{showFilename ? media.fileName : media.title}"
             tools:targetApi="jelly_bean" />
 
         <TextView
diff --git a/vlc-android/res/layout/video_list_card.xml b/vlc-android/res/layout/video_list_card.xml
index 74631574a..d01e36d8c 100644
--- a/vlc-android/res/layout/video_list_card.xml
+++ b/vlc-android/res/layout/video_list_card.xml
@@ -18,6 +18,10 @@
             name="time"
             type="String" />
 
+        <variable
+            name="showFilename"
+            type="android.databinding.ObservableBoolean" />
+
         <variable
             name="bgColor"
             type="int" />
@@ -95,7 +99,7 @@
             android:gravity="center_vertical"
             android:layout_marginStart="16dp"
             android:layout_marginLeft="16dp"
-            android:text="@{media.title}"
+            android:text="@{showFilename ? media.fileName : media.title}"
             style="@style/VLC.TextViewTitle" />
 
         <ImageView
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 7d8dacf82..ede6e8d44 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
@@ -161,6 +161,7 @@ public class VideoGridFragment extends MediaBrowserFragment<VideosModel> impleme
 
     @Override
     public void onChanged(@Nullable List<MediaWrapper> mediaWrappers) {
+        mAdapter.showFilename(viewModel.getSort() == Medialibrary.SORT_FILENAME);
         if (mediaWrappers != null) mAdapter.update(mediaWrappers);
     }
 
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 ef91e15ed..4bb7a0fc0 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
@@ -24,6 +24,7 @@ import android.annotation.TargetApi;
 import android.content.Context;
 import android.databinding.BindingAdapter;
 import android.databinding.DataBindingUtil;
+import android.databinding.ObservableBoolean;
 import android.databinding.ViewDataBinding;
 import android.os.Build;
 import android.support.annotation.MainThread;
@@ -62,6 +63,7 @@ public class VideoListAdapter extends DiffUtilAdapter<MediaWrapper, VideoListAda
     private int mGridCardWidth = 0;
 
     private boolean mIsSeenMediaMarkerVisible;
+    private ObservableBoolean mShowFilename = new ObservableBoolean();
 
     private MultiSelectHelper<MediaWrapper> multiSelectHelper;
 
@@ -76,6 +78,7 @@ public class VideoListAdapter extends DiffUtilAdapter<MediaWrapper, VideoListAda
     public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
         final LayoutInflater inflater = (LayoutInflater) parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
         final ViewDataBinding binding = DataBindingUtil.inflate(inflater, mListMode ? R.layout.video_list_card : R.layout.video_grid_card, parent, false);
+        binding.setVariable(BR.showFilename, mShowFilename);
         if (!mListMode) {
             final GridLayoutManager.LayoutParams params = (GridLayoutManager.LayoutParams) binding.getRoot().getLayoutParams();
             params.width = mGridCardWidth;
@@ -309,6 +312,10 @@ public class VideoListAdapter extends DiffUtilAdapter<MediaWrapper, VideoListAda
         mIsSeenMediaMarkerVisible = seenMediaMarkerVisible;
     }
 
+    void showFilename(boolean show) {
+        mShowFilename.set(show);
+    }
+
     @Override
     protected boolean detectMoves() {
         return true;



More information about the Android mailing list