Glimpse: Preserve last seen media position
Otherwise resuming the fragment will go back to the original media. Change-Id: I9433f353782afb0ae006de4d2906842299f34e82
This commit is contained in:
parent
321615afe5
commit
6984c7d35f
|
@ -81,13 +81,15 @@ class MediaViewerFragment : Fragment(
|
||||||
private val loaderManagerInstance by lazy { LoaderManager.getInstance(this) }
|
private val loaderManagerInstance by lazy { LoaderManager.getInstance(this) }
|
||||||
|
|
||||||
// Arguments
|
// Arguments
|
||||||
private val position by lazy { arguments?.getInt(KEY_POSITION, -1)!! }
|
private var position = -1
|
||||||
private val album by lazy { arguments?.getParcelable(KEY_ALBUM, Album::class) }
|
private val album by lazy { arguments?.getParcelable(KEY_ALBUM, Album::class) }
|
||||||
|
|
||||||
private val onPageChangeCallback = object : OnPageChangeCallback() {
|
private val onPageChangeCallback = object : OnPageChangeCallback() {
|
||||||
override fun onPageSelected(position: Int) {
|
override fun onPageSelected(position: Int) {
|
||||||
super.onPageSelected(position)
|
super.onPageSelected(position)
|
||||||
|
|
||||||
|
this@MediaViewerFragment.position = position
|
||||||
|
|
||||||
val media = mediaViewerAdapter.getMediaFromMediaStore(position) ?: return
|
val media = mediaViewerAdapter.getMediaFromMediaStore(position) ?: return
|
||||||
|
|
||||||
dateTextView.text = dateFormatter.format(media.dateAdded)
|
dateTextView.text = dateFormatter.format(media.dateAdded)
|
||||||
|
@ -98,6 +100,8 @@ class MediaViewerFragment : Fragment(
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
|
position = arguments?.getInt(KEY_POSITION, -1)!!
|
||||||
|
|
||||||
backButton.setOnClickListener {
|
backButton.setOnClickListener {
|
||||||
findNavController().popBackStack()
|
findNavController().popBackStack()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue