Merge "TIF: Add equals() and hashCode() for comparisons" into nyc-dev
This commit is contained in:
@@ -20,9 +20,12 @@ import android.annotation.NonNull;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Parcel;
|
import android.os.Parcel;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import com.android.internal.util.Preconditions;
|
import com.android.internal.util.Preconditions;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encapsulates the format of tracks played in {@link TvInputService}.
|
* Encapsulates the format of tracks played in {@link TvInputService}.
|
||||||
*/
|
*/
|
||||||
@@ -245,6 +248,37 @@ public final class TvTrackInfo implements Parcelable {
|
|||||||
dest.writeBundle(mExtra);
|
dest.writeBundle(mExtra);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(o instanceof TvTrackInfo)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
TvTrackInfo obj = (TvTrackInfo) o;
|
||||||
|
return TextUtils.equals(mId, obj.mId)
|
||||||
|
&& mType == obj.mType
|
||||||
|
&& TextUtils.equals(mLanguage, obj.mLanguage)
|
||||||
|
&& TextUtils.equals(mDescription, obj.mDescription)
|
||||||
|
&& Objects.equals(mExtra, obj.mExtra)
|
||||||
|
&& (mType == TYPE_AUDIO
|
||||||
|
? mAudioChannelCount == obj.mAudioChannelCount
|
||||||
|
&& mAudioSampleRate == obj.mAudioSampleRate
|
||||||
|
: (mType == TYPE_VIDEO
|
||||||
|
? mVideoWidth == obj.mVideoWidth
|
||||||
|
&& mVideoHeight == obj.mVideoHeight
|
||||||
|
&& mVideoFrameRate == obj.mVideoFrameRate
|
||||||
|
&& mVideoPixelAspectRatio == obj.mVideoPixelAspectRatio : true));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hashCode(mId);
|
||||||
|
}
|
||||||
|
|
||||||
public static final Parcelable.Creator<TvTrackInfo> CREATOR =
|
public static final Parcelable.Creator<TvTrackInfo> CREATOR =
|
||||||
new Parcelable.Creator<TvTrackInfo>() {
|
new Parcelable.Creator<TvTrackInfo>() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user