Glide does not resolve its method

狂风中的少年 提交于 2019-11-27 19:14:24
Pehlaj

Seems like updated library has any issue. Add .apply(new RequestOptions() to continue with latest version.

CODE

Glide
 .with(this)
 .load(R.drawable.image_default_profile_picture)
 .apply(new RequestOptions()
 .placeholder(R.mipmap.ic_launcher)
 .fitCenter())
 .into(mUserImage);
James Jordan Taylor

You can still use .placeholder() with the latest version of Glide, you just have to add it as an applied RequestOption in the method chain, i.e.

Glide.with(this)
     .load(floorplanUrl)
     .apply(new RequestOptions()
           .placeholder(R.drawable.floorplan_unavailable))
     .into(floorplanImageView);

If you use Glide package dependences compile 'com.github.bumptech.glide:glide:3.7.0' than use below code

Glide
    .with(your_context)
    .load(image_url)
    .centerCrop()
    .placeholder(R.drawable.image_loading)
    .error(R.drawable.image_error)
    .into(imageView);

Note: As in doc Round Pictures: CircleImageView/CircularImageView/RoundedImageView are known to have issues with TransitionDrawable (.crossFade() with .thumbnail() or .placeholder()) and animated GIFs, use a BitmapTransformation (.circleCrop() will be available in v4) or .dontAnimate() to fix the issue.

Latest update version compile 'com.github.bumptech.glide:glide:4.1.1' or above than use below code

Glide.with(your_context)
     .load(url)
     .apply(new RequestOptions()
                .placeholder(R.mipmap.ic_loading_image)
                .centerCrop()
                .dontAnimate()
                .dontTransform())
                .into(imageView);

If you want to load GIF File in to Glide with using compile 'com.github.bumptech.glide:glide:3.7.0' than use .asGif() method after .load()

Glide
    .with(your_context)
    .load(image_url)
    .asGif()
    .into(imageView);

If you use compile 'com.github.bumptech.glide:glide:4.1.1' or higher(latest) dependences than,

Glide
    .with(your_context)
    .asGif()
    .load(image_url)
    .into(imageView);

Note: If you are useing glide:glide:4.1.1 or higher version than not necessary to use .asGif() method to load GIF file it will load GIF File automatically

See Latest version of glide, Bug fixes, Features

For using fitCenter() and other scale type changes with the Glide version starting from v4.0, you need include special class in your app.

import com.bumptech.glide.annotation.GlideModule;
import com.bumptech.glide.module.AppGlideModule;

@GlideModule
public class MyAppGlideModule extends AppGlideModule {
}

After that rebuild the project, and you can start using Glide on that manner

GlideApp.with(imageView)
    .load("...")
    .fitCenter()
    .into(imageView);

Documentation

Glide version: 4.8.0

Glide.with(this)
        .load("https://media.giphy.com/media/98uBZTzlXMhkk/giphy.gif")
        .apply(new RequestOptions()
                .placeholder(R.drawable.placeholder)
                .error(R.drawable.error)
                .centerCrop()
                .fitCenter())
        .into(imageView);

If you still want to use the newest library 'com.github.bumptech.glide:glide:4.0.0-RC1', The official Github page suggests the following:

Round Pictures: CircleImageView/CircularImageView/RoundedImageView are known to have issues with TransitionDrawable (.crossFade() with .thumbnail() or .placeholder()) and animated GIFs, use a BitmapTransformation (.circleCrop() will be available in v4) or .dontAnimate() to fix the issue.

Otherwise use the following library version:

compile 'com.github.bumptech.glide:glide:3.7.0'

compile this library:-

compile 'com.github.bumptech.glide:glide:3.7.0'
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!