Refactor and optimize equals

- Remove multiple casts of obj

 - Simply use object equals on the streams because PlayQueueItem’s
   equals already compares urls
This commit is contained in:
Eric Xu 2021-05-21 00:33:11 -04:00 committed by Zhiheng Xu
parent 139ced885d
commit 57474e2dab
1 changed files with 3 additions and 11 deletions

View File

@ -500,22 +500,14 @@ public abstract class PlayQueue implements Serializable {
* we don't have to do anything with new queue.
* This method also gives a chance to track history of items in a queue in
* VideoDetailFragment without duplicating items from two identical queues
* */
*/
@Override
public boolean equals(@Nullable final Object obj) {
if (!(obj instanceof PlayQueue)
|| getStreams().size() != ((PlayQueue) obj).getStreams().size()) {
if (!(obj instanceof PlayQueue)) {
return false;
}
final PlayQueue other = (PlayQueue) obj;
for (int i = 0; i < getStreams().size(); i++) {
if (!getItem(i).getUrl().equals(other.getItem(i).getUrl())) {
return false;
}
}
return true;
return streams.equals(other.streams);
}
public boolean isDisposed() {