[Android] Avoid useless list manipulation

Geoffrey Métais git at videolan.org
Fri Dec 18 12:03:41 CET 2015


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Dec 18 11:27:48 2015 +0100| [392d63c920d86eb1f58e593567a708923e5d4862] | committer: Geoffrey Métais

Avoid useless list manipulation

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

 vlc-android/src/org/videolan/vlc/gui/HistoryAdapter.java | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/HistoryAdapter.java b/vlc-android/src/org/videolan/vlc/gui/HistoryAdapter.java
index 28a13ad..8b426a7 100644
--- a/vlc-android/src/org/videolan/vlc/gui/HistoryAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/HistoryAdapter.java
@@ -52,9 +52,11 @@ public class HistoryAdapter extends RecyclerView.Adapter<HistoryAdapter.ViewHold
             int position = getAdapterPosition();
             MediaWrapper mw = mMediaList.get(position);
 
-            mMediaList.remove(position);
-            mMediaList.add(0, mw);
-            notifyItemMoved(position, 0);
+            if (position != 0) {
+                mMediaList.remove(position);
+                mMediaList.add(0, mw);
+                notifyItemMoved(position, 0);
+            }
             MediaUtils.openMedia(v.getContext(), mw);
         }
     }



More information about the Android mailing list