com.bumptech.glide.request.Request Java Examples

The following examples show how to use com.bumptech.glide.request.Request. 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: GenericRequestBuilder.java    From giffun with Apache License 2.0 6 votes vote down vote up
/**
 * Set the target the resource will be loaded into.
 *
 * @see Glide#clear(Target)
 *
 * @param target The target to load the resource into.
 * @return The given target.
 */
public <Y extends Target<TranscodeType>> Y into(Y target) {
    Util.assertMainThread();
    if (target == null) {
        throw new IllegalArgumentException("You must pass in a non null Target");
    }
    if (!isModelSet) {
        throw new IllegalArgumentException("You must first set a model (try #load())");
    }

    Request previous = target.getRequest();

    if (previous != null) {
        previous.clear();
        requestTracker.removeRequest(previous);
        previous.recycle();
    }

    Request request = buildRequest(target);
    target.setRequest(request);
    lifecycle.addListener(target);
    requestTracker.runRequest(request);

    return target;
}
 
Example #2
Source File: GenericRequestBuilder.java    From giffun with Apache License 2.0 5 votes vote down vote up
private Request obtainRequest(Target<TranscodeType> target, float sizeMultiplier, Priority priority,
        RequestCoordinator requestCoordinator) {
    return GenericRequest.obtain(
            loadProvider,
            model,
            signature,
            context,
            priority,
            target,
            sizeMultiplier,
            placeholderDrawable,
            placeholderId,
            errorPlaceholder,
            errorId,
            fallbackDrawable,
            fallbackResource,
            requestListener,
            requestCoordinator,
            glide.getEngine(),
            transformation,
            transcodeClass,
            isCacheable,
            animationFactory,
            overrideWidth,
            overrideHeight,
            diskCacheStrategy);
}
 
Example #3
Source File: GlideImageLoader.java    From GalleryFinal with Apache License 2.0 5 votes vote down vote up
@Override
public void displayImage(Activity activity, String path, final GFImageView imageView, Drawable defaultDrawable, int width, int height) {
    Glide.with(activity)
            .load("file://" + path)
            .placeholder(defaultDrawable)
            .error(defaultDrawable)
            .override(width, height)
            .diskCacheStrategy(DiskCacheStrategy.NONE) //不缓存到SD卡
            .skipMemoryCache(true)
            //.centerCrop()
            .into(new ImageViewTarget<GlideDrawable>(imageView) {
                @Override
                protected void setResource(GlideDrawable resource) {
                    imageView.setImageDrawable(resource);
                }

                @Override
                public void setRequest(Request request) {
                    imageView.setTag(R.id.adapter_item_tag_key,request);
                }

                @Override
                public Request getRequest() {
                    return (Request) imageView.getTag(R.id.adapter_item_tag_key);
                }
            });
}
 
Example #4
Source File: RequestTracker.java    From giffun with Apache License 2.0 5 votes vote down vote up
/**
 * Starts tracking the given request.
 */
public void runRequest(Request request) {
    requests.add(request);
    if (!isPaused) {
        request.begin();
    } else {
        pendingRequests.add(request);
    }
}
 
Example #5
Source File: Glide.java    From giffun with Apache License 2.0 5 votes vote down vote up
/**
 * 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 static void clear(Target<?> target) {
    Util.assertMainThread();
    Request request = target.getRequest();
    if (request != null) {
        request.clear();
        target.setRequest(null);
    }
}
 
Example #6
Source File: RequestTracker.java    From giffun with Apache License 2.0 5 votes vote down vote up
/**
 * Stops any in progress requests.
 */
public void pauseRequests() {
    isPaused = true;
    for (Request request : Util.getSnapshot(requests)) {
        if (request.isRunning()) {
            request.pause();
            pendingRequests.add(request);
        }
    }
}
 
Example #7
Source File: RequestTracker.java    From giffun with Apache License 2.0 5 votes vote down vote up
/**
 * Starts any not yet completed or failed requests.
 */
public void resumeRequests() {
    isPaused = false;
    for (Request request : Util.getSnapshot(requests)) {
        if (!request.isComplete() && !request.isCancelled() && !request.isRunning()) {
            request.begin();
        }
    }
    pendingRequests.clear();
}
 
Example #8
Source File: RequestTracker.java    From giffun with Apache License 2.0 5 votes vote down vote up
/**
 * Cancels all requests and clears their resources.
 */
public void clearRequests() {
    for (Request request : Util.getSnapshot(requests)) {
        request.clear();
    }
    pendingRequests.clear();
}
 
