com.bumptech.glide.request.target.SimpleTarget Java Examples

The following examples show how to use com.bumptech.glide.request.target.SimpleTarget. 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: GlideUtil.java    From Android with MIT License 6 votes vote down vote up
/**
 * Download the pictures
 * @param path
 * @param listeners
 */
public static void downloadImage(String path, final OnDownloadTarget listeners){
    Glide.with(BaseApplication.getInstance())
            .load(path)
            .asBitmap()
            .into(new SimpleTarget<Bitmap>() {
                @Override
                public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
                    File file=BitmapUtil.getInstance().bitmapSavePath(resource);
                    String pathLocal = file.getAbsolutePath();
                    listeners.finish(pathLocal);
                }

                @Override
                public void onLoadFailed(Exception e, Drawable errorDrawable) {
                    super.onLoadFailed(e, errorDrawable);
                    listeners.error();
                }
            });
}
 
Example #2
Source File: AddProfileActivity.java    From star-zone-android with Apache License 2.0 6 votes vote down vote up
@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 #3
Source File: MineFragment.java    From star-zone-android with Apache License 2.0 6 votes vote down vote up
@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 #4
Source File: ContributorAdapter.java    From MediaNotification with Apache License 2.0 6 votes vote down vote up
@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 #5
Source File: VideoDetailsFragment.java    From leanback-assistant with Apache License 2.0 6 votes vote down vote up
private void initializeBackground(Movie movie) {
    mDetailsBackground.enableParallax();
    Glide.with(getActivity())
            .load(movie.getBackgroundImage())
            .asBitmap()
            .centerCrop()
            .error(R.drawable.assistant_tv_banner)
            .into(
                    new SimpleTarget<Bitmap>() {
                        @Override
                        public void onResourceReady(
                                Bitmap bitmap, GlideAnimation<? super Bitmap> glideAnimation) {
                            mDetailsBackground.setCoverBitmap(bitmap);
                            mAdapter.notifyArrayItemRangeChanged(0, mAdapter.size());
                        }
                    });
}
 
Example #6
Source File: EditNotePresenter.java    From SuperNote with GNU General Public License v3.0 6 votes vote down vote up
private void replaceImage(final String imageName) {
    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inJustDecodeBounds = true;

    File imageFile = new File(mView.getActivity().getExternalFilesDir(mNoteId).getPath() + "/" + imageName);

    BitmapFactory.decodeFile(imageFile.getPath(), options);

    int imageRequestWidth = getRequestImeWidth();
    int imageRequestHeight = setNeedHeight(options);


    Glide.with(mView.getActivity())
            .load(imageFile)
            .asBitmap()
            .override(imageRequestWidth, imageRequestHeight)
            .fitCenter()
            .priority(Priority.HIGH)
            .into(new SimpleTarget<Bitmap>() {
                @Override
                public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
                    mView.replaceImage(imageName, resource);
                }
            });
}
 
Example #7
Source File: VideoDetailsFragment.java    From tv-samples with Apache License 2.0 6 votes vote down vote up
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 #8
Source File: MainFragment.java    From leanback-extensions with Apache License 2.0 6 votes vote down vote up
protected void updateBackground(String uri) {
	int width = mMetrics.widthPixels;
	int height = mMetrics.heightPixels;
	Glide.with(getActivity())
			.load(uri)
			.centerCrop()
			.error(mDefaultBackground)
			.into(new SimpleTarget<GlideDrawable>(width, height) {
				@Override
				public void onResourceReady(GlideDrawable resource,
				                            GlideAnimation<? super GlideDrawable>
						                            glideAnimation) {
					mBackgroundManager.setDrawable(resource);
				}
			});
	mBackgroundTimer.cancel();
}
 
Example #9
Source File: AboutActivity.java    From v9porn with MIT License 6 votes vote down vote up
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: AFGlideUtil.java    From AFBaseLibrary with Apache License 2.0 6 votes vote down vote up
public static void loadImgBackground(Object obj, final View v, SimpleTarget simpleTarget) {
    DrawableTypeRequest drawableTypeRequest = getDrawableTypeRequest(obj, v);
    if (drawableTypeRequest == null) {
        drawableTypeRequest = getDrawableTypeRequest(sCommonPlaceholder, v);
    }
    if (drawableTypeRequest != null) {
        drawableTypeRequest
                .asBitmap()
                .centerCrop()
                .dontAnimate()
                .error(sCommonPlaceholder)
                .placeholder(sCommonPlaceholder)
                .diskCacheStrategy(DiskCacheStrategy.RESULT)
                .into(simpleTarget != null ? simpleTarget : new SimpleTarget<Bitmap>() {
                    @Override
                    public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
                        BitmapDrawable drawable = new BitmapDrawable(resource);
                        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                            v.setBackground(drawable);
                        } else {
                            v.setBackgroundDrawable(drawable);
                        }
                    }
                });
    }
}
 
