0

I am fetching countries' flag using a RestFul api, images are in svg formate so glide does not support svg format.

Glide.with(context)
            .load(countriesListObj.getFlag())
            .apply(RequestOptions.circleCropTransform())
            .into(holder.countryFlag);

I found other solutions for the svg

  GlideToVectorYou
            .init()
            .with(this)
            .withListener(new GlideToVectorYouListener() {
                @Override
                public void onLoadFailed() {
                    Toast.makeText(context, "Load failed", Toast.LENGTH_SHORT).show()
                }

                @Override
                public void onResourceReady() {
                    Toast.makeText(context, "Image ready", Toast.LENGTH_SHORT).show()
                }
            })
            .setPlaceHolder(placeholderLoading, placeholderError)
            .load(IMAGE_URL, imageview); 

here is another way

 SvgLoader.pluck()
            .with(activity))
            .setPlaceHolder(R.mipmap.ic_launcher, R.mipmap.ic_launcher)
            .load("http://www.clker.com/cliparts/u/Z/2/b/a/6/android-toy-h.svg", image);

I have found other too, but every method is passing Activity

(.with(activity)))

and in glide we pass context. I am casting context to activity as

(Activity) context;

but it shows error

java.lang.NoSuchMethodError: No static method buildStreamModelLoader(Ljava/lang/Class;Landroid/content/Context;)Lcom/bumptech/glide/load/model/ModelLoader; in class Lcom/bumptech/glide/Glide; or its super classes (declaration of 'com.bumptech.glide.Glide' appears in /data/app/com.abc.online-NgaithsDmCnw4eJKDV789==/split_lib_dependencies_apk.apk)

Zoe
  • 27,060
  • 21
  • 118
  • 148
M.ArslanKhan
  • 3,640
  • 8
  • 34
  • 56
  • https://stackoverflow.com/a/35508121/6819340 – Darshan May 04 '19 at 06:34
  • @DarShan I have asked question regarding context and Activity, if we {with(activity)} and with((Actvity)context) whats the difference?, how we can get Actvity from the context, and I have also tested by passing activity to the construct of adapter but still we have same issue – M.ArslanKhan May 04 '19 at 06:39
  • no difference, an `Activity` is a `Context`, however a `Context` is not always an `Activity`. You can add an `Activity` param in the Adapter constructor and use that reference {with(activity)} – Darshan May 04 '19 at 10:12

0 Answers0