com.bumptech.glide.request.animation.GlideAnimation Java Examples

The following examples show how to use com.bumptech.glide.request.animation.GlideAnimation. 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: FormAdapter.java    From SSForms with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void call(List<Image> images) {
    if (images != null) {
        AppTools appTools = new AppTools();
        Uri imageUri = Uri.fromFile(new File(images.get(0).getPath()));

        try {
            int rotateImage = appTools.getCameraPhotoOrientation(imageUri);
            Bitmap bmp = appTools.getThumbnail(imageUri, rotateImage, mContext);

            Glide.with((Activity) mContext)
                    .load(appTools.bitmapToByte(bmp))
                    .asBitmap()
                    .into(new SimpleTarget<Bitmap>() {
                        @Override
                        public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
                            ((FormElementProfileView) mDataset.get(clickedPosition)).setProfileImage(resource);
                            notifyItemChanged(clickedPosition);
                        }
                    });
        } catch (Exception ex) {
            String sX = ex.toString();
            String gg = "";
        }
    }
}
 
Example #2
Source File: ImageBrowseActivity.java    From YiZhi with Apache License 2.0 6 votes vote down vote up
/**
 * 加载gif
 */
private void loadGif() {
    Glide.with(ImageBrowseActivity.this)
            .load(mImageUrl)
            .fitCenter()
            .diskCacheStrategy(DiskCacheStrategy.SOURCE)
            .into(new GlideDrawableImageViewTarget(pvPic) {
                @Override
                public void onResourceReady(GlideDrawable resource, GlideAnimation<?
                        super GlideDrawable> animation) {
                    super.onResourceReady(resource, animation);
                    //在这里添加一些图片加载完成的操作
                    pbPicBrowse.setVisibility(View.GONE);
                }
            });
}
 
Example #3
Source File: CaptureActivity.java    From myapplication with Apache License 2.0 6 votes vote down vote up
/**
 * 从相册返回扫描结果
 *
 * @param uri 图片地址
 */
private void operateAlbumScanResult(Uri uri) {
    int myWidth = getResources().getDisplayMetrics().widthPixels;
    int myHeight = getResources().getDisplayMetrics().heightPixels;

    Glide.with(CaptureActivity.this)
            .load(uri)
            .asBitmap()
            .into(new SimpleTarget<Bitmap>(myWidth, myHeight) {
                @Override
                public void onResourceReady(Bitmap resource,
                                            GlideAnimation<? super Bitmap> glideAnimation) {
                    Result resultZxing = new DecodeUtils(DecodeUtils.DECODE_DATA_MODE_ALL)
                            .decodeWithZxing(resource);
                    Log.i(TAG, "resultZxing >> " + resultZxing);

                    if (resultZxing != null) {
                        handleDecode(resultZxing, null);
                    } else {
                        SystemUtils.showHandlerToast(CaptureActivity.this,
                                "未发现二维码/条形码");
                    }
                }
            });
}
 
Example #4
Source File: GlideDrawableImageViewTarget.java    From giffun with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 * If no {@link GlideAnimation} is given or if the animation does not set the
 * {@link android.graphics.drawable.Drawable} on the view, the drawable is set using
 * {@link ImageView#setImageDrawable(android.graphics.drawable.Drawable)}.
 *
 * @param resource {@inheritDoc}
 * @param animation {@inheritDoc}
 */
@Override
public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> animation) {
    if (!resource.isAnimated()) {
        //TODO: Try to generalize this to other sizes/shapes.
        // This is a dirty hack that tries to make loading square thumbnails and then square full images less costly
        // by forcing both the smaller thumb and the larger version to have exactly the same intrinsic dimensions.
        // If a drawable is replaced in an ImageView by another drawable with different intrinsic dimensions,
        // the ImageView requests a layout. Scrolling rapidly while replacing thumbs with larger images triggers
        // lots of these calls and causes significant amounts of jank.
        float viewRatio = view.getWidth() / (float) view.getHeight();
        float drawableRatio = resource.getIntrinsicWidth() / (float) resource.getIntrinsicHeight();
        if (Math.abs(viewRatio - 1f) <= SQUARE_RATIO_MARGIN
                && Math.abs(drawableRatio - 1f) <= SQUARE_RATIO_MARGIN) {
            resource = new SquaringDrawable(resource, view.getWidth());
        }
    }
    super.onResourceReady(resource, animation);
    this.resource = resource;
    resource.setLoopCount(maxLoopCount);
    resource.start();
}
 
