Browse Source

Fixing equals and dashcode for download and history items

master
anthony restaino 8 years ago
parent
commit
5f871787a5
  1. 25
      app/src/main/java/acr/browser/lightning/database/HistoryItem.java
  2. 17
      app/src/main/java/acr/browser/lightning/database/downloads/DownloadItem.java

25
app/src/main/java/acr/browser/lightning/database/HistoryItem.java

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

17
app/src/main/java/acr/browser/lightning/database/downloads/DownloadItem.java

@ -70,23 +70,24 @@ public class DownloadItem implements Comparable<DownloadItem> {
} }
@Override @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; DownloadItem that = (DownloadItem) o;
if (object == null) return false;
if (!(object instanceof DownloadItem)) return false;
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 @Override
public int hashCode() { public int hashCode() {
int result = mUrl.hashCode(); int result = mUrl.hashCode();
result = 31 * result + mTitle.hashCode(); result = 31 * result + mTitle.hashCode();
result = 31 * result + mContentSize.hashCode();
return result; return result;
} }

Loading…
Cancel
Save