[Android] Fix MediaWrapper equals()

Geoffrey Métais git at videolan.org
Mon Mar 6 16:53:41 CET 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Mar  6 16:25:52 2017 +0100| [41f690e23339c7defb7957c22431790b25edf05c] | committer: Geoffrey Métais

Fix MediaWrapper equals()

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

 .../src/org/videolan/medialibrary/media/MediaWrapper.java      | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/medialibrary/src/org/videolan/medialibrary/media/MediaWrapper.java b/medialibrary/src/org/videolan/medialibrary/media/MediaWrapper.java
index 6af268b..0459bee 100644
--- a/medialibrary/src/org/videolan/medialibrary/media/MediaWrapper.java
+++ b/medialibrary/src/org/videolan/medialibrary/media/MediaWrapper.java
@@ -181,15 +181,15 @@ public class MediaWrapper extends MediaLibraryItem implements Parcelable {
     public boolean equals(Object obj) {
         if (this == obj)
             return true;
-        long otherId = ((MediaWrapper)obj).getId();
+        if (!(obj instanceof MediaLibraryItem) || ((MediaLibraryItem) obj).getItemType() != TYPE_MEDIA)
+            return false;
+        long otherId = ((MediaWrapper) obj).getId();
         if (otherId != 0 && getId() != 0 && otherId == getId())
             return true;
-        Uri otherUri = ((MediaWrapper)obj).getUri();
+        Uri otherUri = ((MediaWrapper) obj).getUri();
         if (mUri == null || otherUri == null)
             return false;
-        if (mUri == otherUri)
-            return true;
-        return mUri.equals(otherUri);
+        return mUri == otherUri || mUri.equals(otherUri);
     }
 
     private void init(Media media) {



More information about the Android mailing list