0

I'm developing an app and I want to display ArrayList in GridView for that I use an adapter the object includes 3 Strings. number, hint, imageURL

I want to put each object in the GridView I successfully put the number and hint because it's just setText but with the ImageURL, I want to display Image in an ImageView but I can't figure out why my program doesn't work

I'm using Glide.with(context).load(roadSign.getImageURL()).into(SIGN_IMAGE_VIEW);

The function is in the Adapter class

I don't think the problem is in the function I think something is wrong with the Image so I'm adding everything related

https://www.codepile.net/pile/Qe1XpjG9

If you need any more information please comment below

Boris Azanov
  • 4,408
  • 1
  • 15
  • 28
Yaniv
  • 125
  • 2
  • 10
  • You can add a listener to glide to catch any error exception and log it: see https://stackoverflow.com/a/51965942/2711811 –  Dec 09 '20 at 16:56

4 Answers4

0

As far as I know, Glide takes context in Glide.with() so try this:

Glide.with(context).load(roadSign.getImageURL()).into(SIGN_IMAGE_VIEW);
MehranB
  • 1,460
  • 2
  • 7
  • 17
0
Glide.with(view).load(roadSign.getImageURL()).into(SIGN_IMAGE_VIEW); 

Try to do this and if the view doesn't work try to add convertview object....coz glide takes view object now

  @NonNull
  public static RequestManager with(@NonNull View view) {
    return getRetriever(view.getContext()).get(view);
  }
Zaraki596
  • 61
  • 8
0

The problem was that the image URL was HTTP and not HTTPs because I use android 8 and apparently it's not acceptable

Yaniv
  • 125
  • 2
  • 10
0

i dont know imageurl but as you answered it is the http permission problem. you should add the following for http request in

AndroidManifest.xml

<application
       android:usesCleartextTraffic="true"
           //....
           />

and always use the listener to find the exception error

  Glide.with(context)
 .load(roadSign.getImageURL())
  .listener(new RequestListener() {
   @Override
   boolean onLoadFailed(@Nullable GlideException e, Object model,    
     Log.e(TAG, "Load failed", e);
     return false; // Allow calling onLoadFailed on the Target.
   }

   @Override
   boolean onResourceReady(R resource, Object model, Target<R> target,
       DataSource dataSource, boolean isFirstResource) {
     // Log successes here or use DataSource to keep track of cache hits and misses.
     return false;
   }
})
.into(imageView);
Majid Ali
  • 485
  • 6
  • 17