当前位置: 首页>>代码示例>>Java>>正文


Java Util类代码示例

本文整理汇总了Java中com.bumptech.glide.util.Util的典型用法代码示例。如果您正苦于以下问题:Java Util类的具体用法?Java Util怎么用?Java Util使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Util类属于com.bumptech.glide.util包,在下文中一共展示了Util类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: get

import com.bumptech.glide.util.Util; //导入依赖的package包/类
public RequestManager get(Fragment fragment) {
  Preconditions.checkNotNull(fragment.getActivity(),
        "You cannot start a load on a fragment before it is attached or after it is destroyed");
  if (Util.isOnBackgroundThread()) {
    return get(fragment.getActivity().getApplicationContext());
  } else {
    FragmentManager fm = fragment.getChildFragmentManager();
    return supportFragmentGet(fragment.getActivity(), fm, fragment);
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:RequestManagerRetriever.java

示例2: clear

import com.bumptech.glide.util.Util; //导入依赖的package包/类
/**
 * Cancel any pending loads Glide may have for the target and free any resources (such as
 * {@link Bitmap}s) that may have been loaded for the target so they may be reused.
 *
 * @param target The Target to cancel loads for.
 */
public void clear(@Nullable final Target<?> target) {
  if (target == null) {
    return;
  }

  if (Util.isOnMainThread()) {
    untrackOrDelegate(target);
  } else {
    mainHandler.post(new Runnable() {
      @Override
      public void run() {
        clear(target);
      }
    });
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:RequestManager.java

示例3: release

import com.bumptech.glide.util.Util; //导入依赖的package包/类
private void release(boolean isRemovedFromQueue) {
  Util.assertMainThread();
  cbs.clear();
  key = null;
  engineResource = null;
  resource = null;
  if (ignoredCallbacks != null) {
    ignoredCallbacks.clear();
  }
  hasLoadFailed = false;
  isCancelled = false;
  hasResource = false;
  decodeJob.release(isRemovedFromQueue);
  decodeJob = null;
  exception = null;
  dataSource = null;
  pool.release(this);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:EngineJob.java

示例4: equals

import com.bumptech.glide.util.Util; //导入依赖的package包/类
@SuppressWarnings({"PMD.SimplifyBooleanReturns", "RedundantIfStatement"})
@Override
public boolean equals(Object o) {
  if (this == o) {
    return true;
  }
  if (o == null || getClass() != o.getClass()) {
    return false;
  }

  MediaStoreSignature that = (MediaStoreSignature) o;

  if (dateModified != that.dateModified) {
    return false;
  }
  if (orientation != that.orientation) {
    return false;
  }
  if (!Util.bothNullOrEqual(mimeType, that.mimeType)) {
    return false;
  }
  return true;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:MediaStoreSignature.java

示例5: get

import com.bumptech.glide.util.Util; //导入依赖的package包/类
@Override
@Nullable
public Bitmap get(int width, int height, Bitmap.Config config) {
  final int size = Util.getBitmapByteSize(width, height, config);
  Key key = keyPool.get(size);

  Integer possibleSize = sortedSizes.ceilingKey(size);
  if (possibleSize != null && possibleSize != size && possibleSize <= size * MAX_SIZE_MULTIPLE) {
    keyPool.offer(key);
    key = keyPool.get(possibleSize);
  }

  // Do a get even if we know we don't have a bitmap so that the key moves to the front in the
  // lru pool
  final Bitmap result = groupedMap.get(key);
  if (result != null) {
    result.reconfigure(width, height, config);
    decrementBitmapOfSize(possibleSize);
  }

  return result;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:SizeStrategy.java

示例6: into

import com.bumptech.glide.util.Util; //导入依赖的package包/类
/**
 * Sets the {@link ImageView} the resource will be loaded into, cancels any existing loads into
 * the view, and frees any resources Glide may have previously loaded into the view so they may be
 * reused.
 *
 * @see RequestManager#clear(Target)
 *
 * @param view The view to cancel previous loads for and load the new resource into.
 * @return The
 * {@link com.bumptech.glide.request.target.Target} used to wrap the given {@link ImageView}.
 */
public Target<TranscodeType> into(ImageView view) {
  Util.assertMainThread();
  Preconditions.checkNotNull(view);

  if (!requestOptions.isTransformationSet()
      && requestOptions.isTransformationAllowed()
      && view.getScaleType() != null) {
    if (requestOptions.isLocked()) {
      requestOptions = requestOptions.clone();
    }
    switch (view.getScaleType()) {
      case CENTER_CROP:
        requestOptions.optionalCenterCrop();
        break;
      case CENTER_INSIDE:
        requestOptions.optionalCenterInside();
        break;
      case FIT_CENTER:
      case FIT_START:
      case FIT_END:
        requestOptions.optionalFitCenter();
        break;
      case FIT_XY:
        requestOptions.optionalCenterInside();
        break;
      case CENTER:
      case MATRIX:
      default:
        // Do nothing.
    }
  }

  return into(context.buildImageViewTarget(view, transcodeClass));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:46,代码来源:RequestBuilder.java

示例7: submit

import com.bumptech.glide.util.Util; //导入依赖的package包/类
/**
 * Returns a future that can be used to do a blocking get on a background thread.
 *
 * @param width  The desired width in pixels, or {@link Target#SIZE_ORIGINAL}. This will be
 *               overridden by
 *               {@link com.bumptech.glide.request.RequestOptions#override(int, int)} if
 *               previously called.
 * @param height The desired height in pixels, or {@link Target#SIZE_ORIGINAL}. This will be
 *               overridden by
 *               {@link com.bumptech.glide.request.RequestOptions#override(int, int)}} if
 *               previously called).
 */
public FutureTarget<TranscodeType> submit(int width, int height) {
  final RequestFutureTarget<TranscodeType> target =
      new RequestFutureTarget<>(context.getMainHandler(), width, height);

  if (Util.isOnBackgroundThread()) {
    context.getMainHandler().post(new Runnable() {
      @Override
      public void run() {
        if (!target.isCancelled()) {
          into(target);
        }
      }
    });
  } else {
    into(target);
  }

  return target;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:32,代码来源:RequestBuilder.java

示例8: testAddsBitmapsToMemoryCacheIfMemoryCacheHasEnoughSpaceRemaining

import com.bumptech.glide.util.Util; //导入依赖的package包/类
@Test
public void testAddsBitmapsToMemoryCacheIfMemoryCacheHasEnoughSpaceRemaining() {
  Bitmap bitmap = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
  when(cache.getMaxSize()).thenReturn(Util.getBitmapByteSize(bitmap));

  PreFillType size =
      new PreFillType.Builder(bitmap.getWidth(), bitmap.getHeight()).setConfig(bitmap.getConfig())
          .build();
  Map<PreFillType, Integer> allocationOrder = new HashMap<>();
  allocationOrder.put(size, 1);

  getHandler(allocationOrder).run();

  verify(cache).put(any(Key.class), anyResource());
  verify(pool, never()).put(any(Bitmap.class));
  // TODO(b/20335397): This code was relying on Bitmap equality which Robolectric removed
  // assertThat(addedBitmaps).containsExactly(bitmap);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:BitmapPreFillRunnerTest.java

示例9: testAddsBitmapsToPoolIfMemoryCacheIsNotFullButCannotFitBitmap

import com.bumptech.glide.util.Util; //导入依赖的package包/类
@Test
public void testAddsBitmapsToPoolIfMemoryCacheIsNotFullButCannotFitBitmap() {
  Bitmap bitmap = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
  when(cache.getMaxSize()).thenReturn(Util.getBitmapByteSize(bitmap) / 2);

  PreFillType size =
      new PreFillType.Builder(bitmap.getWidth(), bitmap.getHeight()).setConfig(bitmap.getConfig())
          .build();
  Map<PreFillType, Integer> allocationOrder = new HashMap<>();
  allocationOrder.put(size, 1);

  getHandler(allocationOrder).run();

  verify(cache, never()).put(any(Key.class), anyResource());
  // TODO(b/20335397): This code was relying on Bitmap equality which Robolectric removed
  //verify(pool).put(eq(bitmap));
  //assertThat(addedBitmaps).containsExactly(bitmap);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:BitmapPreFillRunnerTest.java

示例10: testAllocationOrderDoesNotOverFillWithMultipleSizes

import com.bumptech.glide.util.Util; //导入依赖的package包/类
@Test
public void testAllocationOrderDoesNotOverFillWithMultipleSizes() {
  PreFillQueue allocationOrder = bitmapPreFiller.generateAllocationOrder(new PreFillType[] {
      new PreFillType.Builder(DEFAULT_BITMAP_WIDTH, DEFAULT_BITMAP_HEIGHT)
          .setConfig(defaultBitmapConfig).build(),
      new PreFillType.Builder(DEFAULT_BITMAP_WIDTH / 2, DEFAULT_BITMAP_HEIGHT)
          .setConfig(defaultBitmapConfig).build(),
      new PreFillType.Builder(DEFAULT_BITMAP_WIDTH, DEFAULT_BITMAP_HEIGHT / 2)
          .setConfig(defaultBitmapConfig).build() });

  int byteSize = 0;
  while (!allocationOrder.isEmpty()) {
    PreFillType current = allocationOrder.remove();
    byteSize +=
        Util.getBitmapByteSize(current.getWidth(), current.getHeight(), current.getConfig());
  }

  assertThat(byteSize).isIn(Range.atMost(poolSize + cacheSize));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:BitmapPreFillerTest.java

示例11: testAllocationOrderDoesNotOverFillWithMultipleSizesAndWeights

import com.bumptech.glide.util.Util; //导入依赖的package包/类
@Test
public void testAllocationOrderDoesNotOverFillWithMultipleSizesAndWeights() {
  PreFillQueue allocationOrder = bitmapPreFiller.generateAllocationOrder(new PreFillType[] {
      new PreFillType.Builder(DEFAULT_BITMAP_WIDTH, DEFAULT_BITMAP_HEIGHT)
          .setConfig(defaultBitmapConfig).setWeight(4).build(),
      new PreFillType.Builder(DEFAULT_BITMAP_WIDTH / 2, DEFAULT_BITMAP_HEIGHT)
          .setConfig(defaultBitmapConfig).build(),
      new PreFillType.Builder(DEFAULT_BITMAP_WIDTH, DEFAULT_BITMAP_HEIGHT / 3)
          .setConfig(defaultBitmapConfig).setWeight(3).build() });

  int byteSize = 0;
  while (!allocationOrder.isEmpty()) {
    PreFillType current = allocationOrder.remove();
    byteSize +=
        Util.getBitmapByteSize(current.getWidth(), current.getHeight(), current.getConfig());
  }

  assertThat(byteSize).isIn(Range.atMost(poolSize + cacheSize));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:BitmapPreFillerTest.java

示例12: clear

import com.bumptech.glide.util.Util; //导入依赖的package包/类
/**
 * Cancels the current load if it is in progress, clears any resources held onto by the request
 * and replaces the loaded resource if the load completed with the placeholder.
 *
 * <p> Cleared requests can be restarted with a subsequent call to {@link #begin()} </p>
 *
 * @see #cancel()
 */
@Override
public void clear() {
  Util.assertMainThread();
  assertNotCallingCallbacks();
  stateVerifier.throwIfRecycled();
  if (status == Status.CLEARED) {
    return;
  }
  cancel();
  // Resource must be released before canNotifyStatusChanged is called.
  if (resource != null) {
    releaseResource(resource);
  }
  if (canNotifyCleared()) {
    target.onLoadCleared(getPlaceholderDrawable());
  }
  // Must be after cancel().
  status = Status.CLEARED;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:28,代码来源:SingleRequest.java

示例13: isEquivalentTo

import com.bumptech.glide.util.Util; //导入依赖的package包/类
@Override
public boolean isEquivalentTo(Request o) {
  if (o instanceof SingleRequest) {
    SingleRequest<?> that = (SingleRequest<?>) o;
    return overrideWidth == that.overrideWidth
        && overrideHeight == that.overrideHeight
        && Util.bothModelsNullEquivalentOrEquals(model, that.model)
        && transcodeClass.equals(that.transcodeClass)
        && requestOptions.equals(that.requestOptions)
        && priority == that.priority
        // We do not want to require that RequestListeners implement equals/hashcode, so we don't
        // compare them using equals(). We can however, at least assert that the request listener
        // is either present or not present in both requests.
        && (requestListener != null
        ? that.requestListener != null : that.requestListener == null);
  }
  return false;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:SingleRequest.java

示例14: testAddsBitmapsToPoolIfMemoryCacheIsNotFullButCannotFitBitmap

import com.bumptech.glide.util.Util; //导入依赖的package包/类
@Test
public void testAddsBitmapsToPoolIfMemoryCacheIsNotFullButCannotFitBitmap() {
  Bitmap bitmap = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
  when(cache.getMaxSize()).thenReturn((long) Util.getBitmapByteSize(bitmap) / 2);

  PreFillType size =
      new PreFillType.Builder(bitmap.getWidth(), bitmap.getHeight()).setConfig(bitmap.getConfig())
          .build();
  Map<PreFillType, Integer> allocationOrder = new HashMap<>();
  allocationOrder.put(size, 1);

  getHandler(allocationOrder).run();

  verify(cache, never()).put(any(Key.class), anyResource());
  // TODO(b/20335397): This code was relying on Bitmap equality which Robolectric removed
  //verify(pool).put(eq(bitmap));
  //assertThat(addedBitmaps).containsExactly(bitmap);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:BitmapPreFillRunnerTest.java

示例15: doGet

import com.bumptech.glide.util.Util; //导入依赖的package包/类
private synchronized R doGet(Long timeoutMillis)
    throws ExecutionException, InterruptedException, TimeoutException {
  if (assertBackgroundThread && !isDone()) {
    Util.assertBackgroundThread();
  }

  if (isCancelled) {
    throw new CancellationException();
  } else if (loadFailed) {
    throw new ExecutionException(new IllegalStateException("Load failed"));
  } else if (resultReceived) {
    return resource;
  }

  if (timeoutMillis == null) {
    waiter.waitForTimeout(this, 0);
  } else if (timeoutMillis > 0) {
    waiter.waitForTimeout(this, timeoutMillis);
  }

  if (Thread.interrupted()) {
    throw new InterruptedException();
  } else if (loadFailed) {
    throw new ExecutionException(new IllegalStateException("Load failed"));
  } else if (isCancelled) {
    throw new CancellationException();
  } else if (!resultReceived) {
    throw new TimeoutException();
  }

  return resource;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:33,代码来源:RequestFutureTarget.java


注:本文中的com.bumptech.glide.util.Util类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。