Commit 8455c912 authored by gogerald's avatar gogerald Committed by Commit bot

Add compareBoolean for consistence

BUG=675686

Review-Url: https://codereview.chromium.org/2628463005
Cr-Commit-Position: refs/heads/master@{#442792}
parent 4dbdb0dd
......@@ -44,14 +44,19 @@ public class ApiCompatibilityUtils {
}
/**
* @see Long#compare(long, long)
* Compares two long values numerically. The value returned is identical to what would be
* returned by {@link Long#compare(long, long)} which is available since API level 19.
*/
public static int compareLong(long lhs, long rhs) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
return Long.compare(lhs, rhs);
} else {
return lhs < rhs ? -1 : (lhs == rhs ? 0 : 1);
}
return lhs < rhs ? -1 : (lhs == rhs ? 0 : 1);
}
/**
* Compares two boolean values. The value returned is identical to what would be returned by
* {@link Boolean#compare(boolean, boolean)} which is available since API level 19.
*/
public static int compareBoolean(boolean lhs, boolean rhs) {
return lhs == rhs ? 0 : lhs ? 1 : -1;
}
/**
......
......@@ -196,7 +196,7 @@ public class CardEditor extends EditorBase<AutofillPaymentInstrument>
AutofillAddress.checkAddressCompletionStatus(a) == AutofillAddress.COMPLETE;
boolean isBComplete =
AutofillAddress.checkAddressCompletionStatus(b) == AutofillAddress.COMPLETE;
return (isBComplete ? 1 : 0) - (isAComplete ? 1 : 0);
return ApiCompatibilityUtils.compareBoolean(isBComplete, isAComplete);
}
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment