com.bumptech.glide.util.Util.isValidDimensions()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(10.5k)|赞(0)|评价(0)|浏览(263)

本文整理了Java中com.bumptech.glide.util.Util.isValidDimensions()方法的一些代码示例,展示了Util.isValidDimensions()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.isValidDimensions()方法的具体详情如下:
包路径:com.bumptech.glide.util.Util
类名称:Util
方法名:isValidDimensions

Util.isValidDimensions介绍

[英]Returns true if width and height are both > 0 and/or equal to Target#SIZE_ORIGINAL.
[中]如果宽度和高度均大于0和/或等于目标#大小_,则返回true。

代码示例

代码示例来源:origin: bumptech/glide

  1. public final boolean isValidOverride() {
  2. return Util.isValidDimensions(overrideWidth, overrideHeight);
  3. }

代码示例来源:origin: bumptech/glide

  1. /**
  2. * Creates a new {@code CustomTarget} that will return the given {@code width} and {@code height}
  3. * as the requested size (unless overridden by
  4. * {@link com.bumptech.glide.request.RequestOptions#override(int)} in the request).
  5. *
  6. * @param width The requested width (>= 0, or == Target.SIZE_ORIGINAL).
  7. * @param height The requested height (>= 0, or == Target.SIZE_ORIGINAL).
  8. */
  9. public CustomTarget(int width, int height) {
  10. if (!Util.isValidDimensions(width, height)) {
  11. throw new IllegalArgumentException(
  12. "Width and height must both be > 0 or Target#SIZE_ORIGINAL, but given" + " width: "
  13. + width + " and height: " + height);
  14. }
  15. this.width = width;
  16. this.height = height;
  17. }

代码示例来源:origin: bumptech/glide

  1. /**
  2. * Immediately calls the given callback with the sizes given in the constructor.
  3. *
  4. * @param cb {@inheritDoc}
  5. */
  6. @Override
  7. public final void getSize(@NonNull SizeReadyCallback cb) {
  8. if (!Util.isValidDimensions(width, height)) {
  9. throw new IllegalArgumentException(
  10. "Width and height must both be > 0 or Target#SIZE_ORIGINAL, but given" + " width: "
  11. + width + " and height: " + height + ", either provide dimensions in the constructor"
  12. + " or call override()");
  13. }
  14. cb.onSizeReady(width, height);
  15. }

代码示例来源:origin: Piasy/BigImageViewer

  1. /**
  2. * Immediately calls the given callback with the sizes given in the constructor.
  3. *
  4. * @param cb {@inheritDoc}
  5. */
  6. @Override
  7. public final void getSize(@NonNull SizeReadyCallback cb) {
  8. if (!Util.isValidDimensions(width, height)) {
  9. throw new IllegalArgumentException(
  10. "Width and height must both be > 0 or Target#SIZE_ORIGINAL, but given" + " width: "
  11. + width + " and height: " + height + ", either provide dimensions in the constructor"
  12. + " or call override()");
  13. }
  14. cb.onSizeReady(width, height);
  15. }

代码示例来源:origin: Piasy/BigImageViewer

  1. /**
  2. * Immediately calls the given callback with the sizes given in the constructor.
  3. *
  4. * @param cb {@inheritDoc}
  5. */
  6. @Override
  7. public final void getSize(@NonNull SizeReadyCallback cb) {
  8. if (!Util.isValidDimensions(width, height)) {
  9. throw new IllegalArgumentException(
  10. "Width and height must both be > 0 or Target#SIZE_ORIGINAL, but given" + " width: "
  11. + width + " and height: " + height + ", either provide dimensions in the constructor"
  12. + " or call override()");
  13. }
  14. cb.onSizeReady(width, height);
  15. }

代码示例来源:origin: bumptech/glide

  1. @NonNull
  2. @Override
  3. public final Resource<Bitmap> transform(
  4. @NonNull Context context, @NonNull Resource<Bitmap> resource, int outWidth, int outHeight) {
  5. if (!Util.isValidDimensions(outWidth, outHeight)) {
  6. throw new IllegalArgumentException(
  7. "Cannot apply transformation on width: " + outWidth + " or height: " + outHeight
  8. + " less than or equal to zero and not Target.SIZE_ORIGINAL");
  9. }
  10. BitmapPool bitmapPool = Glide.get(context).getBitmapPool();
  11. Bitmap toTransform = resource.get();
  12. int targetWidth = outWidth == Target.SIZE_ORIGINAL ? toTransform.getWidth() : outWidth;
  13. int targetHeight = outHeight == Target.SIZE_ORIGINAL ? toTransform.getHeight() : outHeight;
  14. Bitmap transformed = transform(bitmapPool, toTransform, targetWidth, targetHeight);
  15. final Resource<Bitmap> result;
  16. if (toTransform.equals(transformed)) {
  17. result = resource;
  18. } else {
  19. result = BitmapResource.obtain(transformed, bitmapPool);
  20. }
  21. return result;
  22. }

