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