[Android] Fix icons display

Geoffrey Métais git at videolan.org
Wed Apr 4 18:35:59 CEST 2018


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Mar 28 13:37:56 2018 +0200| [5591ff60960045509e3a68a10c2daa33559e4b6b] | committer: Geoffrey Métais

Fix icons display

> https://code.videolan.org/videolan/vlc-android/commit/5591ff60960045509e3a68a10c2daa33559e4b6b
---

 .../src/org/videolan/vlc/gui/tv/CardPresenter.java   |  4 ++--
 vlc-android/src/org/videolan/vlc/gui/tv/TvUtil.java  |  9 ++++++++-
 .../vlc/gui/tv/browser/VerticalGridActivity.java     | 20 ++++++++------------
 3 files changed, 18 insertions(+), 15 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/CardPresenter.java b/vlc-android/src/org/videolan/vlc/gui/tv/CardPresenter.java
index bd7efecf4..8991cfde4 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/CardPresenter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/CardPresenter.java
@@ -76,7 +76,7 @@ public class CardPresenter extends Presenter {
         }
 
         void updateCardViewImage(MediaLibraryItem mediaLibraryItem) {
-            if (mediaLibraryItem.getItemType() == MediaLibraryItem.TYPE_DUMMY) {
+            if (TextUtils.isEmpty(mediaLibraryItem.getArtworkMrl())) {
                 mCardView.getMainImageView().setScaleType(ImageView.ScaleType.FIT_CENTER);
                 mCardView.setMainImage(new BitmapDrawable(mCardView.getResources(), getDefaultImage(mediaLibraryItem)));
             } else AsyncImageLoader.loadPicture(mCardView, mediaLibraryItem);
@@ -86,7 +86,7 @@ public class CardPresenter extends Presenter {
             Bitmap picture;
             final Resources res = mCardView.getResources();
             if (mediaLibraryItem.getItemType() == MediaLibraryItem.TYPE_MEDIA && ((MediaWrapper) mediaLibraryItem).getType() == MediaWrapper.TYPE_DIR) {
-                MediaWrapper mediaWrapper = (MediaWrapper) mediaLibraryItem;
+                final MediaWrapper mediaWrapper = (MediaWrapper) mediaLibraryItem;
                 if (TextUtils.equals(mediaWrapper.getUri().getScheme(), "file"))
                     picture = BitmapFactory.decodeResource(res, R.drawable.ic_menu_folder_big);
                 else
diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/TvUtil.java b/vlc-android/src/org/videolan/vlc/gui/tv/TvUtil.java
index 2f4ac6fc3..7d4ded5d9 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/TvUtil.java
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/TvUtil.java
@@ -51,6 +51,7 @@ import org.videolan.vlc.gui.helpers.UiTools;
 import org.videolan.vlc.gui.tv.audioplayer.AudioPlayerActivity;
 import org.videolan.vlc.gui.tv.browser.VerticalGridActivity;
 import org.videolan.vlc.media.MediaUtils;
+import org.videolan.vlc.util.AndroidDevices;
 import org.videolan.vlc.util.Constants;
 
 import java.lang.ref.WeakReference;
@@ -215,14 +216,20 @@ public class TvUtil {
             case MediaLibraryItem.TYPE_GENRE:
                 return R.drawable.ic_genre_big;
             case MediaLibraryItem.TYPE_MEDIA:
-                if (((MediaWrapper)mediaLibraryItem).getType() == MediaWrapper.TYPE_VIDEO)
+                final MediaWrapper mw = (MediaWrapper) mediaLibraryItem;
+                if (mw.getType() == MediaWrapper.TYPE_VIDEO)
                     return R.drawable.ic_browser_video_big_normal;
+                if (mw.getType() == MediaWrapper.TYPE_DIR
+                        && TextUtils.equals(AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY, mw.getLocation()))
+                    return R.drawable.ic_menu_folder_big;
                 else
                     return R.drawable.ic_song_big;
             case MediaLibraryItem.TYPE_DUMMY:
                 final long id = mediaLibraryItem.getId();
                 if (id == Constants.HEADER_VIDEO) {
                     return R.drawable.ic_video_collection_big;
+                } else if (id == Constants.HEADER_DIRECTORIES) {
+                    return R.drawable.ic_menu_folder_big;
                 } else if (id == Constants.HEADER_NETWORK) {
                     return R.drawable.ic_menu_network_big;
                 } else if (id == Constants.HEADER_STREAM) {
diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/browser/VerticalGridActivity.java b/vlc-android/src/org/videolan/vlc/gui/tv/browser/VerticalGridActivity.java
index c96c32198..8644f77eb 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/browser/VerticalGridActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/browser/VerticalGridActivity.java
@@ -54,26 +54,22 @@ public class VerticalGridActivity extends BaseTvActivity implements BrowserActiv
         mEmptyView = findViewById(R.id.tv_fragment_empty);
         if (savedInstanceState == null) {
             long type = getIntent().getLongExtra(MainTvActivity.BROWSER_TYPE, -1);
-            if (type == Constants.HEADER_VIDEO)
-                mFragment = new VideoBrowserFragment();
-            else if (type == Constants.HEADER_CATEGORIES)
+            if (type == Constants.HEADER_VIDEO) mFragment = new VideoBrowserFragment();
+            else if (type == Constants.HEADER_CATEGORIES) {
                 if (getIntent().getLongExtra(Constants.AUDIO_CATEGORY, Constants.CATEGORY_SONGS) == Constants.CATEGORY_SONGS &&
-                    VLCApplication.getMLInstance().getAudioCount() > GRID_LIMIT) {
+                        VLCApplication.getMLInstance().getAudioCount() > GRID_LIMIT) {
                     mFragment = new SongsBrowserFragment();
                 } else {
                     mFragment = new MusicFragment();
                     Bundle args = new Bundle();
                     args.putParcelable(Constants.AUDIO_ITEM, getIntent().getParcelableExtra(Constants.AUDIO_ITEM));
-                    ((Fragment)mFragment).setArguments(args);
+                    ((Fragment) mFragment).setArguments(args);
                 }
-            else if (type == Constants.HEADER_NETWORK) {
+            } else if (type == Constants.HEADER_NETWORK) {
                 Uri uri = getIntent().getData();
-                if (uri == null)
-                    uri = getIntent().getParcelableExtra(SortedBrowserFragment.KEY_URI);
-                if (uri == null)
-                    mFragment = new BrowserGridFragment();
-                else
-                    mFragment = new NetworkBrowserFragment();
+                if (uri == null) uri = getIntent().getParcelableExtra(SortedBrowserFragment.KEY_URI);
+                if (uri == null) mFragment = new BrowserGridFragment();
+                else mFragment = new NetworkBrowserFragment();
             } else if (type == Constants.HEADER_DIRECTORIES)
                 mFragment = new DirectoryBrowserFragment();
             else {



More information about the Android mailing list