Example #5
Source File: AddNoteFragment.java    From androidtestdebug with MIT License 6 votes vote down vote up
@Override
public void showImagePreview(@NonNull String imageUrl) {
    checkState(!TextUtils.isEmpty(imageUrl), "imageUrl cannot be null or empty!");
    mImageThumbnail.setVisibility(View.VISIBLE);

    // The image is loaded in a different thread so in order to UI-test this, an idling resource
    // is used to specify when the app is idle.
    EspressoIdlingResource.increment(); // App is busy until further notice.

    // This app uses Glide for image loading
    Glide.with(this)
            .load(imageUrl)
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .centerCrop()
            .into(new GlideDrawableImageViewTarget(mImageThumbnail) {
                @Override
                public void onResourceReady(GlideDrawable resource,
                                            GlideAnimation<? super GlideDrawable> animation) {
                    super.onResourceReady(resource, animation);
                    EspressoIdlingResource.decrement(); // Set app as idle.
                }
            });
}
 
Example #6
Source File: GenericRequest.java    From giffun with Apache License 2.0 6 votes vote down vote up
/**
 * Internal {@link #onResourceReady(Resource)} where arguments are known to be safe.
 *
 * @param resource original {@link Resource}, never <code>null</code>
 * @param result object returned by {@link Resource#get()}, checked for type and never <code>null</code>
 */
private void onResourceReady(Resource<?> resource, R result) {
    // We must call isFirstReadyResource before setting status.
    boolean isFirstResource = isFirstReadyResource();
    status = Status.COMPLETE;
    this.resource = resource;

    if (requestListener == null || !requestListener.onResourceReady(result, model, target, loadedFromMemoryCache,
            isFirstResource)) {
        GlideAnimation<R> animation = animationFactory.build(loadedFromMemoryCache, isFirstResource);
        target.onResourceReady(result, animation);
    }

    notifyLoadSuccess();

    if (Log.isLoggable(TAG, Log.VERBOSE)) {
        logV("Resource ready in " + LogTime.getElapsedMillis(startTime) + " size: "
                + (resource.getSize() * TO_MEGABYTE) + " fromCache: " + loadedFromMemoryCache);
    }
}
 
Example #7
Source File: ViewerFragment.java    From GankApp with GNU General Public License v2.0 6 votes vote down vote up
@OnLongClick(R.id.image)
@SuppressWarnings("unused")
boolean setImageToWallpaper(){
    if(!PictUtil.hasSDCard()){
        Toast.makeText(getActivity(),"不支持下载文件",Toast.LENGTH_SHORT).show();
        return false;
    }
    Glide.with(this).load(url).asBitmap().into(new SimpleTarget<Bitmap>() {
        @Override
        public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
            mBitmap = resource;
            saveImgFileToLocal();
        }

        @Override
        public void onLoadFailed(Exception e, Drawable errorDrawable) {
            super.onLoadFailed(e, errorDrawable);
            mBitmap = null;
            Toast.makeText(getActivity(),"下载图片失败,请重试",Toast.LENGTH_SHORT).show();
        }
    });
    return false;
}
 
Example #8
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 #9
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 #10
Source File: FSAppWidgetProvider.java    From android-tutorials-glide with MIT License 6 votes vote down vote up
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager,
                     int[] appWidgetIds) {

    RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.custom_view_futurestudio);

    appWidgetTarget = new AppWidgetTarget(context, remoteViews, R.id.custom_view_image, appWidgetIds) {
        @Override
        public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
            super.onResourceReady(resource, glideAnimation);
        }
    };

    Glide
            .with(context.getApplicationContext())
            .load(GlideExampleActivity.eatFoodyImages[3])
            .asBitmap()
            .into(appWidgetTarget);

    pushWidgetUpdate(context, remoteViews);
}
 
Example #11
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 #12
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 #13
Source File: ArchiveItemView.java    From tribbble with Apache License 2.0 6 votes vote down vote up
public void bind(Shot shot, @DrawableRes int placeholderId) {
  mGifLabel.setVisibility(shot.isAnimated() ? VISIBLE : INVISIBLE);
  Glide.with(getContext())
      .load(shot.getImages().getHighResImage())
      .placeholder(placeholderId)
      .diskCacheStrategy(DiskCacheStrategy.SOURCE)
      .into(new GlideDrawableImageViewTarget(mShotImageView) {
        @Override public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> animation) {
          super.onResourceReady(resource, animation);
          resource.stop();
        }

        @Override public void onStart() {}

        @Override public void onStop() {}
      });
}
 
Example #14
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 #15
Source File: MyApplication.java    From PocketEOS-Android with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void showCirImage(String url, final ImageView image) {
    if (url == null || url.isEmpty() || "".equals(url)) {
        image.setImageResource(R.mipmap.defeat_person_img);
        return;
    }
    Glide.with(getApplicationContext())
            .load(url)
            .error(R.mipmap.ic_launcher_round)
            .into(new SimpleTarget<GlideDrawable>() { // 加上这段代码 可以解决
                @Override
                public void onResourceReady(GlideDrawable resource,
                                            GlideAnimation<? super GlideDrawable> glideAnimation) {
                    image.setImageDrawable(resource); //显示图片
                }
            });
}
 
