Commit 644b1750 authored by Geoffrey Métais's avatar Geoffrey Métais

Refactor video cards

parent 3d9c652e
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<gradient
android:angle="90"
android:endColor="@android:color/transparent"
android:centerColor="@android:color/transparent"
android:startColor="@color/blacktransparent" />
<corners android:radius="0dp" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:vlc="http://schemas.android.com/apk/res-auto" >
<data>
<import type="android.view.View" />
<variable
......@@ -39,57 +39,54 @@
type="org.videolan.vlc.gui.video.VideoListAdapter.ViewHolder" />
</data>
<android.support.v7.widget.CardView
android:id="@+id/card_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
vlc:cardElevation="4sp"
vlc:cardPreventCornerOverlap="false"
vlc:cardUseCompatPadding="true"
android:layout_marginBottom="@dimen/half_default_margin"
android:longClickable="true"
android:clickable="true"
android:focusable="true"
android:onClick="@{holder::onClick}" >
<LinearLayout
android:background="?attr/background_default"
android:id="@+id/layout_item"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical">
<RelativeLayout
android:layout_width="@dimen/grid_card_thumb_width"
android:layout_height="@dimen/grid_card_thumb_height"
android:layout_marginBottom="@dimen/default_margin"
android:paddingLeft="@dimen/half_default_margin"
android:paddingRight="@dimen/half_default_margin"
android:longClickable="true"
android:clickable="true"
android:focusable="true"
android:onClick="@{holder::onClick}">
<!-- Image loading is handled by org.videolan.vlc.gui.helpers.AsyncImageLoader.loadPicture() -->
<ImageView
android:id="@+id/ml_item_thumbnail"
android:layout_width="@dimen/grid_card_thumb_width"
android:layout_height="@dimen/grid_card_thumb_height"
android:background="?attr/background_default_darker"
android:scaleType="@{scaleType}"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
vlc:media="@{media}"
vlc:binding="@{holder.binding}"
android:src="@{cover}"/>
android:src="@{cover}"
android:background="?attr/background_default_darker" />
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/black_gradient" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:gravity="center_vertical"
android:orientation="horizontal">
android:orientation="horizontal"
android:layout_marginEnd="5dp"
android:layout_marginStart="5dp"
android:layout_above="@+id/video_meta">
<TextView
android:id="@+id/ml_item_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingStart="@dimen/very_small_margin"
android:paddingLeft="@dimen/very_small_margin"
android:ellipsize="end"
android:fontFamily="sans-serif-light"
android:fontFamily="sans-serif"
android:maxLines="2"
android:text="@{media.title}"
android:textColor="?attr/list_title"
android:textSize="@dimen/grid_card_title_text_size" />
android:textColor="@color/white"
android:textSize="@dimen/grid_card_title_text_size"
tools:targetApi="jelly_bean" />
<ImageView
android:id="@+id/item_more"
......@@ -99,72 +96,68 @@
android:contentDescription="@string/more_actions"
android:onClick="@{holder::onMoreClick}"
android:scaleType="fitCenter"
android:src="@drawable/ic_more" />
android:src="@drawable/ic_more_w" />
</LinearLayout>
<LinearLayout
android:id="@+id/video_meta"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="bottom"
android:orientation="vertical">
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginEnd="5dp"
android:layout_marginStart="5dp"
android:layout_above="@+id/ml_item_progress"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
<TextView
android:id="@+id/ml_item_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="@dimen/very_small_margin"
android:orientation="horizontal">
<TextView
android:id="@+id/ml_item_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:fontFamily="sans-serif-light"
android:gravity="left"
android:paddingLeft="@dimen/very_small_margin"
android:singleLine="true"
android:text="@{time}"
android:textColor="?attr/list_subtitle"
android:textSize="@dimen/grid_card_subtitle_text_size" />
<TextView
android:id="@+id/ml_item_resolution"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:fontFamily="sans-serif-light"
android:gravity="right"
android:paddingRight="@dimen/very_small_margin"
android:singleLine="true"
android:text="@{resolution}"
android:textColor="?attr/list_subtitle"
android:textSize="@dimen/grid_card_subtitle_text_size" />
</LinearLayout>
<ProgressBar
android:id="@+id/ml_item_progress"
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_weight="1"
android:fontFamily="sans-serif-light"
android:gravity="left"
android:paddingLeft="@dimen/very_small_margin"
android:singleLine="true"
android:text="@{time}"
android:textColor="@color/grey50"
android:textSize="@dimen/grid_card_subtitle_text_size" />
<TextView
android:id="@+id/ml_item_resolution"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="2dp"
android:layout_marginLeft="@dimen/very_small_margin"
android:layout_marginRight="@dimen/very_small_margin"
android:layout_marginTop="1dp"
android:focusable="false"
android:indeterminate="false"
android:max="@{max}"
android:maxHeight="2dip"
android:minHeight="2dip"
android:progress="@{progress}"
android:progressDrawable="?attr/gridview_progressbar"
android:visibility="@{max == 0 ? View.INVISIBLE : View.VISIBLE}" />
</LinearLayout>
android:layout_weight="1"
android:fontFamily="sans-serif-light"
android:gravity="end"
android:paddingRight="@dimen/very_small_margin"
android:paddingEnd="@dimen/very_small_margin"
android:singleLine="true"
android:text="@{resolution}"
android:textColor="@color/grey50"
android:textSize="@dimen/grid_card_subtitle_text_size" />
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
<ProgressBar
android:id="@+id/ml_item_progress"
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/very_small_margin"
android:layout_marginRight="@dimen/very_small_margin"
android:layout_marginTop="1dp"
android:layout_marginBottom="2dp"
android:focusable="false"
android:indeterminate="false"
android:max="@{max}"
android:maxHeight="2dip"
android:minHeight="2dip"
android:progress="@{progress}"
android:secondaryProgress="0"
android:progressDrawable="@drawable/gridview_progressbar"
android:visibility="@{progress == 0 ? View.INVISIBLE : View.VISIBLE}"
android:layout_alignParentBottom="true"
android:background="@color/transparent"/>
</RelativeLayout>
</layout>
......@@ -39,129 +39,114 @@
type="org.videolan.vlc.gui.video.VideoListAdapter.ViewHolder" />
</data>
<android.support.v7.widget.CardView
android:id="@+id/layout_item"
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="@dimen/very_small_margin"
vlc:cardElevation="2sp"
vlc:cardPreventCornerOverlap="false"
vlc:cardUseCompatPadding="true"
android:clickable="true"
android:focusable="true"
android:onClick="@{holder::onClick}"
android:longClickable="true">
<LinearLayout
android:longClickable="true" >
<!-- Image loading is handled by org.videolan.vlc.gui.helpers.AsyncImageLoader.loadPicture() -->
<ImageView
android:id="@+id/ml_item_thumbnail"
android:layout_width="120dp"
android:layout_height="75dp"
android:layout_margin="5dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:background="?attr/background_default_darker"
vlc:media="@{media}"
vlc:binding="@{holder.binding}"
android:scaleType="@{scaleType}"
android:src="@{cover}" />
<TextView
android:id="@+id/ml_item_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/background_default"
android:orientation="horizontal">
<!-- Image loading is handled by org.videolan.vlc.gui.helpers.AsyncImageLoader.loadPicture() -->
<ImageView
android:id="@+id/ml_item_thumbnail"
android:layout_width="120dp"
android:layout_height="75dp"
android:background="?attr/background_default_darker"
vlc:media="@{media}"
vlc:binding="@{holder.binding}"
android:scaleType="@{scaleType}"
android:src="@{cover}" />
<RelativeLayout
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/ml_item_thumbnail"
android:layout_toEndOf="@+id/ml_item_thumbnail"
android:layout_toLeftOf="@+id/item_more"
android:layout_toStartOf="@+id/item_more"
android:layout_above="@+id/ml_item_resolution"
android:ellipsize="end"
android:fontFamily="sans-serif-light"
android:gravity="center_vertical"
android:maxLines="2"
android:paddingLeft="@dimen/half_default_margin"
android:paddingStart="@dimen/half_default_margin"
android:text="@{media.title}"
android:textColor="?attr/list_title"
android:textSize="17sp" />
<ImageView
android:id="@+id/item_more"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_above="@+id/ml_item_time"
android:clickable="true"
android:contentDescription="@string/more_actions"
android:onClick="@{holder::onMoreClick}"
android:scaleType="fitCenter"
android:src="@drawable/ic_more" />
<TextView
android:id="@+id/ml_item_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/ml_item_thumbnail"
android:layout_toEndOf="@+id/ml_item_thumbnail"
android:layout_above="@+id/ml_item_progress"
android:background="@color/transparent"
android:fontFamily="sans-serif-light"
android:gravity="start"
android:layout_marginLeft="@dimen/half_default_margin"
android:layout_marginStart="@dimen/half_default_margin"
android:text="@{time}"
android:textColor="?attr/list_subtitle"
android:textSize="14sp" />
<TextView
android:id="@+id/ml_item_resolution"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_toRightOf="@+id/ml_item_time"
android:layout_toEndOf="@+id/ml_item_time"
android:layout_above="@+id/ml_item_progress"
android:layout_marginRight="@dimen/half_default_margin"
android:layout_marginEnd="@dimen/half_default_margin"
android:background="@color/transparent"
android:fontFamily="sans-serif-light"
android:gravity="end"
android:text="@{resolution}"
android:textColor="?attr/list_subtitle"
android:textSize="14sp" />
<ProgressBar
android:id="@+id/ml_item_progress"
style="@android:style/Widget.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/ml_item_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@+id/item_more"
android:ellipsize="end"
android:fontFamily="sans-serif-light"
android:gravity="center_vertical"
android:maxLines="2"
android:paddingLeft="@dimen/half_default_margin"
android:text="@{media.title}"
android:textColor="?attr/list_title"
android:textSize="17sp" />
<ImageView
android:id="@+id/item_more"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_above="@+id/info_layout"
android:clickable="true"
android:contentDescription="@string/more_actions"
android:onClick="@{holder::onMoreClick}"
android:scaleType="fitCenter"
android:src="@drawable/ic_more" />
<LinearLayout
android:id="@+id/info_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/ml_item_time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@color/transparent"
android:fontFamily="sans-serif-light"
android:gravity="left"
android:paddingLeft="@dimen/half_default_margin"
android:text="@{time}"
android:textColor="?attr/list_subtitle"
android:textSize="14sp" />
<TextView
android:id="@+id/ml_item_resolution"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/half_default_margin"
android:layout_weight="1"
android:background="@color/transparent"
android:fontFamily="sans-serif-light"
android:gravity="right"
android:text="@{resolution}"
android:textColor="?attr/list_subtitle"
android:textSize="14sp" />
</LinearLayout>
<ProgressBar
android:id="@+id/ml_item_progress"
style="@android:style/Widget.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="2dip"
android:layout_marginLeft="@dimen/half_default_margin"
android:layout_marginRight="@dimen/half_default_margin"
android:layout_marginTop="1dp"
android:focusable="false"
android:indeterminate="false"
android:max="@{max}"
android:maxHeight="2dip"
android:minHeight="2dip"
android:progress="@{progress}"
android:progressDrawable="?attr/gridview_progressbar"
android:visibility="@{max == 0 ? View.INVISIBLE : View.VISIBLE}" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/ml_item_thumbnail"
android:layout_toEndOf="@+id/ml_item_thumbnail"
android:layout_alignBottom="@+id/ml_item_thumbnail"
android:layout_marginBottom="2dip"
android:layout_marginLeft="@dimen/half_default_margin"
android:layout_marginRight="@dimen/half_default_margin"
android:layout_marginTop="1dp"
android:focusable="false"
android:indeterminate="false"
android:max="@{max}"
android:maxHeight="2dip"
android:minHeight="2dip"
android:progress="@{progress}"
android:progressDrawable="?attr/gridview_progressbar"
android:visibility="@{max == 0 ? View.INVISIBLE : View.VISIBLE}" />
</RelativeLayout>
</layout>
......@@ -4,4 +4,8 @@
<dimen name="images_margin_sides">60dp</dimen>
<dimen name="overlay_margin">5dp</dimen>
<dimen name="tab_layout_horizontal_padding">20dp</dimen>
<dimen name="grid_card_thumb_width">190dp</dimen>
<dimen name="grid_card_thumb_height">110dp</dimen>
<dimen name="default_margin">16dp</dimen>
<dimen name="half_default_margin">8dp</dimen>
</resources>
\ No newline at end of file
<resources>
<dimen name="grid_card_thumb_width">200dp</dimen>
<dimen name="grid_card_thumb_height">125dp</dimen>
<dimen name="grid_card_thumb_width">250dp</dimen>
<dimen name="grid_card_thumb_height">150dp</dimen>
<dimen name="grid_card_title_text_size">16sp</dimen>
<dimen name="grid_card_subtitle_text_size">12sp</dimen>
<dimen name="grid_card_vertical_spacing">10dp</dimen>
......
......@@ -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">160dp</dimen>
<dimen name="grid_card_thumb_width">180dp</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>
......@@ -48,8 +48,8 @@
<!-- Default -->
<dimen name="default_margin">16dp</dimen>
<dimen name="half_default_margin">8dp</dimen>
<dimen name="default_margin">8dp</dimen>
<dimen name="half_default_margin">4dp</dimen>
<dimen name="very_small_margin">4dp</dimen>
<dimen name="actionBarSize">56dp</dimen>
<dimen name="info_dialog_peek_height">120dip</dimen>
......
......@@ -62,7 +62,7 @@
<item name="ic_trash_small_normal">@drawable/ic_trash_small_normal</item>
<item name="shadow_top_9patch">@drawable/shadow_top</item>
<item name="shadow_bottom_9patch">@drawable/shadow_bottom</item>
<item name="gridview_progressbar">@drawable/gridview_progressbar_w</item>
<item name="gridview_progressbar">@drawable/gridview_progressbar</item>
<item name="progress_mini_player">@drawable/progress_mini_player</item>
<item name="advanced_options_style">@style/Theme.AppCompat.Light.Dialog</item>
<item name="rounded_bg">@drawable/rounded_corners_light</item>
......
......@@ -59,6 +59,7 @@ import org.videolan.vlc.gui.browser.MediaBrowserFragment;
import org.videolan.vlc.gui.helpers.UiTools;
import org.videolan.vlc.gui.view.AutoFitRecyclerView;
import org.videolan.vlc.gui.view.ContextMenuRecyclerView;
import org.videolan.vlc.gui.view.DividerItemDecoration;
import org.videolan.vlc.gui.view.SwipeRefreshLayout;
import org.videolan.vlc.interfaces.ISortable;
import org.videolan.vlc.media.MediaGroup;
......@@ -86,6 +87,7 @@ public class VideoGridFragment extends MediaBrowserFragment implements MediaUpda
private Handler mHandler = new Handler();
private VideoListAdapter mVideoAdapter;
private VideoGridAnimator mAnimator;
private DividerItemDecoration mDividerItemDecoration;
/* All subclasses of Fragment must include a public empty constructor. */
public VideoGridFragment() { }
......@@ -115,6 +117,7 @@ public class VideoGridFragment extends MediaBrowserFragment implements MediaUpda
mSwipeRefreshLayout.setColorSchemeResources(R.color.orange700);
mSwipeRefreshLayout.setOnRefreshListener(this);
mDividerItemDecoration = new DividerItemDecoration(v.getContext(), DividerItemDecoration.VERTICAL_LIST);
mGridView.addOnScrollListener(mScrollListener);
mGridView.setAdapter(mVideoAdapter);
return v;
......@@ -230,13 +233,16 @@ 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)));
mGridView.removeItemDecoration(mDividerItemDecoration);
} else {
mGridView.setNumColumns(1);
mGridView.addItemDecoration(mDividerItemDecoration);
}
if (mVideoAdapter.isListMode() != listMode)
mVideoAdapter.setListMode(listMode);
}
protected void playVideo(MediaWrapper media, boolean fromStart) {
media.removeFlags(MediaWrapper.MEDIA_FORCE_AUDIO);
VideoPlayerActivity.start(getActivity(), media.getUri(), fromStart);
......
......@@ -33,7 +33,6 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import org.videolan.medialibrary.media.MediaWrapper;
import org.videolan.vlc.BR;
......@@ -78,14 +77,6 @@ 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) {
mThumbnail = (ImageView) v.findViewById(R.id.ml_item_thumbnail);
int width = mFragment.mGridView.getColumnWidth();
int height = width*10/16;
mThumbnail.setLayoutParams(new LinearLayout.LayoutParams(width, height));
}
return new ViewHolder(v, listMode);
}
......@@ -94,7 +85,7 @@ public class VideoListAdapter extends RecyclerView.Adapter<VideoListAdapter.View
MediaWrapper media = getItem(position);
if (media == null)
return;
holder.binding.setVariable(BR.scaleType, ImageView.ScaleType.FIT_CENTER);
holder.binding.setVariable(BR.scaleType, ImageView.ScaleType.CENTER_CROP);
fillView(holder, media);
holder.binding.setVariable(BR.media, media);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment