Fixing equals and dashcode for download and history items

This commit is contained in:
anthony restaino 2017-06-09 20:47:53 -04:00
parent 8a58fe9f8c
commit 5f871787a5
2 changed files with 23 additions and 19 deletions

View File

@ -120,27 +120,30 @@ public class HistoryItem implements Comparable<HistoryItem> {
}
@Override
public boolean equals(@Nullable Object object) {
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (this == object) return true;
if (object == null) return false;
if (!(object instanceof HistoryItem)) return false;
HistoryItem that = (HistoryItem) o;
HistoryItem that = (HistoryItem) object;
if (mImageId != that.mImageId) return false;
if (mPosition != that.mPosition) return false;
if (mIsFolder != that.mIsFolder) return false;
if (!mUrl.equals(that.mUrl)) return false;
if (!mTitle.equals(that.mTitle)) return false;
return mFolder.equals(that.mFolder);
return mImageId == that.mImageId &&
this.mTitle.equals(that.mTitle) && this.mUrl.equals(that.mUrl) &&
this.mFolder.equals(that.mFolder);
}
@Override
public int hashCode() {
int result = mUrl.hashCode();
result = 31 * result + mImageId;
result = 31 * result + mTitle.hashCode();
result = 32 * result + mFolder.hashCode();
result = 31 * result + mFolder.hashCode();
result = 31 * result + mImageId;
result = 31 * result + mPosition;
result = 31 * result + (mIsFolder ? 1 : 0);
return result;
}

View File

@ -70,23 +70,24 @@ public class DownloadItem implements Comparable<DownloadItem> {
}
@Override
public boolean equals(@Nullable Object object) {
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (this == object) return true;
if (object == null) return false;
if (!(object instanceof DownloadItem)) return false;
DownloadItem that = (DownloadItem) o;
DownloadItem that = (DownloadItem) object;
if (!mUrl.equals(that.mUrl)) return false;
if (!mTitle.equals(that.mTitle)) return false;
return mContentSize.equals(that.mContentSize);
return this.mTitle.equals(that.mTitle) && this.mUrl.equals(that.mUrl)
&& this.mContentSize.equals(that.mContentSize);
}
@Override
public int hashCode() {
int result = mUrl.hashCode();
result = 31 * result + mTitle.hashCode();
result = 31 * result + mContentSize.hashCode();
return result;
}