Example #11
Source File: EditNotePresenter.java    From SuperNote with GNU General Public License v3.0 6 votes vote down vote up
private void displayImage() {

        BitmapFactory.Options options = new BitmapFactory.Options();
        options.inJustDecodeBounds = true;  // 对图片进行设置 但不形成示例,不耗费内存

        BitmapFactory.decodeFile(mImageFile.getPath(), options);

        int imageRequestWidth = getRequestImeWidth();
        int imageRequestHeight = getRequestImeHeight(options);
        Logger.d("width " + imageRequestWidth + "   height:" + imageRequestHeight);
        Logger.d("bitmap1 width " + options.outWidth + "   height:" + options.outHeight);

        Glide.with(mView.getActivity())
                .load(mImageFile)
                .asBitmap()
                .override(imageRequestWidth, imageRequestHeight)  // 设置大小
                .fitCenter()                                     // 不按照比例
                .into(new SimpleTarget<Bitmap>() {
                    @Override
                    public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
                        //根据Bitmap对象创建ImageSpan对象
                        Logger.d("bitmap width:" + resource.getWidth() + "   height:" + resource.getHeight());
                        mView.insertImage(mImageName, resource);
                    }
                });
    }
 
Example #12
Source File: SongPickerAdapter.java    From MusicPlayer with GNU General Public License v3.0 6 votes vote down vote up
@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 #13
Source File: GenrePickerAdapter.java    From MusicPlayer with GNU General Public License v3.0 6 votes vote down vote up
@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 #14
Source File: ArtistPickerAdapter.java    From MusicPlayer with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean onBindItem(PickerItem item, boolean create, int i) {
    Artist artist = mData.get(i);
    item.setTitle(artist.getName());
    item.setRadiusUnit(PhysicsEngine.INSTANCE.interpolate(1,2f,((float) artist.getSongCount())/getItemCount()));
    // Glide
    ArtistGlideRequest.Builder.from(GlideApp.with(mContext), artist)
            // .tryToLoadOriginal(true)
            .generateBuilder(mContext)
            .buildRequestDrawable()
            .centerCrop()
           // .error(R.drawable.music_style)
            .into(new SimpleTarget<Drawable>() {
                @Override
                public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
                    item.setBackgroundImage(resource);
                }
            });

    return true;
}
 
Example #15
Source File: BottomFragment.java    From NewFastFrame with Apache License 2.0 6 votes vote down vote up
private void updateAlbum(String uri) {
    if (uri != null && uri.startsWith("http")) {
        uri = MusicUtil.getRealUrl(uri, DensityUtil.toDp(50));
    }
    if (getContext() != null) {
        Glide.with(this).asBitmap().load(uri).into(new SimpleTarget<Bitmap>() {
            @Override
            public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
                bg.setBackground(BlurBitmapUtil.createBlurredImageFromBitmap(resource, getContext(), 20));
            }
        });

        BaseApplication.getAppComponent().getImageLoader().loadImage(getContext(), new GlideImageLoaderConfig.Builder()
                .imageView(album).url(uri).build());
    }
}
 
Example #16
Source File: MsgImgHolder.java    From Android with MIT License 6 votes vote down vote up
@Override
public void saveInPhone() {
    super.saveInPhone();
    final MsgDefinBean bean = baseEntity.getMsgDefinBean();
    String local = TextUtils.isEmpty(bean.getContent()) ? bean.getUrl() : bean.getContent();
    Glide.with(BaseApplication.getInstance())
            .load(local)
            .asBitmap()
            .into(new SimpleTarget<Bitmap>() {
                @Override
                public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
                    File file = FileUtil.createAbsNewFile(Environment.getExternalStorageDirectory().getAbsolutePath() + "/connect/" + bean.getMessage_id() + FileUtil.FileType.IMG.getFileType());
                    MediaStore.Images.Media.insertImage(context.getContentResolver(), resource, "connect", "");
                    context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.fromFile(file)));
                }
            });
}
 
