com.bumptech.glide.request.transition.Transition Java Examples
The following examples show how to use
com.bumptech.glide.request.transition.Transition.
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: ContributorAdapter.java From MediaNotification with Apache License 2.0 | 6 votes |
@Override public void onBindViewHolder(final ContributorAdapter.ViewHolder holder, int position) { ContributorData contributor = contributors.get(position); Glide.with(holder.imageView.getContext()).asBitmap().load(contributor.imageUrl).into(new SimpleTarget<Bitmap>() { @Override public void onResourceReady(Bitmap resource, Transition<? super Bitmap> transition) { holder.imageView.setImageBitmap(resource); } }); holder.textView.setText(contributor.name); holder.itemView.setTag(contributor); holder.itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (view.getTag() != null && view.getTag() instanceof ContributorData) view.getContext().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(((ContributorData) view.getTag()).url))); } }); }
Example #2
Source File: MineFragment.java From star-zone-android with Apache License 2.0 | 6 votes |
@Override public void handleMessage(Message msg) { switch (msg.what) { case MSG_WHAT_SHOW_NETWORK_IMAGE: String url = msg.getData().getString("url"); RequestOptions requestOptions = RequestOptions.diskCacheStrategyOf(DiskCacheStrategy.RESOURCE) .override(150, 150) .placeholder(R.mipmap.ic_launcher); Glide.with(getActivity()).asBitmap().load(url) .apply(requestOptions) .thumbnail(0.5F) .into(new SimpleTarget<Bitmap>() { @Override public void onResourceReady(Bitmap bitmap, Transition<? super Bitmap> transition) { // OutputStream outputStream = null; // bitmap.compress(Bitmap.CompressFormat.JPEG, 50, outputStream); mImageView.setImageBitmap(bitmap); } }); break; } }
Example #3
Source File: MainFragment.java From tv-samples with Apache License 2.0 | 6 votes |
private void updateBackground(String uri) { int width = mMetrics.widthPixels; int height = mMetrics.heightPixels; RequestOptions options = new RequestOptions() .centerCrop() .error(mDefaultBackground); Glide.with(this) .asBitmap() .load(uri) .apply(options) .into(new SimpleTarget<Bitmap>(width, height) { @Override public void onResourceReady( Bitmap resource, Transition<? super Bitmap> transition) { mBackgroundManager.setBitmap(resource); } }); }
Example #4
Source File: AddProfileActivity.java From star-zone-android with Apache License 2.0 | 6 votes |
@Override public void handleMessage(Message msg) { switch (msg.what) { case MSG_WHAT_SHOW_NETWORK_IMAGE: String url = msg.getData().getString("url"); RequestOptions requestOptions = RequestOptions.diskCacheStrategyOf(DiskCacheStrategy.RESOURCE) .override(150, 150) .placeholder(R.mipmap.ic_launcher); Glide.with(getActivity()).asBitmap().load(url) .apply(requestOptions) .thumbnail(0.5F) .into(new SimpleTarget<Bitmap>() { @Override public void onResourceReady(Bitmap bitmap, Transition<? super Bitmap> transition) { // mImageView.setImageBitmap(CommonUtil.toRoundCorner(bitmap, 100)); mImageView.setImageBitmap(bitmap); } }); break; } }
Example #5
Source File: VideoDetailsFragment.java From tv-samples with Apache License 2.0 | 6 votes |
private void updateBackground(String uri) { RequestOptions options = new RequestOptions() .centerCrop() .error(mDefaultBackground); Glide.with(this) .asBitmap() .load(uri) .apply(options) .into(new SimpleTarget<Bitmap>(mMetrics.widthPixels, mMetrics.heightPixels) { @Override public void onResourceReady( Bitmap resource, Transition<? super Bitmap> transition) { mBackgroundManager.setBitmap(resource); } }); }
Example #6
Source File: DribbbleTarget.java From Protein with Apache License 2.0 | 6 votes |
@Override public void onResourceReady(Drawable resource, @Nullable Transition<? super Drawable> transition) { super.onResourceReady(resource, transition); BadgedFourThreeImageView badgedImageView = (BadgedFourThreeImageView) getView(); if (resource instanceof GifDrawable) { Bitmap image = ((GifDrawable) resource).getFirstFrame(); if (image != null) { // look at the corner to determine the gif badge color int cornerSize = (int) (56 * getView().getContext().getResources().getDisplayMetrics ().scaledDensity); Bitmap corner = Bitmap.createBitmap(image, image.getWidth() - cornerSize, image.getHeight() - cornerSize, cornerSize, cornerSize); boolean isDark = ColorUtils.isDark(corner); corner.recycle(); badgedImageView.setBadgeColor(ContextCompat.getColor(getView().getContext(), isDark ? R.color.gif_badge_dark_image : R.color.gif_badge_light_image)); } else { badgedImageView.setBadgeColor(ContextCompat.getColor(getView().getContext(), R.color.gif_badge_light_image)); } } }
Example #7
Source File: ImageLoader.java From CrazyDaily with Apache License 2.0 | 6 votes |
public static void load(Context context, String url, OnDrawableCallback callback) { if (context == null) { return; } if (context instanceof Activity && ((Activity) context).isDestroyed()) { return; } GlideApp.with(context) .load(url) .into(new SimpleTarget<Drawable>() { @Override public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) { if (callback != null) { callback.onDrawable(resource); } } }); }
Example #8
Source File: GlideUtil.java From Android-IM with Apache License 2.0 | 6 votes |
public static void loadSmallImageMessage(Context context, String url, final ImageView imageView) { if (null == imageMessageOptions) { imageMessageOptions = new RequestOptions().placeholder(R.drawable.icon_user); } Glide.with(context).asBitmap().load(url).apply(imageMessageOptions).into(new SimpleTarget<Bitmap>(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL) { @Override public void onResourceReady(Bitmap bitmap, Transition<? super Bitmap> transition) { int width = bitmap.getWidth(); int height = bitmap.getHeight(); if (width > height) { width = (width / height) * 198; height = 198; } else { height = (height / width) * 198; width = 198; } imageView.setLayoutParams(new RelativeLayout.LayoutParams(width, height)); imageView.setImageBitmap(bitmap); } }); }
Example #9
Source File: AboutActivity.java From v9porn with MIT License | 6 votes |
private void saveToSystemGallery(final String name, int id) { GlideApp.with(this).downloadOnly().load(id).into(new SimpleTarget<File>() { @Override public void onResourceReady(@NonNull File resource, @Nullable Transition<? super File> transition) { File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), name + ".jpg"); try { FileUtils.copyFile(resource, file); showMessage("保存图片成功了", TastyToast.SUCCESS); notifySystemGallery(file); } catch (IOException e) { e.printStackTrace(); showMessage("保存图片失败了", TastyToast.ERROR); } } }); }
Example #10
Source File: AboutActivity.java From v9porn with MIT License | 6 votes |
private void saveToSystemGallery(final String name, int id) { GlideApp.with(this).downloadOnly().load(id).into(new SimpleTarget<File>() { @Override public void onResourceReady(@NonNull File resource, @Nullable Transition<? super File> transition) { File file = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), name + ".jpg"); try { FileUtils.copyFile(resource, file); showMessage("保存图片成功了", TastyToast.SUCCESS); notifySystemGallery(file); } catch (IOException e) { e.printStackTrace(); showMessage("保存图片失败了", TastyToast.ERROR); } } }); }
Example #11
Source File: ImageDisplayEngine.java From PlayerBase with Apache License 2.0 | 6 votes |
public static void displayAsBitmap(Context context, String path, final OnBitmapResourceCallBack callBack){ GlideApp.with(context) .load(path) .dontAnimate() .into(new SimpleTarget<Drawable>() { @Override public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) { if(callBack!=null){ BitmapDrawable bitmapDrawable = (BitmapDrawable) resource; Bitmap bitmap = null; if(bitmapDrawable!=null){ bitmap = bitmapDrawable.getBitmap(); } callBack.onResourceReady(bitmap); } } }); }
Example #12
Source File: ReadAloudService.java From HaoReader with GNU General Public License v3.0 | 6 votes |
/** * 更新通知 */ private void updateNotification() { final int dimen = DensityUtil.dp2px(this, 128); Glide.with(this) .asBitmap() .load(cover) .into(new RequestFutureTarget<Bitmap>(dimen, dimen) { @Override public synchronized void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) { showNotification(resource); } @Override public synchronized void onLoadFailed(@Nullable Drawable errorDrawable) { showNotification(BitmapFactory.decodeResource(getResources(), R.drawable.img_cover_default)); } }); }
Example #13
Source File: AudioBookPlayService.java From HaoReader with GNU General Public License v3.0 | 6 votes |
private void updateNotification() { final String coverUrl = bookShelfBean == null ? null : bookShelfBean.getBookInfoBean().getRealCoverUrl(); final int dimen = DensityUtil.dp2px(this, 128); Glide.with(this) .asBitmap() .load(coverUrl) .into(new RequestFutureTarget<Bitmap>(dimen, dimen) { @Override public synchronized void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) { showNotification(resource); } @Override public synchronized void onLoadFailed(@Nullable Drawable errorDrawable) { showNotification(BitmapFactory.decodeResource(getResources(), R.drawable.img_cover_default)); } }); }
Example #14
Source File: ImageDetailActivity.java From social-app-android with Apache License 2.0 | 6 votes |
private void loadImage(String imageTitle) { int maxImageSide = presenter.calcMaxImageSide(); ImageUtil.loadImageWithSimpleTarget(GlideApp.with(this), PostManager.getInstance(this.getApplicationContext()).getOriginImageStorageRef(imageTitle), new SimpleTarget<Bitmap>(maxImageSide, maxImageSide) { @Override public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) { progressBar.setVisibility(View.GONE); touchImageView.setImageBitmap(resource); } @Override public void onLoadFailed(@Nullable Drawable errorDrawable) { super.onLoadFailed(errorDrawable); progressBar.setVisibility(View.GONE); touchImageView.setImageResource(R.drawable.ic_stub); } }); }
Example #15
Source File: GlideImageGeter.java From NewFastFrame with Apache License 2.0 | 6 votes |
@Override public void onResourceReady(@NonNull GifDrawable resource, @Nullable Transition<? super GifDrawable> transition) { int w = DensityUtil.getScreenWidth(mContext); int hh = resource.getIntrinsicHeight(); int ww = resource.getIntrinsicWidth(); int high = hh * (w - 50) / ww; Rect rect = new Rect(20, 20, w - 30, high); resource.setBounds(rect); urlDrawable.setBounds(rect); urlDrawable.setDrawable(resource); gifDrawables.add(resource); resource.setCallback(mTextView); resource.start(); resource.setLoopCount(GifDrawable.LOOP_FOREVER); mTextView.setText(mTextView.getText()); mTextView.invalidate(); }
Example #16
Source File: PhotoViewFragment.java From AndroidUiKit with Apache License 2.0 | 6 votes |
private void loadImageView() { final String url = getArguments().getString(ARGUMENTS_IMAGE); Glide.with(this).downloadOnly().load(url) /* todo replace error icon */ .apply(new RequestOptions().error(R.mipmap.qq_refresh_success)) .into(new SimpleTarget<File>() { @Override public void onResourceReady(File resource, Transition<? super File> transition) { mImageView.setImage(ImageSource.uri(Uri.fromFile(resource))); } @Override public void onLoadFailed(@Nullable Drawable errorDrawable) { super.onLoadFailed(errorDrawable); } }); }
Example #17
Source File: MainActivity.java From lbry-android with MIT License | 6 votes |
@Nullable @Override public Bitmap getCurrentLargeIcon(Player player, PlayerNotificationManager.BitmapCallback callback) { if (nowPlayingClaimBitmap == null && nowPlayingClaim != null && !Helper.isNullOrEmpty(nowPlayingClaim.getThumbnailUrl())) { Glide.with(getApplicationContext()).asBitmap().load(nowPlayingClaim.getThumbnailUrl()).into(new CustomTarget<Bitmap>() { @Override public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) { nowPlayingClaimBitmap = resource; callback.onBitmap(resource); } @Override public void onLoadCleared(@Nullable Drawable placeholder) { } }); } return nowPlayingClaimBitmap; }
Example #18
Source File: WallpaperSetter.java From Infinity-For-Reddit with GNU Affero General Public License v3.0 | 6 votes |
public static void set(String url, int setTo, Context context, SetWallpaperListener setWallpaperListener) { Toast.makeText(context, R.string.save_image_first, Toast.LENGTH_SHORT).show(); WallpaperManager wallpaperManager = WallpaperManager.getInstance(context); WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Glide.with(context).asBitmap().load(url).into(new CustomTarget<Bitmap>() { @Override public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) { new SetAsWallpaperAsyncTask(resource, setTo, wallpaperManager, windowManager, setWallpaperListener).execute(); } @Override public void onLoadCleared(@Nullable Drawable placeholder) { } }); }
Example #19
Source File: AlbumTagEditorActivity.java From VinylMusicPlayer with GNU General Public License v3.0 | 6 votes |
@Override protected void loadImageFromFile(@NonNull final Uri selectedFileUri) { GlideApp.with(AlbumTagEditorActivity.this) .as(BitmapPaletteWrapper.class) .load(selectedFileUri) .transition(new GenericTransitionOptions<BitmapPaletteWrapper>().transition(android.R.anim.fade_in)) .apply(new RequestOptions() .diskCacheStrategy(DiskCacheStrategy.NONE) .skipMemoryCache(true)) .into(new VinylSimpleTarget<BitmapPaletteWrapper>() { @Override public void onLoadFailed(@Nullable Drawable errorDrawable) { super.onLoadFailed(errorDrawable); } @Override public void onResourceReady(@NonNull BitmapPaletteWrapper resource, Transition<? super BitmapPaletteWrapper> glideAnimation) { VinylMusicPlayerColorUtil.getColor(resource.getPalette(), Color.TRANSPARENT); albumArtBitmap = ImageUtil.resizeBitmap(resource.getBitmap(), 2048); setImageBitmap(albumArtBitmap, VinylMusicPlayerColorUtil.getColor(resource.getPalette(), ATHUtil.resolveColor(AlbumTagEditorActivity.this, R.attr.defaultFooterColor))); deleteAlbumArt = false; dataChanged(); setResult(RESULT_OK); } }); }
Example #20
Source File: GenrePickerAdapter.java From MusicPlayer with GNU General Public License v3.0 | 6 votes |
@Override public boolean onBindItem(PickerItem item, boolean create, int i) { super.onBindItem(item,create,i); Genre genre = mData.get(i); item.setTitle(genre.name); item.setRadiusUnit(genre.songCount); // Glide ArrayList<Song> songs = GenreLoader.getSongs(mContext,genre.id); Glide.with(mContext).load(MusicUtil.getMediaStoreAlbumCoverUri(songs.get(0).albumId)).into(new SimpleTarget<Drawable>() { @Override public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) { item.setBackgroundImage(resource); GenrePickerAdapter.this.notifyBackImageUpdated(i); } }); return true; }
Example #21
Source File: SongPickerAdapter.java From MusicPlayer with GNU General Public License v3.0 | 6 votes |
@Override public boolean onBindItem(PickerItem item, boolean create, int i) { super.onBindItem(item,create,i); Song song = mData.get(i); item.setTitle(song.title); item.setRadiusUnit(PickerItem.SIZE_RANDOM); // Glide Glide.with(mContext).load(MusicUtil.getMediaStoreAlbumCoverUri(song.albumId)).into(new SimpleTarget<Drawable>() { @Override public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) { item.setBackgroundImage(resource); SongPickerAdapter.this.notifyBackImageUpdated(i); } }); return true; }
Example #22
Source File: ImageLoader.java From ShapeView with Apache License 2.0 | 5 votes |
public static void loadImage(Context context, Object url, ShapeView shapeView, int width, int height) { Glide.with(context).asBitmap().load(url).into(new SimpleTarget<Bitmap>(width, height) { @Override public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) { shapeView.setBitmap(resource); shapeView.reDraw(); } }); }
Example #23
Source File: PictureViewerActivity.java From v9porn with MIT License | 5 votes |
private void showSavePictureDialog(final String imageUrl) { QMUIDialog.MenuDialogBuilder builder = new QMUIDialog.MenuDialogBuilder(this); builder.addItem("保存图片", (dialog, which) -> { GlideApp.with(PictureViewerActivity.this).downloadOnly().load(Uri.parse(imageUrl)).into(new SimpleTarget<File>() { @Override public void onResourceReady(@NonNull File resource, @Nullable Transition<? super File> transition) { File filePath = new File(SDCardUtils.DOWNLOAD_IMAGE_PATH); if (!filePath.exists()) { if (!filePath.mkdirs()) { showMessage("创建文件夹失败了", TastyToast.ERROR); return; } } File file = new File(filePath, UUID.randomUUID().toString() + ".jpg"); try { FileUtils.copyFile(resource, file); showMessage("保存图片成功了", TastyToast.SUCCESS); notifySystemGallery(file); } catch (IOException e) { e.printStackTrace(); showMessage("保存图片失败了", TastyToast.ERROR); } } }); dialog.dismiss(); }); builder.show(); }
Example #24
Source File: ImageLoader.java From ShapeView with Apache License 2.0 | 5 votes |
public static void loadImage(Context context, Object url, ShapeView shapeView) { Glide.with(context).asBitmap().load(url).into(new SimpleTarget<Bitmap>() { @Override public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) { shapeView.setBitmap(resource); shapeView.reDraw(); } }); }
Example #25
Source File: ImageBindingAdapter.java From WanAndroid with GNU General Public License v3.0 | 5 votes |
@BindingAdapter("blurImage") public static void setBlurImage(ImageView imageView, String url) { Glide.with(imageView.getContext()) .applyDefaultRequestOptions(PicConfig.itemOptions) .asBitmap() .load(url) .into(new SimpleTarget<Bitmap>() { @Override public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) { Blurry.with(imageView.getContext()).from(resource).into(imageView); } }); }
Example #26
Source File: AlertDialogsHelper.java From leafpicrevived with GNU General Public License v3.0 | 5 votes |
public static void resizeImage(Activity activity, Uri uri, int width_px, int height_px, Intent adv) { Glide.with(activity) .asBitmap() .load(uri) .into(new SimpleTarget<Bitmap>(width_px, height_px) { @Override public void onResourceReady(@NonNull Bitmap bitmap, Transition<? super Bitmap> transition) { saveResizedImage(bitmap, activity, uri, adv); } }); }
Example #27
Source File: RichTextView.java From V2EX with GNU General Public License v3.0 | 5 votes |
@Override public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) { int w = 600; int hh=resource.getIntrinsicHeight(); int ww=resource.getIntrinsicWidth() ; int high = hh * (w - 50)/ww; Rect rect = new Rect(20, 20,w-30,high); resource.setBounds(rect); webDrawable.setBounds(rect); webDrawable.setDrawable(resource); setText(getText()); invalidate(); }
Example #28
Source File: WebImageSpan.java From V2EX with GNU General Public License v3.0 | 5 votes |
@Override public Drawable getDrawable() { if (isShow){ return super.getDrawable(); } Glide.with(mTextView.getContext()).load(mUri).into(new SimpleTarget<Drawable>() { @Override public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) { Resources resources = mTextView.getContext().getResources(); int targetWidth = (int) (resources.getDisplayMetrics().widthPixels * 0.8); Bitmap zoom = zoom(ConvertUtils.drawable2Bitmap(resource), targetWidth); BitmapDrawable b = new BitmapDrawable(resources, zoom); b.setBounds(0, 0, b.getIntrinsicWidth(), b.getIntrinsicHeight()); Field mDrawable; Field mDrawableRef; try { mDrawable = ImageSpan.class.getDeclaredField("mDrawable"); mDrawable.setAccessible(true); mDrawable.set(WebImageSpan.this, b); mDrawableRef = DynamicDrawableSpan.class.getDeclaredField("mDrawableRef"); mDrawableRef.setAccessible(true); mDrawableRef.set(WebImageSpan.this, null); isShow = true; mTextView.setText(mTextView.getText()); } catch (IllegalAccessException | NoSuchFieldException e) { e.printStackTrace(); } } }); return null; }
Example #29
Source File: ImagePagerAdapter.java From ImageSelector with Apache License 2.0 | 5 votes |
@Override public Object instantiateItem(ViewGroup container, final int position) { final PhotoView currentView = viewList.remove(0); final Image image = mImgList.get(position); container.addView(currentView); if (image.isGif()) { currentView.setScaleType(ImageView.ScaleType.FIT_CENTER); Glide.with(mContext).load(isAndroidQ ? image.getUri() : image.getPath()) .apply(new RequestOptions().diskCacheStrategy(DiskCacheStrategy.NONE)).override(720,1080) .into(currentView); } else { Glide.with(mContext).asBitmap() .apply(new RequestOptions().diskCacheStrategy(DiskCacheStrategy.NONE)) .load(isAndroidQ ? image.getUri() : image.getPath()).into(new SimpleTarget<Bitmap>(720,1080) { @Override public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) { int bw = resource.getWidth(); int bh = resource.getHeight(); if (bw > 4096 || bh > 4096) { Bitmap bitmap = ImageUtil.zoomBitmap(resource, 4096, 4096); setBitmap(currentView, bitmap); } else { setBitmap(currentView, resource); } } }); } currentView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mListener != null) { mListener.onItemClick(position, image); } } }); return currentView; }
Example #30
Source File: PlayActivity.java From Yuan-SxMusic with Apache License 2.0 | 5 votes |
@Override public void setSingerImg(String ImgUrl) { Glide.with(this) .load(ImgUrl) .apply(RequestOptions.placeholderOf(R.drawable.welcome)) .apply(RequestOptions.errorOf(R.drawable.welcome)) .into(new SimpleTarget<Drawable>() { @Override public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) { mImgBmp = ((BitmapDrawable) resource).getBitmap(); //如果是本地音乐 if (!isOnline) { //保存图片到本地 FileUtil.saveImgToNative(PlayActivity.this, mImgBmp, getSingerName()); //将封面地址放到数据库中 LocalSong localSong = new LocalSong(); localSong.setPic(Api.STORAGE_IMG_FILE + FileUtil.getSong().getSinger() + ".jpg"); localSong.updateAll("songId=?", FileUtil.getSong().getSongId()); } try2UpdateMusicPicBackground(mImgBmp); setDiscImg(mImgBmp); mGetImgAndLrcBtn.setVisibility(View.GONE); } }); }