0

I am trying to load a .9.png from filesDir() that I have previously downloaded from a server into a View:

Glide.with(context).asDrawable().load(f.absolutePath).dontTransform().into(object : CustomTarget<Drawable>() {
            override fun onLoadStarted(placeholder: Drawable?) {
                super.onLoadStarted(placeholder)
                Log.v("DRAWABLE_TEST", "onLoadStarted")
            }

            override fun onLoadFailed(errorDrawable: Drawable?) {
                super.onLoadFailed(errorDrawable)
                Log.e("DRAWABLE_TEST", "onLoadFailed")
            }

            override fun onResourceReady(resource: Drawable, transition: Transition<in Drawable>?) {
                Log.v("DRAWABLE_TEST", "onResourceReady")
                view.background = resource
            }

            override fun onLoadCleared(placeholder: Drawable?) {
            }
        })

But I get only normal drawable that is stretched.

Any idea how should I load it?

filipst
  • 1,547
  • 1
  • 30
  • 55

1 Answers1

0

Ok, I have managed to do it, but not with Glide:

val bmp = BitmapFactory.decodeFile(f.absolutePath)
val chunk = bmp.ninePatchChunk
val ninePatchDrawable = NinePatchDrawable(context.resources, bmp, chunk, Rect(), null)

However, before downloading the *.9.png images they should be build in some APK and then uploaded to the server. Source here

filipst
  • 1,547
  • 1
  • 30
  • 55