[Android] TV: Fix video list display

Geoffrey Métais git at videolan.org
Mon Mar 7 13:41:09 CET 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Mar  7 13:36:51 2016 +0100| [c2778245ed8d76b951b96c653747ffe76d5725f2] | committer: Geoffrey Métais

TV: Fix video list display

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

 vlc-android/src/org/videolan/vlc/gui/tv/MainTvActivity.java | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/MainTvActivity.java b/vlc-android/src/org/videolan/vlc/gui/tv/MainTvActivity.java
index 658512c..b935f8f 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/MainTvActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/MainTvActivity.java
@@ -292,7 +292,8 @@ public class MainTvActivity extends BaseTvActivity implements IVideoBrowser, OnI
     }
 
     public void updateList() {
-        mVideoAdapter.notifyArrayItemRangeChanged(0, mVideoAdapter.size());
+        if (mVideoAdapter != null)
+            mVideoAdapter.notifyArrayItemRangeChanged(0, mVideoAdapter.size());
     }
 
     @Override
@@ -419,24 +420,21 @@ public class MainTvActivity extends BaseTvActivity implements IVideoBrowser, OnI
             final HeaderItem videoHeader = new HeaderItem(HEADER_VIDEO, getString(R.string.video));
             // Empty item to launch grid activity
             mVideoAdapter.add(new CardPresenter.SimpleCard(0, "All videos", R.drawable.ic_video_collection_big));
-            int size;
             // Update video section
             if (!videoList.isEmpty()) {
-                size = videoList.size();
-                if (NUM_ITEMS_PREVIEW < size)
-                    size = NUM_ITEMS_PREVIEW;
-                final int total = size;
+                final int size = Math.min(NUM_ITEMS_PREVIEW, videoList.size());
                 mRootContainer.post(new Runnable() {
                     @Override
                     public void run() {
                         MediaWrapper item;
-                        for (int i = 0; i < total; ++i) {
+                        for (int i = 0; i < size; ++i) {
                             item = videoList.get(i);
                             mVideoAdapter.add(item);
                             mVideoIndex.put(item.getLocation(), Integer.valueOf(i));
                         }
                     }
                 });
+                mVideoAdapter.notifyArrayItemRangeChanged(0, size);
             }
             mRowsAdapter.add(new ListRow(videoHeader, mVideoAdapter));
 



More information about the Android mailing list