Example #16
Source File: receiverpictureactivity.java    From Secure-Photo-Viewer with MIT License 6 votes vote down vote up
private void pictureSetFile(final TouchImageView imageset, Uri urinormal) {
    imageset.setMaxZoom(30);

    Glide.with(this)
            .load(urinormal)
            .override(2000, 2000)
            //.override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL)
            .into(new GlideDrawableImageViewTarget(imageset) {
                @Override
                public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> animation) {
                    super.onResourceReady(resource, animation);
                    imageset.setZoom(1);
                }
            })
    ;
}
 
Example #17
Source File: ModifyAvaterPresenter.java    From Android with MIT License 6 votes vote down vote up
@Override
public void saveImageToGallery() {
    String path = MemoryDataManager.getInstance().getAvatar();
    if (!TextUtils.isEmpty(path)) {
        Glide.with(BaseApplication.getInstance())
                .load(path + "?size=500")
                .asBitmap()
                .into(new SimpleTarget<Bitmap>() {
                    @Override
                    public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
                        if(resource != null){
                            saveNotigy(resource);
                        }else{
                            ToastEUtil.makeText(mView.getActivity(),R.string.Set_Save_Failed);
                        }
                    }
                });
    }
}
 
Example #18
Source File: GlideImageLoader.java    From imsdk-android with MIT License 6 votes vote down vote up
@Override
    public void displaygGif(Activity activity, String path, ImageView imageView, int width, int height) {
        if(TextUtils.isEmpty(path)){
            com.orhanobut.logger.Logger.i("图片崩溃错误2");
            return;
        }
        Glide.with(activity)                             //配置上下文
                .load(path)
//                .load(new MyGlideUrl(path))      //设置图片路径(fix #8,文件名包含%符号 无法识别和显示)
                .asGif()
                .toBytes()
                .diskCacheStrategy(DiskCacheStrategy.SOURCE)//缓存全尺寸
                .dontAnimate()
                .into(new ViewTarget<ImageView, byte[]>(imageView) {
                    @Override
                    public void onResourceReady(byte[] resource, GlideAnimation<? super byte[]> glideAnimation) {
//                            try {
                        FrameSequence fs = FrameSequence.decodeByteArray(resource);
                        FrameSequenceDrawable drawable = new FrameSequenceDrawable(fs);
                        view.setImageDrawable(drawable);
                    }
                });
    }
 
Example #19
Source File: AlbumTagEditorActivity.java    From Phonograph 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 = ImageUtil.resizeBitmap(resource.getBitmap(), 2048);
                    setImageBitmap(albumArtBitmap, PhonographColorUtil.getColor(resource.getPalette(), ATHUtil.resolveColor(AlbumTagEditorActivity.this, R.attr.defaultFooterColor)));
                    deleteAlbumArt = false;
                    dataChanged();
                    setResult(RESULT_OK);
                }
            });
}
 
Example #20
Source File: MovieDetailsFragment.java    From BuildingForAndroidTV with MIT License 5 votes vote down vote up
protected void updateBackground(String uri) {
    Glide.with(getActivity())
            .load(uri)
            .centerCrop()
            .error(mDefaultBackground)
            .into(new SimpleTarget<GlideDrawable>(mMetrics.widthPixels, mMetrics.heightPixels) {
                @Override
                public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> glideAnimation) {
                    mBackgroundManager.setDrawable(resource);
                }
            });
}
 
Example #21
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;
}
 
Example #22
Source File: UsageExampleTargetsAndRemoteViews.java    From android-tutorials-glide with MIT License 5 votes vote down vote up
private void loadImageViewTarget() {
    viewTarget = new ViewTarget<FutureStudioView, GlideDrawable>( customView ) {
        @Override
        public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> glideAnimation) {
            this.view.setImage( resource.getCurrent() );
        }
    };

    Glide
            .with( context.getApplicationContext() ) // safer!
            .load( eatFoodyImages[2] )
            .into( viewTarget );
}
 
Example #23
Source File: VideoDetailsFragment.java    From leanback-assistant with Apache License 2.0 5 votes vote down vote up
private void setupDetailsOverviewRow() {
    final DetailsOverviewRow row = new DetailsOverviewRow(mMovie);

    Glide.with(this)
            .load(mMovie.getCardImage())
            .asBitmap()
            .dontAnimate()
            .error(R.drawable.assistant_tv_banner)
            .into(
                    new SimpleTarget<Bitmap>() {
                        @Override
                        public void onResourceReady(
                                final Bitmap resource, GlideAnimation glideAnimation) {
                            row.setImageBitmap(getActivity(), resource);
                        }
                    });

    SparseArrayObjectAdapter adapter = new SparseArrayObjectAdapter();

    adapter.set(
            ACTION_WATCH, new Action(ACTION_WATCH, getResources().getString(R.string.watch)));
    adapter.set(
            ACTION_RENT,
            new Action(
                    ACTION_RENT,
                    getResources().getString(R.string.rent),
                    mMovie.getRentalPrice()));
    adapter.set(
            ACTION_BUY,
            new Action(
                    ACTION_BUY,
                    getResources().getString(R.string.buy),
                    mMovie.getPurchasePrice()));
    row.setActionsAdapter(adapter);

    mAdapter.add(row);
}
 
