androidx.core.util.ObjectsCompat Java Examples

The following examples show how to use androidx.core.util.ObjectsCompat. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ColumnSortCallback.java    From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@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;
}
 
Example #2
Source File: SubtitleCollapsingToolbarLayout.java    From collapsingtoolbarlayout-subtitle with Apache License 2.0 6 votes vote down vote up
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();
}
 
Example #3
Source File: ColumnSortCallback.java    From TableView with MIT License 6 votes vote down vote up
@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;
}
 
Example #4
Source File: AppBarLayout.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #5
Source File: CollapsingToolbarLayout.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
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();
}
 
Example #6
Source File: MaterialShapeDrawable.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example #7
Source File: NextcloudRequest.java    From Android-SingleSignOn with GNU General Public License v3.0 6 votes vote down vote up
@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;
}
 
Example #8
Source File: Triple.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
@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);
}
 
Example #9
Source File: Optional.java    From HaoReader with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #10
Source File: FrescoVitoImage2Spec.java    From fresco with MIT License 5 votes vote down vote up
@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());
}
 
Example #11
Source File: FrescoControllerImpl.java    From fresco with MIT License 5 votes vote down vote up
@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();
    }
  }
}
 
Example #12
Source File: ChapterBean.java    From HaoReader with GNU General Public License v3.0 4 votes vote down vote up
@Override
public int hashCode() {
    return ObjectsCompat.hashCode(durChapterUrl);
}
 
Example #13
Source File: Optional.java    From HaoReader with GNU General Public License v3.0 2 votes vote down vote up
/**
 * 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);
}