[Android] Show cover and title in "now playing card" on TV
Geoffrey Métais
git at videolan.org
Tue Dec 1 15:42:00 CET 2015
vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Dec 1 13:24:32 2015 +0100| [2c6aac35dd3d706761c0af9aa88d14bd703353ce] | committer: Geoffrey Métais
Show cover and title in "now playing card" on TV
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=2c6aac35dd3d706761c0af9aa88d14bd703353ce
---
.../src/org/videolan/vlc/gui/tv/CardPresenter.java | 20 +++++++++++++----
.../org/videolan/vlc/gui/tv/MainTvActivity.java | 23 ++++++++++++++------
2 files changed, 32 insertions(+), 11 deletions(-)
diff --git a/vlc-android/flavors/tv/src/org/videolan/vlc/gui/tv/CardPresenter.java b/vlc-android/flavors/tv/src/org/videolan/vlc/gui/tv/CardPresenter.java
index bac0ca9..c0d5f9b 100644
--- a/vlc-android/flavors/tv/src/org/videolan/vlc/gui/tv/CardPresenter.java
+++ b/vlc-android/flavors/tv/src/org/videolan/vlc/gui/tv/CardPresenter.java
@@ -32,13 +32,13 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
-import org.videolan.vlc.media.MediaDatabase;
-import org.videolan.vlc.media.MediaWrapper;
import org.videolan.vlc.R;
import org.videolan.vlc.gui.helpers.AsyncImageLoader;
import org.videolan.vlc.gui.helpers.AudioUtil;
-import org.videolan.vlc.gui.tv.browser.MusicFragment;
import org.videolan.vlc.gui.helpers.BitmapUtil;
+import org.videolan.vlc.gui.tv.browser.MusicFragment;
+import org.videolan.vlc.media.MediaDatabase;
+import org.videolan.vlc.media.MediaWrapper;
public class CardPresenter extends Presenter {
@@ -113,8 +113,9 @@ public class CardPresenter extends Presenter {
holder.updateCardViewImage(MediaWrapper);
} else if (item instanceof SimpleCard){
SimpleCard card = (SimpleCard) item;
+ Bitmap image = card.getImage();
holder.mCardView.setTitleText(card.getName());
- holder.updateCardViewImage(mRes.getDrawable(card.getImageId()));
+ holder.updateCardViewImage(image != null ? new BitmapDrawable(image) : mRes.getDrawable(card.getImageId()));
}else if (item instanceof String){
holder.mCardView.setTitleText((String) item);
holder.updateCardViewImage(sDefaultCardImage);
@@ -134,6 +135,13 @@ public class CardPresenter extends Presenter {
int id;
int imageId;
String name;
+ Bitmap image;
+
+ SimpleCard(int id, String name, Bitmap image){
+ this.id = id;
+ this.name = name;
+ this.image = image;
+ }
SimpleCard(int id, String name, int imageId){
this.id = id;
@@ -157,6 +165,10 @@ public class CardPresenter extends Presenter {
this.imageId = imageId;
}
+ public Bitmap getImage() {
+ return image;
+ }
+
public String getName() {
return name;
}
diff --git a/vlc-android/flavors/tv/src/org/videolan/vlc/gui/tv/MainTvActivity.java b/vlc-android/flavors/tv/src/org/videolan/vlc/gui/tv/MainTvActivity.java
index 056b3cc..1e485bd 100644
--- a/vlc-android/flavors/tv/src/org/videolan/vlc/gui/tv/MainTvActivity.java
+++ b/vlc-android/flavors/tv/src/org/videolan/vlc/gui/tv/MainTvActivity.java
@@ -47,20 +47,22 @@ import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ProgressBar;
-import org.videolan.vlc.media.MediaDatabase;
-import org.videolan.vlc.media.MediaLibrary;
-import org.videolan.vlc.media.MediaWrapper;
import org.videolan.vlc.PlaybackService;
import org.videolan.vlc.R;
-import org.videolan.vlc.media.Thumbnailer;
import org.videolan.vlc.VLCApplication;
+import org.videolan.vlc.gui.helpers.AudioUtil;
+import org.videolan.vlc.gui.preferences.PreferencesActivity;
import org.videolan.vlc.gui.tv.audioplayer.AudioPlayerActivity;
import org.videolan.vlc.gui.tv.browser.BaseTvActivity;
import org.videolan.vlc.gui.tv.browser.MusicFragment;
import org.videolan.vlc.gui.tv.browser.VerticalGridActivity;
-import org.videolan.vlc.gui.preferences.PreferencesActivity;
import org.videolan.vlc.gui.video.VideoListHandler;
import org.videolan.vlc.interfaces.IVideoBrowser;
+import org.videolan.vlc.media.MediaDatabase;
+import org.videolan.vlc.media.MediaLibrary;
+import org.videolan.vlc.media.MediaUtils;
+import org.videolan.vlc.media.MediaWrapper;
+import org.videolan.vlc.media.Thumbnailer;
import org.videolan.vlc.util.AndroidDevices;
import org.videolan.vlc.util.Permissions;
import org.videolan.vlc.util.VLCInstance;
@@ -356,8 +358,15 @@ public class MainTvActivity extends BaseTvActivity implements IVideoBrowser, OnI
//Music sections
mCategoriesAdapter = new ArrayObjectAdapter(new CardPresenter(mContext));
final HeaderItem musicHeader = new HeaderItem(HEADER_CATEGORIES, getString(R.string.audio));
- if (mService != null && mService.hasMedia() && !mService.canSwitchToVideo())
- mCategoriesAdapter.add(new CardPresenter.SimpleCard(MusicFragment.CATEGORY_NOW_PLAYING, getString(R.string.music_now_playing), R.drawable.ic_nowplaying_big));
+ if (mService != null && mService.hasMedia() && !mService.canSwitchToVideo()) {
+ MediaWrapper mw = mService.getCurrentMediaWrapper();
+ String display = MediaUtils.getMediaTitle(mw) + " - " + MediaUtils.getMediaReferenceArtist(MainTvActivity.this, mw);
+ Bitmap cover = AudioUtil.getCover(MainTvActivity.this, mw, VLCApplication.getAppResources().getDimensionPixelSize(R.dimen.grid_card_thumb_width));
+ if (cover != null)
+ mCategoriesAdapter.add(new CardPresenter.SimpleCard(MusicFragment.CATEGORY_NOW_PLAYING, display, cover));
+ else
+ mCategoriesAdapter.add(new CardPresenter.SimpleCard(MusicFragment.CATEGORY_NOW_PLAYING, display, R.drawable.ic_nowplaying_big));
+ }
mCategoriesAdapter.add(new CardPresenter.SimpleCard(MusicFragment.CATEGORY_ARTISTS, getString(R.string.artists), R.drawable.ic_artist_big));
mCategoriesAdapter.add(new CardPresenter.SimpleCard(MusicFragment.CATEGORY_ALBUMS, getString(R.string.albums), R.drawable.ic_album_big));
mCategoriesAdapter.add(new CardPresenter.SimpleCard(MusicFragment.CATEGORY_GENRES, getString(R.string.genres), R.drawable.ic_genre_big));
More information about the Android
mailing list