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

remove glide from photo

parent 23fc8814
...@@ -46,7 +46,7 @@ class PhotoScreenController : ...@@ -46,7 +46,7 @@ class PhotoScreenController :
private fun bindRecycler() { private fun bindRecycler() {
photoViewPager.isNestedScrollingEnabled = false photoViewPager.isNestedScrollingEnabled = false
photoViewPager.offscreenPageLimit = 2 photoViewPager.offscreenPageLimit = 1
photoViewPager.adapter = PhotosAdapter() photoViewPager.adapter = PhotosAdapter()
setVewPager() setVewPager()
} }
......
...@@ -11,10 +11,11 @@ import com.biganto.visual.roompark.domain.model.PhotoModel ...@@ -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.domain.model.PhotoResolutionModel
import com.biganto.visual.roompark.presentation.screen.settings.util.CommonRecyclerAdapter import com.biganto.visual.roompark.presentation.screen.settings.util.CommonRecyclerAdapter
import com.biganto.visual.roompark.presentation.screen.settings.util.CommonViewHolder 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.github.chrisbanes.photoview.PhotoView
import com.google.android.material.textview.MaterialTextView import com.google.android.material.textview.MaterialTextView
import timber.log.Timber import timber.log.Timber
import javax.security.auth.callback.Callback
import kotlin.math.absoluteValue import kotlin.math.absoluteValue
/** /**
...@@ -64,54 +65,26 @@ class PhotosViewHolder(itemView: View) : CommonViewHolder<PhotoModel>(itemView) ...@@ -64,54 +65,26 @@ class PhotosViewHolder(itemView: View) : CommonViewHolder<PhotoModel>(itemView)
description.visibility = if (model.description != null) View.VISIBLE else View.GONE description.visibility = if (model.description != null) View.VISIBLE else View.GONE
model.description?.let { description.text = it } model.description?.let { description.text = it }
model.resolutionList.lowelest()?.let { model.resolutionList
picassoAsync .minBy {
.load(it.url) ((windowSize.x - it.resWidth + .1f).absoluteValue
.centerCrop() + (windowSize.y - it.resHeight + .1f).absoluteValue
.fit() )
.into(photoPreview, object :Callback, com.squareup.picasso.Callback { }
override fun onSuccess() { ?.let { photo ->
model.resolutionList Timber.d("val: ${photo.resWidth} : ${photo.resHeight}")
.onEach { Timber.d("val ensure: ${it.resWidth} : ${it.resHeight}") } Glide.with(photoPreview)
.minBy { .load(photo.url)
((windowSize.x - it.resWidth + .1f).absoluteValue .thumbnail(model.resolutionList.lowelest()?.let { thumb ->
+ (windowSize.y - it.resHeight + .1f).absoluteValue Glide.with(photoPreview).load(thumb.url).diskCacheStrategy(DiskCacheStrategy.ALL)
) })
} .diskCacheStrategy(DiskCacheStrategy.ALL)
?.let {photo -> .into(photoPreview)
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)
}
}
})
}
} }
} }
private fun List<PhotoResolutionModel>.lowelest() = private fun List<PhotoResolutionModel>.lowelest() =
this.minBy { it.resWidth * it.resHeight } 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