代码示例来源:origin: wasabeef/glide-transformations

  1. @NonNull
  2. @Override
  3. public final Resource<Bitmap> transform(@NonNull Context context, @NonNull Resource<Bitmap> resource,
  4. int outWidth, int outHeight) {
  5. if (!Util.isValidDimensions(outWidth, outHeight)) {
  6. throw new IllegalArgumentException(
  7. "Cannot apply transformation on width: " + outWidth + " or height: " + outHeight
  8. + " less than or equal to zero and not Target.SIZE_ORIGINAL");
  9. }
  10. BitmapPool bitmapPool = Glide.get(context).getBitmapPool();
  11. Bitmap toTransform = resource.get();
  12. int targetWidth = outWidth == Target.SIZE_ORIGINAL ? toTransform.getWidth() : outWidth;
  13. int targetHeight = outHeight == Target.SIZE_ORIGINAL ? toTransform.getHeight() : outHeight;
  14. Bitmap transformed = transform(context.getApplicationContext(), bitmapPool, toTransform, targetWidth, targetHeight);
  15. final Resource<Bitmap> result;
  16. if (toTransform.equals(transformed)) {
  17. result = resource;
  18. } else {
  19. result = BitmapResource.obtain(transformed, bitmapPool);
  20. }
  21. return result;
  22. }

