[Android] Fix video grid item size and space
Alexandre Perraud
git at videolan.org
Wed Nov 9 19:30:48 CET 2016
vlc-android | branch: master | Alexandre Perraud <4leyx4ndre at gmail.com> | Wed Nov 9 19:21:23 2016 +0100| [c64d1c692788ef106cab226383fa62d9c34b2492] | committer: Alexandre Perraud
Fix video grid item size and space
> https://code.videolan.org/videolan/vlc-android/commit/c64d1c692788ef106cab226383fa62d9c34b2492
---
vlc-android/res/layout/video_grid_card.xml | 3 ++-
vlc-android/res/values/dimens.xml | 2 +-
.../src/org/videolan/vlc/gui/video/VideoGridFragment.java | 1 +
.../src/org/videolan/vlc/gui/video/VideoListAdapter.java | 12 ++++++++++++
4 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/vlc-android/res/layout/video_grid_card.xml b/vlc-android/res/layout/video_grid_card.xml
index 07909a0..a8c2a0f 100644
--- a/vlc-android/res/layout/video_grid_card.xml
+++ b/vlc-android/res/layout/video_grid_card.xml
@@ -40,6 +40,7 @@
</data>
<RelativeLayout
+ android:id="@+id/video_grid_item_layout"
android:layout_width="@dimen/grid_card_thumb_width"
android:layout_height="@dimen/grid_card_thumb_height"
android:layout_marginBottom="@dimen/default_margin"
@@ -54,7 +55,7 @@
android:id="@+id/ml_item_thumbnail"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:scaleType="centerCrop"
+ android:scaleType="center"
vlc:media="@{media}"
vlc:binding="@{holder.binding}"
android:src="@drawable/black_gradient"
diff --git a/vlc-android/res/values/dimens.xml b/vlc-android/res/values/dimens.xml
index 5acb261..0e9261e 100644
--- a/vlc-android/res/values/dimens.xml
+++ b/vlc-android/res/values/dimens.xml
@@ -5,7 +5,7 @@
<dimen name="directory_browser_item_size">40dp</dimen>
<dimen name="listview_bottom_padding">10dp</dimen>
<dimen name="listview_side_padding">5dp</dimen>
- <dimen name="grid_card_thumb_width">180dp</dimen>
+ <dimen name="grid_card_thumb_width">160dp</dimen>
<dimen name="grid_card_thumb_height">100dp</dimen>
<dimen name="tv_grid_card_thumb_width">192dp</dimen>
<dimen name="tv_grid_card_thumb_height">120dp</dimen>
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 b5bc397..d367425 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
@@ -236,6 +236,7 @@ public class VideoGridFragment extends MediaBrowserFragment implements MediaUpda
mGridView.setNumColumns(-1);
int thumbnailWidth = res.getDimensionPixelSize(R.dimen.grid_card_thumb_width);
mGridView.setColumnWidth(mGridView.getPerfectColumnWidth(thumbnailWidth, res.getDimensionPixelSize(R.dimen.default_margin)));
+ mVideoAdapter.setGridCardWidth(mGridView.getColumnWidth());
mGridView.removeItemDecoration(mDividerItemDecoration);
} else {
mGridView.setNumColumns(1);
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 2fdd59f..9fc5bbd 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
@@ -29,6 +29,7 @@ import android.preference.PreferenceManager;
import android.support.annotation.MainThread;
import android.support.annotation.Nullable;
import android.support.v7.util.SortedList;
+import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
@@ -73,6 +74,7 @@ public class VideoListAdapter extends RecyclerView.Adapter<VideoListAdapter.View
private ArrayList<MediaWrapper> mOriginalData = null;
private ItemFilter mFilter = new ItemFilter();
+ private int mGridCardWidth = 0;
public VideoListAdapter(VideoGridFragment fragment) {
super();
mFragment = fragment;
@@ -83,6 +85,12 @@ public class VideoListAdapter extends RecyclerView.Adapter<VideoListAdapter.View
boolean listMode = viewType == TYPE_LIST;
LayoutInflater inflater = (LayoutInflater) parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = inflater.inflate(mListMode ? R.layout.video_list_card : R.layout.video_grid_card, parent, false);
+ if (!mListMode) {
+ GridLayoutManager.LayoutParams params = (GridLayoutManager.LayoutParams) v.getLayoutParams();
+ params.width = mGridCardWidth;
+ params.height = params.width*10/16;
+ v.setLayoutParams(params);
+ }
return new ViewHolder(v, listMode);
}
@@ -233,6 +241,10 @@ public class VideoListAdapter extends RecyclerView.Adapter<VideoListAdapter.View
mListMode = value;
}
+ public void setGridCardWidth(int gridCardWidth) {
+ mGridCardWidth = gridCardWidth;
+ }
+
public boolean isListMode() {
return mListMode;
}
More information about the Android
mailing list