From 5f871787a51aa8bf136b88d7bfd7b32f5247ab15 Mon Sep 17 00:00:00 2001 From: anthony restaino Date: Fri, 9 Jun 2017 20:47:53 -0400 Subject: [PATCH] Fixing equals and dashcode for download and history items --- .../lightning/database/HistoryItem.java | 25 +++++++++++-------- .../database/downloads/DownloadItem.java | 17 +++++++------ 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/acr/browser/lightning/database/HistoryItem.java b/app/src/main/java/acr/browser/lightning/database/HistoryItem.java index 9c0a041..b921b2a 100644 --- a/app/src/main/java/acr/browser/lightning/database/HistoryItem.java +++ b/app/src/main/java/acr/browser/lightning/database/HistoryItem.java @@ -120,27 +120,30 @@ public class HistoryItem implements Comparable { } @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; } diff --git a/app/src/main/java/acr/browser/lightning/database/downloads/DownloadItem.java b/app/src/main/java/acr/browser/lightning/database/downloads/DownloadItem.java index eb06c6e..f87e4a1 100644 --- a/app/src/main/java/acr/browser/lightning/database/downloads/DownloadItem.java +++ b/app/src/main/java/acr/browser/lightning/database/downloads/DownloadItem.java @@ -70,23 +70,24 @@ public class DownloadItem implements Comparable { } @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; }