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


Java Util.isOnBackgroundThread方法代码示例

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


在下文中一共展示了Util.isOnBackgroundThread方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例3: 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<>(glideContext.getMainHandler(), width, height);

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

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

示例4: RequestManager

import com.bumptech.glide.util.Util; //导入方法依赖的package包/类
@SuppressWarnings("PMD.ConstructorCallsOverridableMethod")
RequestManager(
    Glide glide,
    Lifecycle lifecycle,
    RequestManagerTreeNode treeNode,
    RequestTracker requestTracker,
    ConnectivityMonitorFactory factory) {
  this.glide = glide;
  this.lifecycle = lifecycle;
  this.treeNode = treeNode;
  this.requestTracker = requestTracker;

  final Context context = glide.getGlideContext().getBaseContext();

  connectivityMonitor =
      factory.build(context, new RequestManagerConnectivityListener(requestTracker));

  // If we're the application level request manager, we may be created on a background thread.
  // In that case we cannot risk synchronously pausing or resuming requests, so we hack around the
  // issue by delaying adding ourselves as a lifecycle listener by posting to the main thread.
  // This should be entirely safe.
  if (Util.isOnBackgroundThread()) {
    mainHandler.post(addSelfToLifecycle);
  } else {
    lifecycle.addListener(this);
  }
  lifecycle.addListener(connectivityMonitor);

  setRequestOptions(glide.getGlideContext().getDefaultRequestOptions());

  glide.registerRequestManager(this);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:33,代码来源:RequestManager.java

示例5: RequestManager

import com.bumptech.glide.util.Util; //导入方法依赖的package包/类
@SuppressWarnings("PMD.ConstructorCallsOverridableMethod")
RequestManager(
    Glide glide,
    Lifecycle lifecycle,
    RequestManagerTreeNode treeNode,
    RequestTracker requestTracker,
    ConnectivityMonitorFactory factory,
    Context context) {
  this.glide = glide;
  this.lifecycle = lifecycle;
  this.treeNode = treeNode;
  this.requestTracker = requestTracker;
  this.context = context;

  connectivityMonitor =
      factory.build(
          context.getApplicationContext(),
          new RequestManagerConnectivityListener(requestTracker));

  // If we're the application level request manager, we may be created on a background thread.
  // In that case we cannot risk synchronously pausing or resuming requests, so we hack around the
  // issue by delaying adding ourselves as a lifecycle listener by posting to the main thread.
  // This should be entirely safe.
  if (Util.isOnBackgroundThread()) {
    mainHandler.post(addSelfToLifecycle);
  } else {
    lifecycle.addListener(this);
  }
  lifecycle.addListener(connectivityMonitor);

  setRequestOptions(glide.getGlideContext().getDefaultRequestOptions());

  glide.registerRequestManager(this);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:35,代码来源:RequestManager.java


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