[Android] Harmonize video thumb display size
Geoffrey Métais
git at videolan.org
Tue Apr 7 10:45:14 CEST 2015
vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Apr 2 16:43:53 2015 +0200| [0a92e7bb54a150b80c75893c7a661c636a3298ac] | committer: Geoffrey Métais
Harmonize video thumb display size
- Use resources values
- TV uses the dimension value
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=0a92e7bb54a150b80c75893c7a661c636a3298ac
---
vlc-android/res/layout/video_grid_card.xml | 2 +-
vlc-android/res/values-sw600dp/dimens.xml | 1 +
vlc-android/res/values/dimens.xml | 1 +
vlc-android/tv/res/values/dimens.xml | 4 +--
.../src/org/videolan/vlc/gui/tv/CardPresenter.java | 33 ++++++++------------
.../org/videolan/vlc/gui/tv/StringPresenter.java | 4 +--
6 files changed, 20 insertions(+), 25 deletions(-)
diff --git a/vlc-android/res/layout/video_grid_card.xml b/vlc-android/res/layout/video_grid_card.xml
index 7b6c59c..65036b2 100644
--- a/vlc-android/res/layout/video_grid_card.xml
+++ b/vlc-android/res/layout/video_grid_card.xml
@@ -18,7 +18,7 @@
<ImageView
android:id="@+id/ml_item_thumbnail"
- android:layout_width="match_parent"
+ android:layout_width="@dimen/grid_card_thumb_width"
android:layout_height="@dimen/grid_card_thumb_height"
android:layout_alignParentTop="true"
android:background="?attr/background_default_darker"
diff --git a/vlc-android/res/values-sw600dp/dimens.xml b/vlc-android/res/values-sw600dp/dimens.xml
index 981cc97..a654209 100644
--- a/vlc-android/res/values-sw600dp/dimens.xml
+++ b/vlc-android/res/values-sw600dp/dimens.xml
@@ -1,6 +1,7 @@
<resources>
<dimen name="grid_card_width">200dp</dimen>
<dimen name="grid_card_height">200dp</dimen>
+ <dimen name="grid_card_thumb_width">200dp</dimen>
<dimen name="grid_card_thumb_height">125dp</dimen>
<dimen name="grid_card_title_text_size">16sp</dimen>
<dimen name="grid_card_subtitle_text_size">12sp</dimen>
diff --git a/vlc-android/res/values/dimens.xml b/vlc-android/res/values/dimens.xml
index 8a080bf..bc5c8ba 100644
--- a/vlc-android/res/values/dimens.xml
+++ b/vlc-android/res/values/dimens.xml
@@ -7,6 +7,7 @@
<dimen name="listview_side_padding">5dp</dimen>
<dimen name="grid_card_width">160dp</dimen>
<dimen name="grid_card_height">160dp</dimen>
+ <dimen name="grid_card_thumb_width">160dp</dimen>
<dimen name="grid_card_thumb_height">100dp</dimen>
<dimen name="grid_card_title_text_size">12sp</dimen>
<dimen name="grid_card_subtitle_text_size">10sp</dimen>
diff --git a/vlc-android/tv/res/values/dimens.xml b/vlc-android/tv/res/values/dimens.xml
index 52648f7..753a78f 100644
--- a/vlc-android/tv/res/values/dimens.xml
+++ b/vlc-android/tv/res/values/dimens.xml
@@ -1,6 +1,6 @@
<resources>
- <dimen name="tv_card_width">192dp</dimen>
- <dimen name="tv_card_height">108dp</dimen>
+ <dimen name="grid_card_thumb_width">192dp</dimen>
+ <dimen name="grid_card_thumb_height">108dp</dimen>
<dimen name="tv_overscan_vertical">27dp</dimen>
<dimen name="tv_overscan_horizontal">48dp</dimen>
</resources>
\ No newline at end of file
diff --git a/vlc-android/tv/src/org/videolan/vlc/gui/tv/CardPresenter.java b/vlc-android/tv/src/org/videolan/vlc/gui/tv/CardPresenter.java
index 6913160..7e20418 100644
--- a/vlc-android/tv/src/org/videolan/vlc/gui/tv/CardPresenter.java
+++ b/vlc-android/tv/src/org/videolan/vlc/gui/tv/CardPresenter.java
@@ -25,6 +25,7 @@ import org.videolan.vlc.R;
import org.videolan.vlc.gui.audio.AudioUtil;
import org.videolan.vlc.gui.tv.browser.GridFragment;
import org.videolan.vlc.gui.tv.browser.MusicFragment;
+import org.videolan.vlc.util.BitmapUtil;
import android.content.Context;
import android.content.res.Resources;
@@ -53,8 +54,8 @@ public class CardPresenter extends Presenter {
sContext = context;
mRes = sContext.getResources();
sDefaultCardImage = mRes.getDrawable(R.drawable.background_cone);
- CARD_WIDTH = mRes.getDimensionPixelSize(R.dimen.tv_card_width);
- CARD_HEIGHT = mRes.getDimensionPixelSize(R.dimen.tv_card_height);
+ CARD_WIDTH = mRes.getDimensionPixelSize(R.dimen.grid_card_thumb_width);
+ CARD_HEIGHT = mRes.getDimensionPixelSize(R.dimen.grid_card_thumb_height);
}
static class ViewHolder extends Presenter.ViewHolder {
@@ -69,29 +70,21 @@ public class CardPresenter extends Presenter {
return mCardView;
}
- protected void updateCardViewImage(MediaWrapper MediaWrapper) {
+ protected void updateCardViewImage(MediaWrapper mediaWrapper) {
+ mCardView.getMainImageView().setScaleType(ImageView.ScaleType.CENTER);
Bitmap picture = null;
- if (MediaWrapper.getType() == MediaWrapper.TYPE_AUDIO) {
- picture = AudioUtil.getCover(sContext, MediaWrapper, 320);
- if (picture == null) {
- mCardView.getMainImageView().setScaleType(ImageView.ScaleType.CENTER);
+ if (mediaWrapper.getType() == mediaWrapper.TYPE_AUDIO) {
+ picture = AudioUtil.getCover(sContext, mediaWrapper, 320);
+ if (picture == null)
picture = BitmapFactory.decodeResource(mRes, R.drawable.ic_browser_audio_big_normal);
- } else
- mCardView.getMainImageView().setScaleType(ImageView.ScaleType.FIT_XY);
- } else if (MediaWrapper.getType() == MediaWrapper.TYPE_VIDEO) {
- picture = sMediaDatabase.getPicture(sContext, MediaWrapper.getLocation());
- if (picture == null){
- mCardView.getMainImageView().setScaleType(ImageView.ScaleType.CENTER);
+ } else if (mediaWrapper.getType() == mediaWrapper.TYPE_VIDEO) {
+ picture = BitmapUtil.getPictureFromCache(mediaWrapper);
+ if (picture == null)
picture = BitmapFactory.decodeResource(mRes, R.drawable.ic_browser_video_big_normal);
- } else
- mCardView.getMainImageView().setScaleType(ImageView.ScaleType.FIT_XY);
- } else if (MediaWrapper.getType() == MediaWrapper.TYPE_DIR) {
- mCardView.getMainImageView().setScaleType(ImageView.ScaleType.CENTER);
+ } else if (mediaWrapper.getType() == mediaWrapper.TYPE_DIR)
picture = BitmapFactory.decodeResource(mRes, R.drawable.ic_menu_network_big);
- } else {
- mCardView.getMainImageView().setScaleType(ImageView.ScaleType.CENTER);
+ else
picture = BitmapFactory.decodeResource(mRes, R.drawable.ic_browser_unknown_big_normal);
- }
if (picture != null && picture.getByteCount() > 4)
mCardView.setMainImage(new BitmapDrawable(mRes, picture));
else
diff --git a/vlc-android/tv/src/org/videolan/vlc/gui/tv/StringPresenter.java b/vlc-android/tv/src/org/videolan/vlc/gui/tv/StringPresenter.java
index b3dabcb..88e9bd4 100644
--- a/vlc-android/tv/src/org/videolan/vlc/gui/tv/StringPresenter.java
+++ b/vlc-android/tv/src/org/videolan/vlc/gui/tv/StringPresenter.java
@@ -45,8 +45,8 @@ public class StringPresenter extends Presenter {
if (res.getString(R.string.preferences).equals(item.toString())) {
tv.setBackground(res.getDrawable(R.drawable.ic_menu_preferences_big));
}
- tv.setHeight(res.getDimensionPixelSize(R.dimen.tv_card_height));
- tv.setWidth(res.getDimensionPixelSize(R.dimen.tv_card_width));
+ tv.setHeight(res.getDimensionPixelSize(R.dimen.grid_card_thumb_height));
+ tv.setWidth(res.getDimensionPixelSize(R.dimen.grid_card_thumb_width));
}
public void onUnbindViewHolder(ViewHolder viewHolder) {
More information about the Android
mailing list