代码示例来源:origin: bumptech/glide

  1. startTime = LogTime.getLogTime();
  2. if (model == null) {
  3. if (Util.isValidDimensions(overrideWidth, overrideHeight)) {
  4. width = overrideWidth;
  5. height = overrideHeight;
  6. if (Util.isValidDimensions(overrideWidth, overrideHeight)) {
  7. onSizeReady(overrideWidth, overrideHeight);
  8. } else {

代码示例来源:origin: bumptech/glide

  1. if (Util.isValidDimensions(overrideWidth, overrideHeight)
  2. && !errorBuilder.isValidOverride()) {
  3. errorOverrideWidth = requestOptions.getOverrideWidth();

代码示例来源:origin: bumptech/glide

  1. if (Util.isValidDimensions(overrideWidth, overrideHeight)
  2. && !thumbnailBuilder.isValidOverride()) {
  3. thumbOverrideWidth = requestOptions.getOverrideWidth();

代码示例来源:origin: guolindev/giffun

  1. /**
  2. * Overrides the {@link Target}'s width and height with the given values. This is useful almost exclusively for
  3. * thumbnails, and should only be used when you both need a very specific sized image and when it is impossible or
  4. * impractical to return that size from {@link Target#getSize(com.bumptech.glide.request.target.SizeReadyCallback)}.
  5. *
  6. * @param width The width in pixels to use to load the resource.
  7. * @param height The height in pixels to use to load the resource.
  8. * @return This request builder.
  9. */
  10. public GenericRequestBuilder<ModelType, DataType, ResourceType, TranscodeType> override(int width, int height) {
  11. if (!Util.isValidDimensions(width, height)) {
  12. throw new IllegalArgumentException("Width and height must be Target#SIZE_ORIGINAL or > 0");
  13. }
  14. this.overrideWidth = width;
  15. this.overrideHeight = height;
  16. return this;
  17. }

代码示例来源:origin: guolindev/giffun

  1. /**
  2. * Immediately calls the given callback with the sizes given in the constructor.
  3. *
  4. * @param cb {@inheritDoc}
  5. */
  6. @Override
  7. public final void getSize(SizeReadyCallback cb) {
  8. if (!Util.isValidDimensions(width, height)) {
  9. throw new IllegalArgumentException("Width and height must both be > 0 or Target#SIZE_ORIGINAL, but given"
  10. + " width: " + width + " and height: " + height + ", either provide dimensions in the constructor"
  11. + " or call override()");
  12. }
  13. cb.onSizeReady(width, height);
  14. }
  15. }

代码示例来源:origin: guolindev/giffun

  1. @Override
  2. public final Resource<Bitmap> transform(Resource<Bitmap> resource, int outWidth, int outHeight) {
  3. if (!Util.isValidDimensions(outWidth, outHeight)) {
  4. throw new IllegalArgumentException("Cannot apply transformation on width: " + outWidth + " or height: "
  5. + outHeight + " less than or equal to zero and not Target.SIZE_ORIGINAL");
  6. }
  7. Bitmap toTransform = resource.get();
  8. int targetWidth = outWidth == Target.SIZE_ORIGINAL ? toTransform.getWidth() : outWidth;
  9. int targetHeight = outHeight == Target.SIZE_ORIGINAL ? toTransform.getHeight() : outHeight;
  10. Bitmap transformed = transform(bitmapPool, toTransform, targetWidth, targetHeight);
  11. final Resource<Bitmap> result;
  12. if (toTransform.equals(transformed)) {
  13. result = resource;
  14. } else {
  15. result = BitmapResource.obtain(transformed, bitmapPool);
  16. }
  17. return result;
  18. }

代码示例来源:origin: guolindev/giffun

  1. if (Util.isValidDimensions(overrideWidth, overrideHeight)
  2. && !Util.isValidDimensions(thumbnailRequestBuilder.overrideWidth,
  3. thumbnailRequestBuilder.overrideHeight)) {
  4. thumbnailRequestBuilder.override(overrideWidth, overrideHeight);

代码示例来源:origin: guolindev/giffun

  1. /**
  2. * {@inheritDoc}
  3. */
  4. @Override
  5. public void begin() {
  6. startTime = LogTime.getLogTime();
  7. if (model == null) {
  8. onException(null);
  9. return;
  10. }
  11. status = Status.WAITING_FOR_SIZE;
  12. if (Util.isValidDimensions(overrideWidth, overrideHeight)) {
  13. onSizeReady(overrideWidth, overrideHeight);
  14. } else {
  15. target.getSize(this);
  16. }
  17. if (!isComplete() && !isFailed() && canNotifyStatusChanged()) {
  18. target.onLoadStarted(getPlaceholderDrawable());
  19. }
  20. if (Log.isLoggable(TAG, Log.VERBOSE)) {
  21. logV("finished run method in " + LogTime.getElapsedMillis(startTime));
  22. }
  23. }

代码示例来源:origin: mozilla-tw/Rocket

  1. public final boolean isValidOverride() {
  2. return Util.isValidDimensions(overrideWidth, overrideHeight);
  3. }

代码示例来源:origin: smarek/Simple-Dilbert

  1. /**
  2. * Creates a new {@code CustomTarget} that will return the given {@code width} and {@link @code}
  3. * as the requested size (unless overridden by
  4. * {@link com.bumptech.glide.request.RequestOptions#override(int)} in the request).
  5. *
  6. * @param width The requested width (>= 0, or == Target.SIZE_ORIGINAL).
  7. * @param height The requested height (>= 0, or == Target.SIZE_ORIGINAL).
  8. */
  9. public CustomTarget(int width, int height) {
  10. if (!Util.isValidDimensions(width, height)) {
  11. throw new IllegalArgumentException(
  12. "Width and height must both be > 0 or Target#SIZE_ORIGINAL, but given" + " width: "
  13. + width + " and height: " + height);
  14. }
  15. this.width = width;
  16. this.height = height;
  17. }

代码示例来源:origin: mozilla-tw/Rocket

  1. /**
  2. * Immediately calls the given callback with the sizes given in the constructor.
  3. *
  4. * @param cb {@inheritDoc}
  5. */
  6. @Override
  7. public final void getSize(SizeReadyCallback cb) {
  8. if (!Util.isValidDimensions(width, height)) {
  9. throw new IllegalArgumentException(
  10. "Width and height must both be > 0 or Target#SIZE_ORIGINAL, but given" + " width: "
  11. + width + " and height: " + height + ", either provide dimensions in the constructor"
  12. + " or call override()");
  13. }
  14. cb.onSizeReady(width, height);
  15. }

代码示例来源:origin: mozilla-tw/Rocket

  1. @Override
  2. public final Resource<Bitmap> transform(
  3. Context context, Resource<Bitmap> resource, int outWidth, int outHeight) {
  4. if (!Util.isValidDimensions(outWidth, outHeight)) {
  5. throw new IllegalArgumentException(
  6. "Cannot apply transformation on width: " + outWidth + " or height: " + outHeight
  7. + " less than or equal to zero and not Target.SIZE_ORIGINAL");
  8. }
  9. BitmapPool bitmapPool = Glide.get(context).getBitmapPool();
  10. Bitmap toTransform = resource.get();
  11. int targetWidth = outWidth == Target.SIZE_ORIGINAL ? toTransform.getWidth() : outWidth;
  12. int targetHeight = outHeight == Target.SIZE_ORIGINAL ? toTransform.getHeight() : outHeight;
  13. Bitmap transformed = transform(bitmapPool, toTransform, targetWidth, targetHeight);
  14. final Resource<Bitmap> result;
  15. if (toTransform.equals(transformed)) {
  16. result = resource;
  17. } else {
  18. result = BitmapResource.obtain(transformed, bitmapPool);
  19. }
  20. return result;
  21. }

代码示例来源:origin: mozilla-tw/Rocket

  1. startTime = LogTime.getLogTime();
  2. if (model == null) {
  3. if (Util.isValidDimensions(overrideWidth, overrideHeight)) {
  4. width = overrideWidth;
  5. height = overrideHeight;
  6. if (Util.isValidDimensions(overrideWidth, overrideHeight)) {
  7. onSizeReady(overrideWidth, overrideHeight);
  8. } else {

相关文章