Glide 4.3.1: how to use error()?

Damn Vegetables

First, what is the difference between Glide and GlideApp? The latter seems to be automatically generated, but the steps seemed to be complicated so I used Glide instead. They both seem to have the same methods.

So, I used Glide.with(activity).load(fileName).error().into(imageView). The problem is that I cannot understand what to pass to error(). It did not take a drawable resource ID. Android Studio says the parameter is RequestBuilder< Drawable!>?, but I could not find any example.

"Error: Type mismatch: inferred type is Int but RequestBuilder< Drawable!>? was expected"

D_Alpha

If you are using Glide v4 then you have to use RequestOptions for including the more options you want, for example centerCrop(), placeholder(), error(), priority() , diskCacheStrategy().

So after using RequestOptions your Glide would look like this-

RequestOptions options = new RequestOptions()
                    .centerCrop()
                    .placeholder(R.drawable.default_avatar)
                    .error(R.drawable.default_avatar)
                    .diskCacheStrategy(DiskCacheStrategy.ALL)
                    .priority(Priority.HIGH);

Glide.with(mContext).load(imgUrl)
                    .apply(options)
                    .into(picThumbnail);

Now you can show error image and placeholder set the disk cache etc.

GlideApp is also a part of Glide v4. It is used to provide more than one Transformation in Glide v4, using the transforms() method:

GlideApp.with(mContext)
  .load(imgUrl)
  .transforms(new CenterCrop(), new RoundedCorners(20))
  .into(target);

error() and placeholder() using GlideApp-

GlideApp.with(mContext)
            .load(imageUrl)
            .placeholder(R.drawable.placeholder_image)
            .error(R.drawable.error_image)
            .diskCacheStrategy(DiskCacheStrategy.ALL)
            .priority(Priority.HIGH)
            .into(offerImage);

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

How to use a view (shimmer) as a placeholder for an imageView (Glide)

分類Dev

Migrated from Glide 3 to 4 and having a AbstractMethodError when launching the app

分類Dev

Glide 4 logging

分類Dev

Error Number: 1064 You have an error in your SQL syntax; right syntax to use near '3 = ''' at line 1

分類Dev

Glide 4: get GifDecoder of GifDrawable

分類Dev

How to use pivot_longer on 1x3 dataframe

分類Dev

How to round an image with Glide library?

分類Dev

How to secure Laravel Glide library?

分類Dev

How to configure Log4j (1 or 2) to use custom log file name while code against Slf4j

分類Dev

d3.v4: How to use linkRadial instead of linkVertical/Horizontal

分類Dev

how to correctly use append function in sqlite3 database in swift 4

分類Dev

Is it better to use a crowded 2.4GHz Wi-Fi channel 1, 6, 11 or "unused" 3, 4, 8, or 9?

分類Dev

how to fix SQL syntax error...upto...for the right syntax to use near '())' at line 1

分類Dev

cryptsetup luksFormat error "Device /dev/nvme0n1p3 is in use. Can not proceed with format operation."

分類Dev

Skip List in Redis why use p=1/4 not 1/e?

分類Dev

Glide v4 / OkHttp3でリダイレクトを検出する方法は?

分類Dev

a=3,2,1; gives error in gcc

分類Dev

Android Glide: How to download and cache bitmaps?

分類Dev

How to fit Image into ImageView using Glide

分類Dev

How to use wxPython for Python 3?

分類Dev

シーケンス0、0、0、0、0、1、1、1、1、1、2、2、2、2、2、3、3、3、3、3、4、4、4、4を作成します。 、4 with seq()

分類Dev

R forループベクトル1,2,2,3,3,3,4,4,4,4、..、10、

分類Dev

Glide 4でGlideModuleを使用する方法は?

分類Dev

シリーズ1、2、1、3、2、1、4、3、2、1、5、4、3、2、1を生成する

分類Dev

How to use gstreamer for transcoding and resizing from mp4(h264/aac) to mp4(h264/mp3)?

分類Dev

How can I use Realm with Swift 4?

分類Dev

How to use Multiple Tables in Codeigniter 4

分類Dev

How to use OR in Rails 4 ActiveRecord named scope

分類Dev

How to install and use beautifulsoup4

Related 関連記事

  1. 1

    How to use a view (shimmer) as a placeholder for an imageView (Glide)

  2. 2

    Migrated from Glide 3 to 4 and having a AbstractMethodError when launching the app

  3. 3

    Glide 4 logging

  4. 4

    Error Number: 1064 You have an error in your SQL syntax; right syntax to use near '3 = ''' at line 1

  5. 5

    Glide 4: get GifDecoder of GifDrawable

  6. 6

    How to use pivot_longer on 1x3 dataframe

  7. 7

    How to round an image with Glide library?

  8. 8

    How to secure Laravel Glide library?

  9. 9

    How to configure Log4j (1 or 2) to use custom log file name while code against Slf4j

  10. 10

    d3.v4: How to use linkRadial instead of linkVertical/Horizontal

  11. 11

    how to correctly use append function in sqlite3 database in swift 4

  12. 12

    Is it better to use a crowded 2.4GHz Wi-Fi channel 1, 6, 11 or "unused" 3, 4, 8, or 9?

  13. 13

    how to fix SQL syntax error...upto...for the right syntax to use near '())' at line 1

  14. 14

    cryptsetup luksFormat error "Device /dev/nvme0n1p3 is in use. Can not proceed with format operation."

  15. 15

    Skip List in Redis why use p=1/4 not 1/e?

  16. 16

    Glide v4 / OkHttp3でリダイレクトを検出する方法は?

  17. 17

    a=3,2,1; gives error in gcc

  18. 18

    Android Glide: How to download and cache bitmaps?

  19. 19

    How to fit Image into ImageView using Glide

  20. 20

    How to use wxPython for Python 3?

  21. 21

    シーケンス0、0、0、0、0、1、1、1、1、1、2、2、2、2、2、3、3、3、3、3、4、4、4、4を作成します。 、4 with seq()

  22. 22

    R forループベクトル1,2,2,3,3,3,4,4,4,4、..、10、

  23. 23

    Glide 4でGlideModuleを使用する方法は?

  24. 24

    シリーズ1、2、1、3、2、1、4、3、2、1、5、4、3、2、1を生成する

  25. 25

    How to use gstreamer for transcoding and resizing from mp4(h264/aac) to mp4(h264/mp3)?

  26. 26

    How can I use Realm with Swift 4?

  27. 27

    How to use Multiple Tables in Codeigniter 4

  28. 28

    How to use OR in Rails 4 ActiveRecord named scope

  29. 29

    How to install and use beautifulsoup4

ホットタグ

アーカイブ