com.bumptech.glide.Priority Java Examples
The following examples show how to use
com.bumptech.glide.Priority.
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: OkHttpStreamFetcher.java From NewFastFrame with Apache License 2.0 | 6 votes |
@Override public void loadData(@NonNull Priority priority, @NonNull DataCallback<? super InputStream> callback) { Request.Builder requestBuilder = new Request.Builder().url(url.toStringUrl()); for (Map.Entry<String, String> headerEntry : url.getHeaders().entrySet()) { String key = headerEntry.getKey(); requestBuilder.addHeader(key, headerEntry.getValue()); } Request request = requestBuilder.build(); Response response = null; call = client.newCall(request); try { response = call.execute(); responseBody = response.body(); } catch (IOException e) { e.printStackTrace(); callback.onLoadFailed(new IOException("Request failed with code: ")); return; } long contentLength = responseBody.contentLength(); stream = ContentLengthInputStream.obtain(responseBody.byteStream(), contentLength); callback.onDataReady(stream); }
Example #2
Source File: TrackFragment.java From Melophile with Apache License 2.0 | 6 votes |
public void showArt(String artUrl) { if (!TextUtils.equals(lastArtUrl, artUrl)) { lastArtUrl = artUrl; Glide.with(getContext()) .load(artUrl) .asBitmap() .priority(Priority.IMMEDIATE) .into(new ImageViewTarget<Bitmap>(smallImage) { @Override protected void setResource(Bitmap resource) { smallImage.setImageBitmap(resource); smallImage.post(() -> { Blurry.with(getContext()) .async(bitmap -> { background.setImageDrawable(bitmap); getActivity().supportStartPostponedEnterTransition(); }) .from(resource) .into(background); }); } }); } }
Example #3
Source File: DecodeJob.java From giffun with Apache License 2.0 | 6 votes |
DecodeJob(EngineKey resultKey, int width, int height, DataFetcher<A> fetcher, DataLoadProvider<A, T> loadProvider, Transformation<T> transformation, ResourceTranscoder<T, Z> transcoder, DiskCacheProvider diskCacheProvider, DiskCacheStrategy diskCacheStrategy, Priority priority, FileOpener fileOpener) { this.resultKey = resultKey; this.width = width; this.height = height; this.fetcher = fetcher; this.loadProvider = loadProvider; this.transformation = transformation; this.transcoder = transcoder; this.diskCacheProvider = diskCacheProvider; this.diskCacheStrategy = diskCacheStrategy; this.priority = priority; this.fileOpener = fileOpener; }
Example #4
Source File: OkHttpStreamFetcher.java From TestChat with Apache License 2.0 | 6 votes |
@Override public InputStream loadData(Priority priority) throws Exception { Request.Builder requestBuilder = new Request.Builder() .url(url.toStringUrl()); for (Map.Entry<String, String> headerEntry : url.getHeaders().entrySet()) { String key = headerEntry.getKey(); requestBuilder.addHeader(key, headerEntry.getValue()); } Request request = requestBuilder.build(); Response response = client.newCall(request).execute(); responseBody = response.body(); if (!response.isSuccessful()) { throw new IOException("Request failed with code: " + response.code()); } long contentLength = responseBody.contentLength(); stream = ContentLengthInputStream.obtain(responseBody.byteStream(), contentLength); return stream; }
Example #5
Source File: ImageViewerActivity.java From titanium-imagepicker with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") private void setupGlideOptions() { options = new RequestOptions(); if (isShapeCircle) { if (Defaults.CIRCLE_RADIUS > 0) { options.transforms(new CenterCrop(), new RoundedCorners(Defaults.CIRCLE_RADIUS)); } else { options.circleCrop(); } } options.override(Defaults.IMAGE_HEIGHT, Defaults.IMAGE_HEIGHT); options.placeholder(placeholder_image); options.priority(Priority.HIGH); }
Example #6
Source File: ImagePickerActivity.java From titanium-imagepicker with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") private void setupGlideOptions() { options = new RequestOptions(); int size; if (isShapeCircle) { if (Defaults.CIRCLE_RADIUS > 0) { size = (int) (0.65 * Defaults.IMAGE_HEIGHT); options.transforms(new CenterCrop(), new RoundedCorners(Defaults.CIRCLE_RADIUS)); } else { size = Defaults.IMAGE_HEIGHT; options.circleCrop(); } } else { size = (int) (0.65 * Defaults.IMAGE_HEIGHT); } options.override(size, size); options.error(error_image); options.priority(Priority.HIGH); }
Example #7
Source File: ImageViewerActivity.java From titanium-imagepicker with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") private void setupGlideOptions() { options = new RequestOptions(); if (isShapeCircle) { if (Defaults.CIRCLE_RADIUS > 0) { options.transforms(new CenterCrop(), new RoundedCorners(Defaults.CIRCLE_RADIUS)); } else { options.circleCrop(); } } options.override(Defaults.IMAGE_HEIGHT, Defaults.IMAGE_HEIGHT); options.placeholder(placeholder_image); options.priority(Priority.HIGH); }
Example #8
Source File: OkHttpStreamFetcher.java From imsdk-android with MIT License | 6 votes |
@Override public InputStream loadData(Priority priority) throws Exception { Request.Builder requestBuilder = new Request.Builder().url(url.toStringUrl()); for (Map.Entry<String, String> headerEntry : url.getHeaders().entrySet()) { String key = headerEntry.getKey(); requestBuilder.addHeader(key, headerEntry.getValue()); } Request request = requestBuilder.build(); Response response; call = client.newCall(request); response = call.execute(); responseBody = response.body(); if (!response.isSuccessful()) { throw new IOException("Request failed with code: " + response.code()); } long contentLength = responseBody.contentLength(); stream = ContentLengthInputStream.obtain(responseBody.byteStream(), contentLength); return stream; }
Example #9
Source File: AudioFileCoverFetcher.java From MusicPlayer with GNU General Public License v3.0 | 6 votes |
@Override public void loadData(@NonNull Priority priority, @NonNull DataCallback<? super InputStream> callback) { MediaMetadataRetriever retriever = new MediaMetadataRetriever(); try { retriever.setDataSource(model.filePath); byte[] picture = retriever.getEmbeddedPicture(); if (picture != null) { callback.onDataReady(new ByteArrayInputStream(picture)); } else { try { callback.onDataReady(fallback(model.filePath)); } catch (FileNotFoundException e) { callback.onLoadFailed(e); } } } finally { retriever.release(); } }
Example #10
Source File: AlbumAdapter.java From Melophile with Apache License 2.0 | 6 votes |
@Override public View instantiateItem(ViewGroup container, int position) { View view = inflater.inflate(R.layout.adapter_album, container, false); ImageView image = ButterKnife.findById(view, R.id.image); Glide.with(container.getContext()) .load(albums.get(position).getArtworkUrl()) .asBitmap() .priority(Priority.IMMEDIATE) .diskCacheStrategy(DiskCacheStrategy.RESULT) .into(new ImageViewTarget<Bitmap>(image) { @Override protected void setResource(Bitmap resource) { image.setImageBitmap(resource); if (position == current && !isLoaded) { isLoaded = true; if (callback != null) { callback.onTransitionImageLoaded(image, resource); } } } }); container.addView(view); return view; }
Example #11
Source File: GlideUtils.java From Collection-Android with MIT License | 6 votes |
/** * Glide实现高斯模糊 * * @param context * @param url * @param imageView */ public static void loadImgBlur(Context context, String url, int defaultLoadingImg,ImageView imageView) { try { RequestOptions options = new RequestOptions() .priority(Priority.HIGH) .placeholder(defaultLoadingImg) .error(defaultLoadingImg) .bitmapTransform(new BlurTransformation(40, 16)); Glide.with(context) .load(url) .apply(options) .into(imageView); } catch (Exception exception) { return; } }
Example #12
Source File: PlaylistFragment.java From Melophile with Apache License 2.0 | 6 votes |
@Override public void showPlaylistArt(String artUrl) { if (!loaded) { loaded = true; Glide.with(getContext()) .load(artUrl) .asBitmap() .priority(Priority.IMMEDIATE) .into(new ImageViewTarget<Bitmap>(playlistArt) { @Override protected void setResource(Bitmap resource) { final int imageHeight = playlistArt.getHeight(); playlistArt.setImageBitmap(resource); parent.setStaticOffset(imageHeight); parent.setOffset(imageHeight); toggle.setStaticOffset(imageHeight - toggle.getHeight() / 2); toggle.setOffset(imageHeight - toggle.getHeight() / 2); toggle.setMinOffset(ViewCompat.getMinimumHeight(playlistArt) - toggle.getHeight() / 2); tracks.addOnScrollListener(listener); tracks.setOnFlingListener(flingListener); new Palette.Builder(resource).generate(PlaylistFragment.this::applyPalette); getActivity().supportStartPostponedEnterTransition(); } }); } }
Example #13
Source File: TracksAdapter.java From Melophile with Apache License 2.0 | 5 votes |
@Override public void onBindData() { Track track = at(getAdapterPosition()); artist.setText(track.getArtist()); trackTitle.setText(track.getTitle()); duration.setText(track.getFormatedDuration()); Glide.with(itemView.getContext()) .load(track.getArtworkUrl()) .priority(Priority.IMMEDIATE) .diskCacheStrategy(DiskCacheStrategy.RESULT) .into(trackArt); }
Example #14
Source File: GlideManager.java From UIWidget with Apache License 2.0 | 5 votes |
private static RequestOptions getRequestOptions() { RequestOptions requestOptions = new RequestOptions() .centerCrop() // 填充方式 .priority(Priority.HIGH) //优先级 .diskCacheStrategy(DiskCacheStrategy.ALL); //缓存策略 return requestOptions; }
Example #15
Source File: GlideEngine.java From Matisse with Apache License 2.0 | 5 votes |
@Override public void loadImage(Context context, int resizeX, int resizeY, ImageView imageView, Uri uri) { Glide.with(context) .load(uri) .apply(new RequestOptions() .override(resizeX, resizeY) .priority(Priority.HIGH) .fitCenter()) .into(imageView); }
Example #16
Source File: GlideEngine.java From Matisse with Apache License 2.0 | 5 votes |
@Override public void loadGifImage(Context context, int resizeX, int resizeY, ImageView imageView, Uri uri) { Glide.with(context) .asGif() .load(uri) .apply(new RequestOptions() .override(resizeX, resizeY) .priority(Priority.HIGH) .fitCenter()) .into(imageView); }
Example #17
Source File: ImageLoader.java From Ency with Apache License 2.0 | 5 votes |
public static void loadAll(Context context, String imgUrl, ImageView imageView) { GlideApp.with(context) .load(imgUrl) .centerCrop() .placeholder(R.drawable.icon_default) .error(R.drawable.icon_default) .priority(Priority.LOW) .diskCacheStrategy(DiskCacheStrategy.AUTOMATIC) .into(imageView); }
Example #18
Source File: Glide4Engine.java From AlbumCameraRecorder with MIT License | 5 votes |
@Override public void loadImage(Context context, int resizeX, int resizeY, ImageView imageView, Uri uri) { Glide.with(context) .load(uri) .apply(new RequestOptions() .override(resizeX, resizeY) .priority(Priority.HIGH) .error(R.drawable.image_failed) .fitCenter()) .into(imageView); }
Example #19
Source File: ArtistGlideRequest.java From MusicPlayer with GNU General Public License v3.0 | 5 votes |
public RequestBuilder<Drawable> buildRequestDrawable() { //noinspection unchecked return createBaseRequestForDrawable(builder.requestManager, builder.artist, builder.noCustomImage, builder.forceDownload, builder.mLoadOriginalImage, builder.mImageNumber) .diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY) .priority(Priority.LOW) .override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL) .signature(createSignature(builder.artist,builder.mLoadOriginalImage, builder.mImageNumber)); }
Example #20
Source File: ArtistGlideRequest.java From MusicPlayer with GNU General Public License v3.0 | 5 votes |
public RequestBuilder<Bitmap> build() { //noinspection unchecked return createBaseRequest(builder.requestManager, builder.artist, builder.noCustomImage, builder.forceDownload, builder.mLoadOriginalImage, builder.mImageNumber) //.transcode(new BitmapPaletteTranscoder(context), BitmapPaletteWrapper.class) .diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY) .transition(GenericTransitionOptions.with(DEFAULT_ANIMATION)) .priority(Priority.LOW) .override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL) .signature(createSignature(builder.artist,builder.mLoadOriginalImage, builder.mImageNumber)); }
Example #21
Source File: ArtistGlideRequest.java From MusicPlayer with GNU General Public License v3.0 | 5 votes |
public RequestBuilder<Drawable> buildRequestDrawable() { //noinspection unchecked return createBaseRequestForDrawable(builder.requestManager, builder.artist, builder.noCustomImage, builder.forceDownload, builder.mLoadOriginalImage, builder.mImageNumber) .diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY) .priority(Priority.LOW) .override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL) .signature(createSignature(builder.artist,builder.mLoadOriginalImage, builder.mImageNumber)); }
Example #22
Source File: ArtistGlideRequest.java From MusicPlayer with GNU General Public License v3.0 | 5 votes |
public RequestBuilder<Bitmap> build() { //noinspection unchecked return createBaseRequest(builder.requestManager, builder.artist, builder.noCustomImage, builder.forceDownload, builder.mLoadOriginalImage, builder.mImageNumber) .diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY) .priority(Priority.LOW) .override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL) .signature(createSignature(builder.artist,builder.mLoadOriginalImage, builder.mImageNumber)); }
Example #23
Source File: ArtistGlideRequest.java From MusicPlayer with GNU General Public License v3.0 | 5 votes |
public RequestBuilder<Bitmap> build() { return createBaseRequest(requestManager, artist, noCustomImage, forceDownload, mLoadOriginalImage, mImageNumber) .diskCacheStrategy(DEFAULT_DISK_CACHE_STRATEGY) .transition(GenericTransitionOptions.with(DEFAULT_ANIMATION)) .priority(Priority.LOW) //.override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL) .signature(createSignature(artist,mLoadOriginalImage, mImageNumber)); }
Example #24
Source File: ImageLoader.java From Ency with Apache License 2.0 | 5 votes |
public static void loadAll(Context context, int imgRes, ImageView imageView) { GlideApp.with(context) .load(imgRes) .centerCrop() .priority(Priority.LOW) .diskCacheStrategy(DiskCacheStrategy.ALL) .into(imageView); }
Example #25
Source File: Glide4EngineProgress.java From AlbumCameraRecorder with MIT License | 5 votes |
@Override public void loadImage(Context context, int resizeX, int resizeY, ImageView imageView, Uri uri) { Glide.with(context) .load(uri) .apply(new RequestOptions() .override(resizeX, resizeY) .priority(Priority.HIGH) .fitCenter()) .into(imageView); }
Example #26
Source File: Glide4Engine.java From AlbumCameraRecorder with MIT License | 5 votes |
@Override public void loadGifImage(Context context, int resizeX, int resizeY, ImageView imageView, Uri uri) { Glide.with(context) .asGif() .load(uri) .apply(new RequestOptions() .override(resizeX, resizeY) .priority(Priority.HIGH) .fitCenter()) .into(imageView); }
Example #27
Source File: Glide4Engine.java From AlbumCameraRecorder with MIT License | 5 votes |
@Override public void loadDrawableImage(Context context, ImageView imageView, Integer resourceId) { Glide.with(context) .load(resourceId) .apply(new RequestOptions() .priority(Priority.HIGH) .error(R.drawable.image_failed) .fitCenter()) .into(imageView); }
Example #28
Source File: Glide4Engine.java From AlbumCameraRecorder with MIT License | 5 votes |
@Override public void loadUriImage(Context context, ImageView imageView, Uri uri) { Glide.with(context) .load(uri) .apply(new RequestOptions() .priority(Priority.HIGH) .error(R.drawable.image_failed) .fitCenter()) .into(imageView); }
Example #29
Source File: Glide4Engine.java From AlbumCameraRecorder with MIT License | 5 votes |
@Override public void loadUrlImage(Context context, ImageView imageView, String url) { Glide.with(context) .load(url) .apply(new RequestOptions() .priority(Priority.HIGH) .error(R.drawable.image_failed) .fitCenter()) .into(imageView); }
Example #30
Source File: GlideEngine.java From AlbumCameraRecorder with MIT License | 5 votes |
@Override public void loadGifImage(Context context, int resizeX, int resizeY, ImageView imageView, Uri uri) { Glide.with(context) .load(uri) .asGif() .override(resizeX, resizeY) .priority(Priority.HIGH) .into(imageView); }