Example #24
Source File: PictureDetailFragment.java    From FileManager with Apache License 2.0 5 votes vote down vote up
@Override
protected void initViews(View self, Bundle savedInstanceState) {
    Glide.with(App.getAppContext())
            .load("file://" + mImageUrl)
            .fitCenter()
            //禁止磁盘缓存
            .diskCacheStrategy(DiskCacheStrategy.NONE)
            //禁止内存缓存
            //.skipMemoryCache( true )
            //.placeholder(R.drawable.image_loading)
            .error(R.drawable.image_load_failure)
            .into(new GlideDrawableImageViewTarget(image) {
                @Override
                public void onLoadStarted(Drawable placeholder) {
                    super.onLoadStarted(placeholder);
                    memoryProgressbar.show();
                }

                @Override
                public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> animation) {
                    super.onResourceReady(resource, animation);
                    memoryProgressbar.hide();
                }

                @Override
                public void onLoadFailed(Exception e, Drawable errorDrawable) {
                    super.onLoadFailed(e, errorDrawable);
                    memoryProgressbar.hide();
                }
            });
}
 
Example #25
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 #26
Source File: MusicService.java    From vk_music_android with GNU General Public License v3.0 5 votes vote down vote up
public void loadAlbumArt(VKApiAudio audio) {
    Bitmap placeHolder = BitmapFactory.decodeResource(getResources(), R.drawable.ic_album_placeholder);
    currentAlbumArt.set(placeHolder);
    notificationManager.updateNotificationBitmap(placeHolder);

    albumArtProvider.getAlbumArtUrl(audio.artist + " - " + audio.title)
            .subscribeOn(Schedulers.newThread())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(url -> {
                saveAlbumArtUrl(url);

                Glide.with(MusicService.this)
                        .load(url)
                        .asBitmap()
                        .error(R.drawable.ic_album_placeholder)
                        .into(new SimpleTarget<Bitmap>() {
                            @Override
                            public void onResourceReady(Bitmap bitmap, GlideAnimation<? super Bitmap> glideAnimation) {
                                currentAlbumArt.set(bitmap);
                                notificationManager.updateNotificationBitmap(bitmap);
                            }
                        });
            }, throwable -> {
                saveAlbumArtUrl("");
                currentAlbumArt.set(placeHolder);
                notificationManager.updateNotificationBitmap(placeHolder);
            });
}
 
Example #27
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 #28
Source File: PlayerService.java    From Pasta-Music with Apache License 2.0 5 votes vote down vote up
private void showNotification() {
    startForeground(NOTIFICATION_ID, getNotificationBuilder().build());

    Glide.with(this).load(trackList.get(curPos).trackImage).asBitmap().into(new SimpleTarget<Bitmap>() {
        @Override
        public void onResourceReady(final Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
            Palette.from(resource).generate(new Palette.PaletteAsyncListener() {
                @Override
                public void onGenerated(Palette palette) {
                    startForeground(NOTIFICATION_ID, getNotificationBuilder().setLargeIcon(resource).setColor(palette.getVibrantColor(Color.GRAY)).build());
                }
            });
        }
    });
}
 
Example #29
Source File: GlideBigLoader.java    From ImageLoader with Apache License 2.0 5 votes vote down vote up
@Override
public void prefetch(Uri uri) {
    mRequestManager
            .load(uri)
            .downloadOnly(new SimpleTarget<File>() {
                @Override
                public void onResourceReady(File resource,
                        GlideAnimation<? super File> glideAnimation) {
                    // not interested in result
                }
            });
}
 
Example #30
Source File: ImageBrowseActivity.java    From YiZhi with Apache License 2.0 5 votes vote down vote up
/**
 * 加载静态图片
 */
private void loadImage() {
    Glide.with(ImageBrowseActivity.this)
            .load(mImageUrl)
            .fitCenter()
            .crossFade()
            .into(new GlideDrawableImageViewTarget(pvPic) {
                @Override
                public void onResourceReady(GlideDrawable drawable, GlideAnimation anim) {
                    super.onResourceReady(drawable, anim);
                    //在这里添加一些图片加载完成的操作
                    pbPicBrowse.setVisibility(View.GONE);
                }
            });
}