From 4e4707b524936e702829856f0419b02198ae95cd Mon Sep 17 00:00:00 2001 From: anthony restaino Date: Sat, 24 Jun 2017 22:19:40 -0400 Subject: [PATCH] Cleaning up code --- .../browser/lightning/database/HistoryItem.java | 16 ++++++---------- .../database/downloads/DownloadItem.java | 9 +++------ .../search/engine/BaseSearchEngine.java | 6 +++--- .../search/suggestions/BaseSuggestionsModel.java | 1 + .../lightning/utils/StringBuilderUtils.java | 8 ++++---- 5 files changed, 17 insertions(+), 23 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 7913864..69d61a1 100644 --- a/app/src/main/java/acr/browser/lightning/database/HistoryItem.java +++ b/app/src/main/java/acr/browser/lightning/database/HistoryItem.java @@ -12,11 +12,8 @@ import acr.browser.lightning.utils.Preconditions; public class HistoryItem implements Comparable { @NonNull private String mUrl = ""; - @NonNull private String mTitle = ""; - @NonNull private String mFolder = ""; - @Nullable private Bitmap mBitmap = null; private int mImageId = 0; @@ -126,13 +123,12 @@ public class HistoryItem implements Comparable { HistoryItem that = (HistoryItem) o; - 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 && + mPosition == that.mPosition && + mIsFolder == that.mIsFolder && + mUrl.equals(that.mUrl) && + mTitle.equals(that.mTitle) && + mFolder.equals(that.mFolder); } 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 b45abb6..6585f35 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 @@ -11,9 +11,7 @@ import acr.browser.lightning.utils.Preconditions; public class DownloadItem implements Comparable { @NonNull private String mUrl = ""; - @NonNull private String mTitle = ""; - @NonNull private String mContentSize = ""; public DownloadItem() {} @@ -76,10 +74,9 @@ public class DownloadItem implements Comparable { DownloadItem that = (DownloadItem) o; - if (!mUrl.equals(that.mUrl)) return false; - if (!mTitle.equals(that.mTitle)) return false; - - return mContentSize.equals(that.mContentSize); + return mUrl.equals(that.mUrl) && + mTitle.equals(that.mTitle) && + mContentSize.equals(that.mContentSize); } diff --git a/app/src/main/java/acr/browser/lightning/search/engine/BaseSearchEngine.java b/app/src/main/java/acr/browser/lightning/search/engine/BaseSearchEngine.java index 2844ee9..92cb5e9 100644 --- a/app/src/main/java/acr/browser/lightning/search/engine/BaseSearchEngine.java +++ b/app/src/main/java/acr/browser/lightning/search/engine/BaseSearchEngine.java @@ -21,9 +21,9 @@ public class BaseSearchEngine { @NonNull private final String mQueryUrl; @StringRes private final int mTitleRes; - public BaseSearchEngine(@NonNull String iconUrl, - @NonNull String queryUrl, - @StringRes int titleRes) { + BaseSearchEngine(@NonNull String iconUrl, + @NonNull String queryUrl, + @StringRes int titleRes) { Preconditions.checkNonNull(iconUrl); Preconditions.checkNonNull(queryUrl); diff --git a/app/src/main/java/acr/browser/lightning/search/suggestions/BaseSuggestionsModel.java b/app/src/main/java/acr/browser/lightning/search/suggestions/BaseSuggestionsModel.java index 34abde6..961715f 100644 --- a/app/src/main/java/acr/browser/lightning/search/suggestions/BaseSuggestionsModel.java +++ b/app/src/main/java/acr/browser/lightning/search/suggestions/BaseSuggestionsModel.java @@ -151,6 +151,7 @@ public abstract class BaseSuggestionsModel { return language; } + @NonNull private static final Interceptor REWRITE_CACHE_CONTROL_INTERCEPTOR = new Interceptor() { @Override public Response intercept(@NonNull Chain chain) throws IOException { diff --git a/app/src/main/java/acr/browser/lightning/utils/StringBuilderUtils.java b/app/src/main/java/acr/browser/lightning/utils/StringBuilderUtils.java index 0c66f8a..77c5bb7 100644 --- a/app/src/main/java/acr/browser/lightning/utils/StringBuilderUtils.java +++ b/app/src/main/java/acr/browser/lightning/utils/StringBuilderUtils.java @@ -8,7 +8,7 @@ import android.support.annotation.NonNull; * API equality with the {@link String} * API. */ -public class StringBuilderUtils { +class StringBuilderUtils { private static final String SPACE = " "; private static final String EMPTY = ""; @@ -21,9 +21,9 @@ public class StringBuilderUtils { * @param toReplace the string to replace. * @param replacement the replacement string. */ - public static void replace(@NonNull StringBuilder stringBuilder, - @NonNull String toReplace, - @NonNull String replacement) { + static void replace(@NonNull StringBuilder stringBuilder, + @NonNull String toReplace, + @NonNull String replacement) { int index = stringBuilder.indexOf(toReplace); if (index >= 0) { stringBuilder.replace(index, index + toReplace.length(), replacement);