Java源码示例:androidx.core.util.ObjectsCompat
示例1
@Override
public boolean areContentsTheSame(int oldItemPosition, int newItemPosition) {
// Control for precaution from IndexOutOfBoundsException
if (mOldCellItems.size() > oldItemPosition && mNewCellItems.size() > newItemPosition) {
if (mOldCellItems.get(oldItemPosition).size() > mColumnPosition && mNewCellItems.get
(newItemPosition).size() > mColumnPosition) {
// Compare contents
Object oldContent = mOldCellItems.get(oldItemPosition).get(mColumnPosition)
.getContent();
Object newContent = mNewCellItems.get(newItemPosition).get(mColumnPosition)
.getContent();
return ObjectsCompat.equals(oldContent, newContent);
}
}
return false;
}
示例2
WindowInsetsCompat onWindowInsetChanged(@NonNull final WindowInsetsCompat insets) {
WindowInsetsCompat newInsets = null;
if (ViewCompat.getFitsSystemWindows(this)) {
// If we're set to fit system windows, keep the insets
newInsets = insets;
}
// If our insets have changed, keep them and invalidate the scroll ranges...
if (!ObjectsCompat.equals(lastInsets, newInsets)) {
lastInsets = newInsets;
requestLayout();
}
// Consume the insets. This is done so that child views with fitSystemWindows=true do not
// get the default padding functionality from View
return insets.consumeSystemWindowInsets();
}
示例3
@Override
public boolean areContentsTheSame(int oldItemPosition, int newItemPosition) {
// Control for precaution from IndexOutOfBoundsException
if (mOldCellItems.size() > oldItemPosition && mNewCellItems.size() > newItemPosition) {
if (mOldCellItems.get(oldItemPosition).size() > mColumnPosition && mNewCellItems.get
(newItemPosition).size() > mColumnPosition) {
// Compare contents
Object oldContent = mOldCellItems.get(oldItemPosition).get(mColumnPosition)
.getContent();
Object newContent = mNewCellItems.get(newItemPosition).get(mColumnPosition)
.getContent();
return ObjectsCompat.equals(oldContent, newContent);
}
}
return false;
}
示例4
WindowInsetsCompat onWindowInsetChanged(final WindowInsetsCompat insets) {
WindowInsetsCompat newInsets = null;
if (ViewCompat.getFitsSystemWindows(this)) {
// If we're set to fit system windows, keep the insets
newInsets = insets;
}
// If our insets have changed, keep them and trigger a layout...
if (!ObjectsCompat.equals(lastInsets, newInsets)) {
lastInsets = newInsets;
updateWillNotDraw();
requestLayout();
}
return insets;
}
示例5
WindowInsetsCompat onWindowInsetChanged(@NonNull final WindowInsetsCompat insets) {
WindowInsetsCompat newInsets = null;
if (ViewCompat.getFitsSystemWindows(this)) {
// If we're set to fit system windows, keep the insets
newInsets = insets;
}
// If our insets have changed, keep them and invalidate the scroll ranges...
if (!ObjectsCompat.equals(lastInsets, newInsets)) {
lastInsets = newInsets;
requestLayout();
}
// Consume the insets. This is done so that child views with fitSystemWindows=true do not
// get the default padding functionality from View
return insets.consumeSystemWindowInsets();
}
示例6
private boolean updateTintFilter() {
PorterDuffColorFilter originalTintFilter = tintFilter;
PorterDuffColorFilter originalStrokeTintFilter = strokeTintFilter;
tintFilter =
calculateTintFilter(
drawableState.tintList,
drawableState.tintMode,
fillPaint,
/* requiresElevationOverlay= */ true);
strokeTintFilter =
calculateTintFilter(
drawableState.strokeTintList,
drawableState.tintMode,
strokePaint,
/* requiresElevationOverlay= */ false);
if (drawableState.useTintColorForShadow) {
shadowRenderer.setShadowColor(
drawableState.tintList.getColorForState(getState(), Color.TRANSPARENT));
}
return !ObjectsCompat.equals(originalTintFilter, tintFilter)
|| !ObjectsCompat.equals(originalStrokeTintFilter, strokeTintFilter);
}
示例7
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof NextcloudRequest)) {
return false;
}
NextcloudRequest rq = (NextcloudRequest)obj;
boolean equal;
equal = ObjectsCompat.equals(this.accountName, rq.accountName);
equal &= ObjectsCompat.equals(this.header, rq.header);
equal &= ObjectsCompat.equals(this.method, rq.method);
equal &= ObjectsCompat.equals(this.packageName, rq.packageName);
equal &= ObjectsCompat.equals(this.parameter, rq.parameter);
equal &= ObjectsCompat.equals(this.requestBody, rq.requestBody);
equal &= ObjectsCompat.equals(this.token, rq.token);
equal &= ObjectsCompat.equals(this.url, rq.url);
equal &= ObjectsCompat.equals(this.followRedirects, rq.followRedirects);
return equal;
}
示例8
@Override
public boolean equals(Object o) {
if (!(o instanceof Triple)) {
return false;
}
Triple<?, ?, ?> t = (Triple<?, ?, ?>) o;
return ObjectsCompat.equals(t.a, a) && ObjectsCompat.equals(t.b, b) && ObjectsCompat.equals(t.c, c);
}
示例9
/**
* Indicates whether some other object is "equal to" this Optional. The
* other object is considered equal if:
* <ul>
* <li>it is also an {@code Optional} and;
* <li>both instances have no value present or;
* <li>the present values are "equal to" each other via {@code equals()}.
* </ul>
*
* @param obj an object to be tested for equality
* @return {code true} if the other object is "equal to" this object
* otherwise {@code false}
*/
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof Optional)) {
return false;
}
Optional<?> other = (Optional<?>) obj;
return ObjectsCompat.equals(value, other.value);
}
示例10
@ShouldUpdate(onMount = true)
static boolean shouldUpdate(
@Prop(optional = true) Diff<Uri> uri,
@Prop(optional = true) Diff<ImageSource> imageSource,
@Prop(optional = true) Diff<ImageOptions> imageOptions,
@Prop(optional = true, resType = ResType.FLOAT) Diff<Float> imageAspectRatio,
@Prop(optional = true) Diff<ImageListener> imageListener) {
return !ObjectsCompat.equals(uri.getPrevious(), uri.getNext())
|| !ObjectsCompat.equals(imageSource.getPrevious(), imageSource.getNext())
|| !ObjectsCompat.equals(imageOptions.getPrevious(), imageOptions.getNext())
|| !ObjectsCompat.equals(imageAspectRatio.getPrevious(), imageAspectRatio.getNext())
|| !ObjectsCompat.equals(imageListener.getPrevious(), imageListener.getNext());
}
示例11
@Override
public FrescoState onPrepare(
final FrescoState frescoState,
final @Nullable Uri uri,
final @Nullable MultiUri multiUri,
final ImageOptions imageOptions,
final @Nullable Object callerContext,
final Resources resources,
final @Nullable ImageListener imageListener) {
if (FrescoSystrace.isTracing()) {
FrescoSystrace.beginSection("FrescoControllerImpl#onPrepare");
}
try {
final boolean stateHasSameProps =
frescoState != null
&& ObjectsCompat.equals(uri, frescoState.getUri())
&& ObjectsCompat.equals(multiUri, frescoState.getMultiUri())
&& ObjectsCompat.equals(imageOptions, frescoState.getImageOptions())
&& (mFrescoContext.getExperiments().shouldDiffCallerContext()
? ObjectsCompat.equals(callerContext, frescoState.getCallerContext())
: true);
// If state is recycled from another component we must create a new one
return stateHasSameProps
? frescoState
: createState(uri, multiUri, imageOptions, callerContext, resources, imageListener);
} finally {
if (FrescoSystrace.isTracing()) {
FrescoSystrace.endSection();
}
}
}
示例12
@Override
public int hashCode() {
return ObjectsCompat.hashCode(durChapterUrl);
}
示例13
/**
* Returns the hash code value of the present value, if any, or 0 (zero) if
* no value is present.
*
* @return hash code value of the present value or 0 if no value is present
*/
@Override
public int hashCode() {
return ObjectsCompat.hashCode(value);
}