[Android] Fix MediaLibraryItem equality check

Geoffrey Métais git at videolan.org
Wed Dec 7 18:59:38 CET 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Dec  7 18:59:16 2016 +0100| [d36144601b986e5df92fd790397c4b0f89a00c74] | committer: Geoffrey Métais

Fix MediaLibraryItem equality check

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

 .../src/org/videolan/medialibrary/media/MediaLibraryItem.java | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/medialibrary/src/org/videolan/medialibrary/media/MediaLibraryItem.java b/medialibrary/src/org/videolan/medialibrary/media/MediaLibraryItem.java
index c2a214a..d6462e2 100644
--- a/medialibrary/src/org/videolan/medialibrary/media/MediaLibraryItem.java
+++ b/medialibrary/src/org/videolan/medialibrary/media/MediaLibraryItem.java
@@ -2,6 +2,7 @@ package org.videolan.medialibrary.media;
 
 import android.os.Parcel;
 import android.os.Parcelable;
+import android.text.TextUtils;
 
 import org.videolan.medialibrary.Medialibrary;
 
@@ -72,6 +73,14 @@ public abstract class MediaLibraryItem implements Parcelable {
     }
 
     public boolean equals(MediaLibraryItem other) {
-        return this == other || (other != null && other.getItemType() == getItemType() && mId == other.getId());
+        if (this == other)
+            return true;
+        if (other == null)
+            return false;
+        if (getItemType() != other.getItemType())
+            return false;
+        if (getItemType() == TYPE_DUMMY)
+            return TextUtils.equals(getTitle(), other.getTitle());
+        return mId == other.getId();
     }
 }



More information about the Android mailing list