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