Commit ec6d3fc0 authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

remove glide from photo

parent 23fc8814
......@@ -46,7 +46,7 @@ class PhotoScreenController :
private fun bindRecycler() {
photoViewPager.isNestedScrollingEnabled = false
photoViewPager.offscreenPageLimit = 2
photoViewPager.offscreenPageLimit = 1
photoViewPager.adapter = PhotosAdapter()
setVewPager()
}
......
......@@ -11,10 +11,11 @@ import com.biganto.visual.roompark.domain.model.PhotoModel
import com.biganto.visual.roompark.domain.model.PhotoResolutionModel
import com.biganto.visual.roompark.presentation.screen.settings.util.CommonRecyclerAdapter
import com.biganto.visual.roompark.presentation.screen.settings.util.CommonViewHolder
import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.github.chrisbanes.photoview.PhotoView
import com.google.android.material.textview.MaterialTextView
import timber.log.Timber
import javax.security.auth.callback.Callback
import kotlin.math.absoluteValue
/**
......@@ -64,54 +65,26 @@ class PhotosViewHolder(itemView: View) : CommonViewHolder<PhotoModel>(itemView)
description.visibility = if (model.description != null) View.VISIBLE else View.GONE
model.description?.let { description.text = it }
model.resolutionList.lowelest()?.let {
picassoAsync
.load(it.url)
.centerCrop()
.fit()
.into(photoPreview, object :Callback, com.squareup.picasso.Callback {
override fun onSuccess() {
model.resolutionList
.onEach { Timber.d("val ensure: ${it.resWidth} : ${it.resHeight}") }
.minBy {
((windowSize.x - it.resWidth + .1f).absoluteValue
+ (windowSize.y - it.resHeight + .1f).absoluteValue
)
}
?.let {photo ->
Timber.d("val: ${photo.resWidth} : ${photo.resHeight}")
picassoAsync
.load(photo.url)
.centerCrop()
.fit()
.into(photoPreview)
}
}
override fun onError(e: Exception?) {
model.resolutionList
.onEach { Timber.d("val ensure: ${it.resWidth} : ${it.resHeight}") }
.minBy {
((windowSize.x - it.resWidth + .1f).absoluteValue
+ (windowSize.y - it.resHeight + .1f).absoluteValue
)
}
?.let {
Timber.d("val: ${it.resWidth} : ${it.resHeight}")
picassoAsync
.load(it.url)
.centerCrop()
.fit()
.into(photoPreview)
}
}
})
}
model.resolutionList
.minBy {
((windowSize.x - it.resWidth + .1f).absoluteValue
+ (windowSize.y - it.resHeight + .1f).absoluteValue
)
}
?.let { photo ->
Timber.d("val: ${photo.resWidth} : ${photo.resHeight}")
Glide.with(photoPreview)
.load(photo.url)
.thumbnail(model.resolutionList.lowelest()?.let { thumb ->
Glide.with(photoPreview).load(thumb.url).diskCacheStrategy(DiskCacheStrategy.ALL)
})
.diskCacheStrategy(DiskCacheStrategy.ALL)
.into(photoPreview)
}
}
}
private fun List<PhotoResolutionModel>.lowelest() =
this.minBy { it.resWidth * it.resHeight }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment