本文整理汇总了Java中com.bumptech.glide.util.Util.assertMainThread方法的典型用法代码示例。如果您正苦于以下问题:Java Util.assertMainThread方法的具体用法?Java Util.assertMainThread怎么用?Java Util.assertMainThread使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.bumptech.glide.util.Util
的用法示例。
在下文中一共展示了Util.assertMainThread方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: into
import com.bumptech.glide.util.Util; //导入方法依赖的package包/类
/**
* Set the target the resource will be loaded into.
*
* @param target The target to load the resource into.
* @return The given target.
* @see RequestManager#clear(Target)
*/
public <Y extends Target<TranscodeType>> Y into(@NonNull Y target) {
Util.assertMainThread();
Preconditions.checkNotNull(target);
if (!isModelSet) {
throw new IllegalArgumentException("You must call #load() before calling #into()");
}
Request previous = target.getRequest();
if (previous != null) {
requestManager.clear(target);
}
requestOptions.lock();
Request request = buildRequest(target);
target.setRequest(request);
requestManager.track(target, request);
return target;
}
示例3: resumeRequestsRecursive
import com.bumptech.glide.util.Util; //导入方法依赖的package包/类
/**
* Performs {@link #resumeRequests()} recursively for all managers that are contextually
* descendant to this manager based on the Activity/Fragment hierarchy. The hierarchical semantics
* are identical as for {@link #pauseRequestsRecursive()}.
*/
// Public API.
@SuppressWarnings("unused")
public void resumeRequestsRecursive() {
Util.assertMainThread();
resumeRequests();
for (RequestManager requestManager : treeNode.getDescendants()) {
requestManager.resumeRequests();
}
}
示例4: clearMemory
import com.bumptech.glide.util.Util; //导入方法依赖的package包/类
/**
* Clears as much memory as possible.
*
* @see android.content.ComponentCallbacks#onLowMemory()
* @see android.content.ComponentCallbacks2#onLowMemory()
*/
public void clearMemory() {
// Engine asserts this anyway when removing resources, fail faster and consistently
Util.assertMainThread();
// memory cache needs to be cleared before bitmap pool to clear re-pooled Bitmaps too. See #687.
memoryCache.clearMemory();
bitmapPool.clearMemory();
arrayPool.clearMemory();
}
示例5: resumeRequestsRecursive
import com.bumptech.glide.util.Util; //导入方法依赖的package包/类
/**
* Performs {@link #resumeRequests()} recursively for all managers that are contextually
* descendant to this manager based on the Activity/Fragment hierarchy. The hierarchical semantics
* are identical as for {@link #pauseRequestsRecursive()}.
*/
public void resumeRequestsRecursive() {
Util.assertMainThread();
resumeRequests();
for (RequestManager requestManager : treeNode.getDescendants()) {
requestManager.resumeRequests();
}
}
示例6: trimMemory
import com.bumptech.glide.util.Util; //导入方法依赖的package包/类
/**
* Clears some memory with the exact amount depending on the given level.
*
* @see android.content.ComponentCallbacks2#onTrimMemory(int)
*/
public void trimMemory(int level) {
// Engine asserts this anyway when removing resources, fail faster and consistently
Util.assertMainThread();
// memory cache needs to be trimmed before bitmap pool to trim re-pooled Bitmaps too. See #687.
memoryCache.trimMemory(level);
bitmapPool.trimMemory(level);
arrayPool.trimMemory(level);
}
示例7: into
import com.bumptech.glide.util.Util; //导入方法依赖的package包/类
private <Y extends Target<TranscodeType>> Y into(
@NonNull Y target,
@Nullable RequestListener<TranscodeType> targetListener,
RequestOptions options) {
Util.assertMainThread();
Preconditions.checkNotNull(target);
if (!isModelSet) {
throw new IllegalArgumentException("You must call #load() before calling #into()");
}
options = options.autoClone();
Request request = buildRequest(target, targetListener, options);
Request previous = target.getRequest();
if (request.isEquivalentTo(previous)) {
request.recycle();
// If the request is completed, beginning again will ensure the result is re-delivered,
// triggering RequestListeners and Targets. If the request is failed, beginning again will
// restart the request, giving it another chance to complete. If the request is already
// running, we can let it continue running without interruption.
if (!Preconditions.checkNotNull(previous).isRunning()) {
// Use the previous request rather than the new one to allow for optimizations like skipping
// setting placeholders, tracking and untracking Targets, and obtaining View dimensions that
// are done in the individual Request.
previous.begin();
}
return target;
}
requestManager.clear(target);
target.setRequest(request);
requestManager.track(target, request);
return target;
}
示例8: addCallback
import com.bumptech.glide.util.Util; //导入方法依赖的package包/类
public void addCallback(ResourceCallback cb) {
Util.assertMainThread();
stateVerifier.throwIfRecycled();
if (hasResource) {
cb.onResourceReady(engineResource, dataSource);
} else if (hasLoadFailed) {
cb.onLoadFailed(exception);
} else {
cbs.add(cb);
}
}
示例9: removeCallback
import com.bumptech.glide.util.Util; //导入方法依赖的package包/类
public void removeCallback(ResourceCallback cb) {
Util.assertMainThread();
stateVerifier.throwIfRecycled();
if (hasResource || hasLoadFailed) {
addIgnoredCallback(cb);
} else {
cbs.remove(cb);
if (cbs.isEmpty()) {
cancel();
}
}
}
示例10: onResourceReleased
import com.bumptech.glide.util.Util; //导入方法依赖的package包/类
@Override
public void onResourceReleased(Key cacheKey, EngineResource<?> resource) {
Util.assertMainThread();
activeResources.deactivate(cacheKey);
if (resource.isCacheable()) {
cache.put(cacheKey, resource);
} else {
resourceRecycler.recycle(resource);
}
}
示例11: onEngineJobComplete
import com.bumptech.glide.util.Util; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void onEngineJobComplete(Key key, EngineResource<?> resource) {
Util.assertMainThread();
// A null resource indicates that the load failed, usually due to an exception.
if (resource != null) {
resource.setResourceListener(key, this);
if (resource.isCacheable()) {
activeResources.put(key, new ResourceWeakReference(key, resource, getReferenceQueue()));
}
}
// TODO: should this check that the engine job is still current?
jobs.remove(key);
}
示例12: onEngineJobCancelled
import com.bumptech.glide.util.Util; //导入方法依赖的package包/类
@Override
public void onEngineJobCancelled(EngineJob engineJob, Key key) {
Util.assertMainThread();
EngineJob<?> current = jobs.get(key);
if (engineJob.equals(current)) {
jobs.remove(key);
}
}
示例13: recycle
import com.bumptech.glide.util.Util; //导入方法依赖的package包/类
void recycle(Resource<?> resource) {
Util.assertMainThread();
if (isRecycling) {
// If a resource has sub-resources, releasing a sub resource can cause it's parent to be
// synchronously
// evicted which leads to a recycle loop when the parent releases it's children. Posting
// breaks this loop.
handler.obtainMessage(ResourceRecyclerCallback.RECYCLE_RESOURCE, resource).sendToTarget();
} else {
isRecycling = true;
resource.recycle();
isRecycling = false;
}
}
示例14: onResourceReleased
import com.bumptech.glide.util.Util; //导入方法依赖的package包/类
@Override
public void onResourceReleased(Key cacheKey, EngineResource resource) {
Util.assertMainThread();
activeResources.remove(cacheKey);
if (resource.isCacheable()) {
cache.put(cacheKey, resource);
} else {
resourceRecycler.recycle(resource);
}
}
示例15: pauseRequestsRecursive
import com.bumptech.glide.util.Util; //导入方法依赖的package包/类
/**
* Performs {@link #pauseRequests()} recursively for all managers that are contextually
* descendant to this manager based on the Activity/Fragment hierarchy:
*
* <ul>
* <li>When pausing on an Activity all attached fragments will also get paused.
* <li>When pausing on an attached Fragment all descendant fragments will also get paused.
* <li>When pausing on a detached Fragment or the application context only the current
* RequestManager is paused.
* </ul>
*
* <p>Note, on pre-Jelly Bean MR1 calling pause on a Fragment will not cause child fragments to
* pause, in this case either call pause on the Activity or use a support Fragment.
*/
public void pauseRequestsRecursive() {
Util.assertMainThread();
pauseRequests();
for (RequestManager requestManager : treeNode.getDescendants()) {
requestManager.pauseRequests();
}
}