Skip to content

Commit

Permalink
[Fix] Fix blank screen after deletion when we have offscreenPageLimit…
Browse files Browse the repository at this point in the history
… = 1.
  • Loading branch information
zhanghai committed Sep 25, 2023
1 parent c31e095 commit 0b432da
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.doOnPreDraw
import androidx.fragment.app.Fragment
import androidx.interpolator.view.animation.FastOutSlowInInterpolator
import androidx.viewpager2.widget.ViewPager2
Expand Down Expand Up @@ -179,6 +180,9 @@ class ImageViewerFragment : Fragment(), ConfirmDeleteDialogFragment.Listener {
binding.viewPager.currentItem = paths.lastIndex
}
updateTitle()
// Work around blank screen due to ViewPager2.PageTransformer not being called (and thus the
// next item keeps its 0 alpha) when we have offscreenPageLimit = 1.
binding.viewPager.doOnPreDraw { binding.viewPager.requestTransform() }
}

private fun updateTitle() {
Expand Down

0 comments on commit 0b432da

Please sign in to comment.