Example #9
Source File: RequestTracker.java    From giffun with Apache License 2.0 5 votes vote down vote up
/**
 * Restarts failed requests and cancels and restarts in progress requests.
 */
public void restartRequests() {
    for (Request request : Util.getSnapshot(requests)) {
        if (!request.isComplete() && !request.isCancelled()) {
            // Ensure the request will be restarted in onResume.
            request.pause();
            if (!isPaused) {
                request.begin();
            } else {
                pendingRequests.add(request);
            }
        }
    }
}
 
Example #10
Source File: TestFragment_Separate.java    From glide-support with The Unlicense 4 votes vote down vote up
@Override public void setRequest(Request request) {
	view.setTag(request);
}
 
Example #11
Source File: BindingUtil.java    From CompositionAvatar with MIT License 4 votes vote down vote up
@Override
public void setRequest(Request request) {
    mView.setTag(mId, request);
}
 
Example #12
Source File: AbstractIconTarget.java    From GeometricWeather with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void setRequest(Request request) {
    setTag(request);
}
 
Example #13
Source File: GlideImageGetter.java    From diycode with Apache License 2.0 4 votes vote down vote up
@Override
public void setRequest(Request request) {
    this.request = request;
}
 
Example #14
Source File: GlideImageGetter.java    From diycode with Apache License 2.0 4 votes vote down vote up
@Override
public Request getRequest() {
    return request;
}
 
Example #15
Source File: VinylSimpleTarget.java    From VinylMusicPlayer with GNU General Public License v3.0 4 votes vote down vote up
@Override
@Nullable
public Request getRequest() {
    return request;
}
 
Example #16
Source File: VinylSimpleTarget.java    From VinylMusicPlayer with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void setRequest(@Nullable Request request) {
    this.request = request;
}
 
Example #17
Source File: GlideImageGetter.java    From Infinity-For-Reddit with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void setRequest(@Nullable Request request) {}
 
Example #18
Source File: LoggingTarget.java    From glide-support with The Unlicense 4 votes vote down vote up
@Override public Request getRequest() {
	log("getRequest");
	return super.getRequest();
}
 
Example #19
Source File: LoggingTarget.java    From glide-support with The Unlicense 4 votes vote down vote up
@Override public void setRequest(Request request) {
	log("setRequest", request);
	super.setRequest(request);
}
 
Example #20
Source File: WrappingTarget.java    From glide-support with The Unlicense 4 votes vote down vote up
@Override public Request getRequest() {
	return target.getRequest();
}
 
Example #21
Source File: WrappingTarget.java    From glide-support with The Unlicense 4 votes vote down vote up
@Override public void setRequest(Request request) {
	target.setRequest(request);
}
 
Example #22
Source File: WrappingTarget.java    From VideoListPlayer with MIT License 4 votes vote down vote up
@Override
public Request getRequest() {
    return target.getRequest();
}
 
Example #23
Source File: WrappingTarget.java    From VideoListPlayer with MIT License 4 votes vote down vote up
@Override
public void setRequest(Request request) {
    target.setRequest(request);
}
 
Example #24
Source File: CustomTarget.java    From Simple-Dilbert with Apache License 2.0 4 votes vote down vote up
@Override
public final void setRequest(@Nullable Request request) {
    this.request = request;
}
 
Example #25
Source File: CustomTarget.java    From Simple-Dilbert with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public final Request getRequest() {
    return request;
}
 
Example #26
Source File: BindingUtil.java    From CompositionAvatar with MIT License 4 votes vote down vote up
@Override
public Request getRequest() {
    return (Request) mView.getTag(mId);
}
 
Example #27
Source File: WrappingTarget.java    From StatusStories with Apache License 2.0 4 votes vote down vote up
@Override public void setRequest(Request request) {
    target.setRequest(request);
}
 
Example #28
Source File: WrappingTarget.java    From StatusStories with Apache License 2.0 4 votes vote down vote up
@Override public Request getRequest() {
    return target.getRequest();
}
 
Example #29
Source File: GlideImageGetter.java    From Infinity-For-Reddit with GNU Affero General Public License v3.0 4 votes vote down vote up
@Nullable
@Override
public Request getRequest() {
    return null;
}
 
Example #30
Source File: WrappingTarget.java    From imsdk-android with MIT License 4 votes vote down vote up
@Override
public void setRequest(Request request) {
    this.request = request;
    if (target != null) target.setRequest(request);
}