From 42fc2058e66dc49a9d0612e135755b493097afc3 Mon Sep 17 00:00:00 2001 From: Cole Faust Date: Mon, 27 Jan 2025 09:48:59 -0800 Subject: [PATCH] Fix errorprone warnings https://errorprone.info/bugpattern/BadInstanceof https://errorprone.info/bugpattern/CompareToZero Bug: 253827323 Test: Presubmits Flag: EXEMPT refactor Change-Id: If28f8f7f407b5b1e58911c58bb7d1b80f08c6114 --- src/com/android/launcher3/BubbleTextView.java | 2 +- src/com/android/launcher3/Workspace.java | 2 +- .../search/StringMatcherUtility.java | 22 +++++++++---------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java index 5224ee39d1..f801f7bf55 100644 --- a/src/com/android/launcher3/BubbleTextView.java +++ b/src/com/android/launcher3/BubbleTextView.java @@ -1106,7 +1106,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, public void applyDotState(ItemInfo itemInfo, boolean animate) { - if (mIcon instanceof FastBitmapDrawable) { + if (mIcon != null) { boolean wasDotted = mDotInfo != null; mDotInfo = mActivity.getDotInfoForItem(itemInfo); boolean isDotted = mDotInfo != null; diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 0e9c8610e6..09e33be34d 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -1750,7 +1750,7 @@ public class Workspace extends PagedView } final DragView dv; - if (contentView instanceof View) { + if (contentView != null) { dv = mDragController.startDrag( contentView, draggableView, diff --git a/src/com/android/launcher3/search/StringMatcherUtility.java b/src/com/android/launcher3/search/StringMatcherUtility.java index 7446314296..20b4d0b08a 100644 --- a/src/com/android/launcher3/search/StringMatcherUtility.java +++ b/src/com/android/launcher3/search/StringMatcherUtility.java @@ -127,17 +127,17 @@ public class StringMatcherUtility { if (query == null || target == null) { return false; } - switch (mCollator.compare(query, target)) { - case 0: - return true; - case -1: - // The target string can contain a modifier which would make it larger than - // the query string (even though the length is same). If the query becomes - // larger after appending a unicode character, it was originally a prefix of - // the target string and hence should match. - return mCollator.compare(query + MAX_UNICODE, target) > -1; - default: - return false; + int compare = mCollator.compare(query, target); + if (compare == 0) { + return true; + } else if (compare < 0) { + // The target string can contain a modifier which would make it larger than + // the query string (even though the length is same). If the query becomes + // larger after appending a unicode character, it was originally a prefix of + // the target string and hence should match. + return mCollator.compare(query + MAX_UNICODE, target) >= 0; + } else { + return false; } }