Compare commits
2 Commits
c09a32e9ad
...
dbe97f564e
Author | SHA1 | Date | |
---|---|---|---|
dbe97f564e | |||
|
3a3bf03114 |
@ -1,23 +1,21 @@
|
||||
package bou.amine.apps.readerforselfossv2.android.fragments
|
||||
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.graphics.drawable.LayerDrawable
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.Fragment
|
||||
import bou.amine.apps.readerforselfossv2.android.R
|
||||
import bou.amine.apps.readerforselfossv2.android.databinding.FragmentImageBinding
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.request.target.ImageViewTarget
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||
import com.bumptech.glide.request.RequestOptions
|
||||
|
||||
class ImageFragment : Fragment() {
|
||||
|
||||
private lateinit var imageUrl : String
|
||||
private val glideOptions = RequestOptions.diskCacheStrategyOf(DiskCacheStrategy.ALL)
|
||||
private var _binding: FragmentImageBinding? = null
|
||||
private val binding get() = _binding
|
||||
private lateinit var layers: LayerDrawable
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
@ -31,18 +29,10 @@ class ImageFragment : Fragment() {
|
||||
|
||||
binding!!.photoView.visibility = View.VISIBLE
|
||||
Glide.with(activity)
|
||||
.asBitmap()
|
||||
.apply(glideOptions)
|
||||
.load(imageUrl)
|
||||
.into(object : ImageViewTarget<Drawable>(binding!!.photoView) {
|
||||
override fun setResource(resource: Drawable?) {
|
||||
val background = resources.getDrawable(R.drawable.checkerboard, context?.theme)
|
||||
layers = LayerDrawable(arrayOf(background, resource))
|
||||
binding!!.photoView.setImageDrawable(layers)
|
||||
}
|
||||
|
||||
override fun onLoadCleared(placeholder: Drawable?) {
|
||||
layers = LayerDrawable(emptyArray())
|
||||
}
|
||||
})
|
||||
.into(binding!!.photoView)
|
||||
|
||||
return view
|
||||
}
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 98 B After Width: | Height: | Size: 235 B |
@ -10,7 +10,7 @@
|
||||
android:layout_height="match_parent"
|
||||
android:layout_centerVertical="true"
|
||||
android:adjustViewBounds="true"
|
||||
android:background="?attr/colorOnBackground"
|
||||
android:background="@drawable/checkerboard"
|
||||
app:srcCompat="@android:drawable/screen_background_dark" />
|
||||
|
||||
</RelativeLayout>
|
Loading…
Reference in New Issue
Block a user