Example #17
Source File: PhotoViewFragment.java    From AndroidUiKit with Apache License 2.0 6 votes vote down vote up
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 #18
Source File: ImageDetailActivity.java    From social-app-android with Apache License 2.0 6 votes vote down vote up
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 #19
Source File: UserDetailActivity.java    From NewFastFrame with Apache License 2.0 5 votes vote down vote up
private void updateUserInfo() {
    if (user != null) {
        Glide.with(this)
                .load(user.getAvatar())
                .into(avatar);
        name.setText(user.getName());
        signature.setText(user.getSignature());
        sex.setImageResource(user.isSex() ? R.drawable.ic_sex_male : R.drawable.ic_sex_female);
        school.setText(user.getSchool());
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append(user.getYear())
                .append(user.getMajor());
        major.setText(stringBuilder.toString());
        Glide.with(this).asBitmap().load(user.getTitlePaper()).into(new SimpleTarget<Bitmap>() {
            @Override
            public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
                headerBg.setBackground(BlurBitmapUtil.createBlurredImageFromBitmap(resource, UserDetailActivity.this, 20));
            }
        });

        if (user.isSex()) {
            sexContent.setText("他");
        } else {
            sexContent.setText("她");
        }
    }
}
 
Example #20
Source File: UserInfoActivity.java    From NewFastFrame with Apache License 2.0 5 votes vote down vote up
private void updateUserInfo() {
    sex.setImageResource(userEntity.isSex() ? R.drawable.ic_sex_male : R.drawable.ic_sex_female);
    userName.setText(userEntity.getUserName());
    name.setText(userEntity.getName());
    signature.setText(userEntity.getSignature());
    Glide.with(this).load(userEntity.getAvatar()).into(avatar);
    Glide.with(this).asBitmap().load(userEntity.getTitlePaper()).into(new SimpleTarget<Bitmap>() {
        @Override
        public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
            headerContainer.setBackground(BlurBitmapUtil.createBlurredImageFromBitmap(resource, UserInfoActivity.this, 20));
        }
    });
}
 
Example #21
Source File: Camera1Fragment.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
private void onCaptureClicked() {
  orderEnforcer.reset();

  Stopwatch fastCaptureTimer = new Stopwatch("Capture");

  camera.capture((jpegData, frontFacing) -> {
    fastCaptureTimer.split("captured");

    Transformation<Bitmap> transformation = frontFacing ? new MultiTransformation<>(new CenterCrop(), new FlipTransformation())
                                                        : new CenterCrop();

    GlideApp.with(this)
            .asBitmap()
            .load(jpegData)
            .transform(transformation)
            .override(cameraPreview.getWidth(), cameraPreview.getHeight())
            .into(new SimpleTarget<Bitmap>() {
              @Override
              public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
                fastCaptureTimer.split("transform");

                ByteArrayOutputStream stream = new ByteArrayOutputStream();
                resource.compress(Bitmap.CompressFormat.JPEG, 80, stream);
                fastCaptureTimer.split("compressed");

                byte[] data = stream.toByteArray();
                fastCaptureTimer.split("bytes");
                fastCaptureTimer.stop(TAG);

                controller.onImageCaptured(data, resource.getWidth(), resource.getHeight());
              }

              @Override
              public void onLoadFailed(@Nullable Drawable errorDrawable) {
                controller.onCameraError();
              }
            });
  });
}
 
Example #22
Source File: BaseWrappedViewHolder.java    From NewFastFrame with Apache License 2.0 5 votes vote down vote up
public BaseWrappedViewHolder setImageBg(final int id, String url) {
    if (getView(id) instanceof ImageView) {
        Glide.with(itemView.getContext()).load(url).into(new SimpleTarget<Drawable>() {
            @Override
            public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
                CommonLogger.e("设置背景");
                getView(id).setBackground(resource);
            }
        });
    }
    return this;
}
 
Example #23
Source File: WebImageSpan.java    From V2EX with GNU General Public License v3.0 5 votes vote down vote up
@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 #24
Source File: BaseWebViewLoadPresenter.java    From YiZhi with Apache License 2.0 5 votes vote down vote up
@Override
public void saveImageClicked(final FragmentActivity activity, final String imgUrl) {
    if (mIView.popupWindowIsShowing())
        mIView.dismissPopupWindow();

    Glide.with(activity).load(imgUrl).asBitmap().into(new SimpleTarget<Bitmap>() {
        @Override
        public void onResourceReady(Bitmap resource, GlideAnimation<? super
                Bitmap> glideAnimation) {
            FileUtils.saveBitmap(activity, imgUrl, resource, new FileUtils.SaveResultCallback
                    () {
                @Override
                public void onSavedSuccess() {
                    if (mIView != null) {
                        mIView.showToast("图片保存成功");
                    }
                }

                @Override
                public void onSavedFailed() {
                    if (mIView != null) {
                        mIView.showToast("图片保存失败");
                    }
                }
            });
        }
    });
}
 
