Skip to content
Snippets Groups Projects
Commit c64d1c69 authored by Alexandre Perraud's avatar Alexandre Perraud
Browse files

Fix video grid item size and space

parent 99c34111
No related branches found
No related tags found
No related merge requests found
......@@ -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"
......
......@@ -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>
......
......@@ -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);
......
......@@ -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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment