Java Code Examples for androidx.core.util.Preconditions#checkNotNull()

The following examples show how to use androidx.core.util.Preconditions#checkNotNull() . 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: StickerPackDownloadJob.java    From mollyim-android with GNU General Public License v3.0 6 votes vote down vote up
private StickerPackDownloadJob(@NonNull Parameters parameters,
                               @NonNull String packId,
                               @NonNull String packKey,
                               boolean isReferencePack,
                               boolean notify)
{
  super(parameters);

  Preconditions.checkNotNull(packId);
  Preconditions.checkNotNull(packKey);

  this.packId          = packId;
  this.packKey         = packKey;
  this.isReferencePack = isReferencePack;
  this.notify          = notify;
}
 
Example 2
Source File: CreateKbsPinViewModel.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
@MainThread
public void confirm() {
  KbsPin          pin      = Preconditions.checkNotNull(this.getUserEntry().getValue());
  PinKeyboardType keyboard = Preconditions.checkNotNull(this.getKeyboard().getValue());

  if (PinValidityChecker.valid(pin.toString())) {
    events.setValue(new NavigationEvent(pin, keyboard));
  } else {
    errors.setValue(PinErrorEvent.WEAK_PIN);
  }
}
 
Example 3
Source File: BaseMotionStrategy.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
@Override
public final MotionSpec getCurrentMotionSpec() {
  if (motionSpec != null) {
    return motionSpec;
  }

  if (defaultMotionSpec == null) {
    defaultMotionSpec =
        MotionSpec.createFromResource(
            context,
            getDefaultMotionSpecResource());
  }

  return Preconditions.checkNotNull(defaultMotionSpec);
}
 
Example 4
Source File: FloatingActionButtonImpl.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
void onPaddingUpdated(@NonNull Rect padding) {
  Preconditions.checkNotNull(contentBackground, "Didn't initialize content background");
  if (shouldAddPadding()) {
    InsetDrawable insetDrawable = new InsetDrawable(
        contentBackground, padding.left, padding.top, padding.right, padding.bottom);
    shadowViewDelegate.setBackgroundDrawable(insetDrawable);
  } else {
    shadowViewDelegate.setBackgroundDrawable(contentBackground);
  }
}
 
Example 5
Source File: Permissions.java    From permission-bitte with MIT License 4 votes vote down vote up
Permissions(Map<String, PermissionResult> map) {
  this.map = Preconditions.checkNotNull(map);
}
 
Example 6
Source File: Permission.java    From permission-bitte with MIT License 4 votes vote down vote up
Permission(String name, PermissionResult result) {
  this.name = Preconditions.checkNotNull(name);
  this.result = Preconditions.checkNotNull(result);
}
 
Example 7
Source File: Permission.java    From permission-bitte with MIT License 4 votes vote down vote up
protected Permission(Parcel in) {
  this.name = Preconditions.checkNotNull(in.readString());
  this.result = PermissionResult.values()[in.readInt()];
}
 
Example 8
Source File: ResourcesCompat.java    From Carbon with Apache License 2.0 3 votes vote down vote up
/**
 * Returns a font Typeface associated with a particular resource ID asynchronously.
 * <p>
 * Prior to API level 23, font resources with more than one font in a family will only load the
 * font closest to a regular weight typeface.
 * </p>
 *
 * @param context      A context to retrieve the Resources from.
 * @param id           The desired resource identifier of a {@link Typeface}, as generated by the aapt
 *                     tool. This integer encodes the package, type, and resource entry. The value 0 is an
 *                     invalid identifier.
 * @param fontCallback A callback to receive async fetching of this font. The callback will be
 *                     triggered on the UI thread.
 * @param handler      A handler for the thread the callback should be called on. If null, the
 *                     callback will be called on the UI thread.
 * @throws NotFoundException Throws NotFoundException if the given ID does not exist.
 */
public static void getFont(@NonNull Context context, @FontRes int id,
                           @NonNull androidx.core.content.res.ResourcesCompat.FontCallback fontCallback, @Nullable Handler handler)
        throws NotFoundException {
    Preconditions.checkNotNull(fontCallback);
    if (context.isRestricted()) {
        fontCallback.callbackFailAsync(
                FontRequestCallback.FAIL_REASON_SECURITY_VIOLATION, handler);
        return;
    }
    loadFont(context, id, new TypedValue(), Typeface.NORMAL, 400, fontCallback, handler,
            false /* isXmlRequest */);
}