tweak the photo fragment a bit
This commit is contained in:
parent
7b9503229f
commit
c564e63135
1 changed files with 41 additions and 36 deletions
|
@ -7,6 +7,7 @@ import android.os.Bundle
|
|||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.load.DecodeFormat
|
||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||
|
@ -22,28 +23,28 @@ import kotlinx.android.synthetic.main.pager_photo_item.view.*
|
|||
|
||||
class PhotoFragment : ViewPagerFragment() {
|
||||
lateinit var medium: Medium
|
||||
lateinit var mView: View
|
||||
lateinit var subsamplingView: SubsamplingScaleImageView
|
||||
lateinit var glideView: ImageView
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||
mView = inflater.inflate(R.layout.pager_photo_item, container, false)
|
||||
val view = inflater.inflate(R.layout.pager_photo_item, container, false)
|
||||
|
||||
medium = arguments.getSerializable(MEDIUM) as Medium
|
||||
if (medium.path.startsWith("content://"))
|
||||
medium.path = context.getRealPathFromURI(Uri.parse(medium.path)) ?: ""
|
||||
|
||||
subsamplingView = view.photo_view.apply { setOnClickListener({ photoClicked() }) }
|
||||
glideView = view.glide_view.apply { setOnClickListener({ photoClicked() }) }
|
||||
loadImage(medium)
|
||||
|
||||
activity.window.decorView.setOnSystemUiVisibilityChangeListener { visibility ->
|
||||
listener?.systemUiVisibilityChanged(visibility)
|
||||
}
|
||||
|
||||
return mView
|
||||
return view
|
||||
}
|
||||
|
||||
private fun loadImage(medium: Medium) {
|
||||
val subsamplingView = mView.photo_view.apply { setOnClickListener({ photoClicked() }) }
|
||||
val glideView = mView.glide_view.apply { setOnClickListener({ photoClicked() }) }
|
||||
|
||||
if (medium.isGif()) {
|
||||
Glide.with(this)
|
||||
.load(medium.path)
|
||||
|
@ -62,6 +63,14 @@ class PhotoFragment : ViewPagerFragment() {
|
|||
}
|
||||
|
||||
override fun onResourceReady(resource: Bitmap?, model: String?, target: Target<Bitmap>?, isFromMemoryCache: Boolean, isFirstResource: Boolean): Boolean {
|
||||
addZoomableView()
|
||||
return false
|
||||
}
|
||||
}).into(glideView)
|
||||
}
|
||||
}
|
||||
|
||||
private fun addZoomableView() {
|
||||
if (!medium.isPng()) {
|
||||
subsamplingView.visibility = View.VISIBLE
|
||||
subsamplingView.apply {
|
||||
|
@ -75,7 +84,7 @@ class PhotoFragment : ViewPagerFragment() {
|
|||
|
||||
override fun onReady() {
|
||||
glideView.visibility = View.GONE
|
||||
subsamplingView.visibility = View.VISIBLE
|
||||
glideView.setImageBitmap(null)
|
||||
}
|
||||
|
||||
override fun onTileLoadError(p0: Exception?) {
|
||||
|
@ -92,10 +101,6 @@ class PhotoFragment : ViewPagerFragment() {
|
|||
})
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
}).into(glideView)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onConfigurationChanged(newConfig: Configuration?) {
|
||||
|
|
Loading…
Reference in a new issue