preload just 1 fullscreen image per side, with more dynamic resolution
This commit is contained in:
parent
2100004168
commit
e1ddcda524
|
@ -54,6 +54,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
|||
companion object {
|
||||
var screenWidth = 0
|
||||
var screenHeight = 0
|
||||
var screenDensity = 0f
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
@ -174,13 +175,13 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
|||
windowManager.defaultDisplay.getMetrics(metrics)
|
||||
screenWidth = metrics.widthPixels
|
||||
screenHeight = metrics.heightPixels
|
||||
screenDensity = metrics.density
|
||||
}
|
||||
|
||||
private fun updatePagerItems() {
|
||||
val pagerAdapter = MyPagerAdapter(this, supportFragmentManager, mMedia)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && !isDestroyed) {
|
||||
view_pager?.apply {
|
||||
offscreenPageLimit = 2
|
||||
adapter = pagerAdapter
|
||||
currentItem = mPos
|
||||
addOnPageChangeListener(this@ViewPagerActivity)
|
||||
|
|
|
@ -134,9 +134,10 @@ class PhotoFragment : ViewPagerFragment() {
|
|||
}
|
||||
|
||||
private fun loadBitmap(degrees: Float = 0f) {
|
||||
val densiy = ViewPagerActivity.screenDensity
|
||||
Picasso.with(activity)
|
||||
.load("file:${medium.path}")
|
||||
.resize(ViewPagerActivity.screenWidth * 2, ViewPagerActivity.screenHeight * 2)
|
||||
.resize((ViewPagerActivity.screenWidth * densiy).toInt(), (ViewPagerActivity.screenHeight * densiy).toInt())
|
||||
.priority(if (isFragmentVisible) Picasso.Priority.HIGH else Picasso.Priority.LOW)
|
||||
.rotate(degrees)
|
||||
.centerInside()
|
||||
|
|
Loading…
Reference in New Issue