Example #25
Source File: MyApplication.java    From PocketEOS-Android with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void showImage(String url, final ImageView image) {
    Glide.with(getApplicationContext()).load(url).placeholder(R.mipmap.ic_launcher).error(R.mipmap.ic_launcher)
            .into(new SimpleTarget<GlideDrawable>() { // 加上这段代码 可以解决
                @Override
                public void onResourceReady(GlideDrawable resource,
                                            GlideAnimation<? super GlideDrawable> glideAnimation) {
                    image.setImageDrawable(resource); //显示图片
                }
            });
}
 
Example #26
Source File: AlbumTagEditorActivity.java    From Orin with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void loadImageFromFile(@NonNull final Uri selectedFileUri) {
    Glide.with(AlbumTagEditorActivity.this)
            .load(selectedFileUri)
            .asBitmap()
            .transcode(new BitmapPaletteTranscoder(AlbumTagEditorActivity.this), BitmapPaletteWrapper.class)
            .diskCacheStrategy(DiskCacheStrategy.NONE)
            .skipMemoryCache(true)
            .into(new SimpleTarget<BitmapPaletteWrapper>() {
                @Override
                public void onLoadFailed(Exception e, Drawable errorDrawable) {
                    super.onLoadFailed(e, errorDrawable);
                    e.printStackTrace();
                    Toast.makeText(AlbumTagEditorActivity.this, e.toString(), Toast.LENGTH_LONG).show();
                }

                @Override
                public void onResourceReady(BitmapPaletteWrapper resource, GlideAnimation<? super BitmapPaletteWrapper> glideAnimation) {
                    PhonographColorUtil.getColor(resource.getPalette(), Color.TRANSPARENT);
                    albumArtBitmap = getResizedAlbumCover(resource.getBitmap(), 2048);
                    setImageBitmap(albumArtBitmap, PhonographColorUtil.getColor(resource.getPalette(), ATHUtil.resolveColor(AlbumTagEditorActivity.this, R.attr.defaultFooterColor)));
                    deleteAlbumArt = false;
                    dataChanged();
                    setResult(RESULT_OK);
                }
            });
}
 
Example #27
Source File: MainActivity.java    From TestChat with Apache License 2.0 5 votes vote down vote up
public void updateMenuBg() {
    Glide.with(this).load(user.getWallPaper()).into(new SimpleTarget<GlideDrawable>() {
        @Override
        public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> glideAnimation) {
            container.setBackground(resource);
        }
    });
}
 
Example #28
Source File: AlbumTagEditorActivity.java    From RetroMusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void loadImageFromFile(@NonNull final Uri selectedFileUri) {
    Glide.with(AlbumTagEditorActivity.this)
            .load(selectedFileUri)
            .asBitmap()
            .transcode(new BitmapPaletteTranscoder(AlbumTagEditorActivity.this), BitmapPaletteWrapper.class)
            .diskCacheStrategy(DiskCacheStrategy.NONE)
            .skipMemoryCache(true)
            .into(new SimpleTarget<BitmapPaletteWrapper>() {
                @Override
                public void onLoadFailed(Exception e, Drawable errorDrawable) {
                    super.onLoadFailed(e, errorDrawable);
                    e.printStackTrace();
                    Toast.makeText(AlbumTagEditorActivity.this, e.toString(), Toast.LENGTH_LONG).show();
                }

                @Override
                public void onResourceReady(BitmapPaletteWrapper resource, GlideAnimation<? super BitmapPaletteWrapper> glideAnimation) {
                    RetroMusicColorUtil.getColor(resource.getPalette(), Color.TRANSPARENT);
                    albumArtBitmap = ImageUtil.resizeBitmap(resource.getBitmap(), 2048);
                    setImageBitmap(albumArtBitmap, RetroMusicColorUtil.getColor(resource.getPalette(),
                            ContextCompat.getColor(AlbumTagEditorActivity.this, R.color.md_grey_500)));
                    deleteAlbumArt = false;
                    dataChanged();
                    setResult(RESULT_OK);
                }
            });
}
 
Example #29
Source File: ImageBindingAdapter.java    From WanAndroid with GNU General Public License v3.0 5 votes vote down vote up
@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 #30
Source File: BaseWrappedViewHolder.java    From TestChat with Apache License 2.0 5 votes vote down vote up
public BaseWrappedViewHolder setImageBg(final int id, String url) {
        if (getView(id) instanceof ImageView) {
                Glide.with(itemView.getContext()).load(url).into(new SimpleTarget<GlideDrawable>() {
                        @Override
                        public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> glideAnimation) {
                                LogUtil.e("设置背景");
                                getView(id).setBackground(resource);
                        }
                });
        }
        return this;
}