Fix errorprone warnings
https://errorprone.info/bugpattern/BadInstanceof
https://errorprone.info/bugpattern/CompareToZero
Bug: 253827323
Test: Presubmits
Flag: EXEMPT refactor
Change-Id: If28f8f7f407b5b1e58911c58bb7d1b80f08c6114
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java
index 5224ee3..f801f7b 100644
--- a/src/com/android/launcher3/BubbleTextView.java
+++ b/src/com/android/launcher3/BubbleTextView.java
@@ -1106,7 +1106,7 @@
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 0e9c861..09e33be 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -1750,7 +1750,7 @@
}
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 7446314..20b4d0b 100644
--- a/src/com/android/launcher3/search/StringMatcherUtility.java
+++ b/src/com/android/launcher3/search/StringMatcherUtility.java
@@ -127,17 +127,17 @@
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;
}
}