This commit is contained in:
parent
c09a32e9ad
commit
3a3bf03114
@ -1,23 +1,18 @@
|
||||
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
|
||||
|
||||
class ImageFragment : Fragment() {
|
||||
|
||||
private lateinit var imageUrl : String
|
||||
private var _binding: FragmentImageBinding? = null
|
||||
private val binding get() = _binding
|
||||
private lateinit var layers: LayerDrawable
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
@ -32,17 +27,7 @@ class ImageFragment : Fragment() {
|
||||
binding!!.photoView.visibility = View.VISIBLE
|
||||
Glide.with(activity)
|
||||
.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