mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 14:37:59 +01:00
fix #74, properly set the viewpager position after delete
This commit is contained in:
parent
2c9c91396a
commit
de967340ad
1 changed files with 17 additions and 10 deletions
|
@ -38,7 +38,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
private var mDirectory = ""
|
private var mDirectory = ""
|
||||||
|
|
||||||
private var mIsFullScreen = false
|
private var mIsFullScreen = false
|
||||||
private var mPos = 0
|
private var mPos = -1
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
@ -73,8 +73,6 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
mPos = 0
|
|
||||||
mIsFullScreen = false
|
|
||||||
mMedia = ArrayList<Medium>()
|
mMedia = ArrayList<Medium>()
|
||||||
showSystemUI()
|
showSystemUI()
|
||||||
|
|
||||||
|
@ -246,13 +244,10 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
if (isDirEmpty())
|
if (isDirEmpty())
|
||||||
return@GetMediaAsynctask
|
return@GetMediaAsynctask
|
||||||
|
|
||||||
var j = 0
|
if (mPos == -1) {
|
||||||
for (medium in it) {
|
mPos = getProperPosition()
|
||||||
if (medium.path == mPath) {
|
} else {
|
||||||
mPos = j
|
mPos = Math.min(mPos, mMedia.size - 1)
|
||||||
break
|
|
||||||
}
|
|
||||||
j++
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updateActionbarTitle()
|
updateActionbarTitle()
|
||||||
|
@ -261,6 +256,18 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
}.execute()
|
}.execute()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getProperPosition(): Int {
|
||||||
|
mPos = 0
|
||||||
|
var i = 0
|
||||||
|
for (medium in mMedia) {
|
||||||
|
if (medium.path == mPath) {
|
||||||
|
return i
|
||||||
|
}
|
||||||
|
i++
|
||||||
|
}
|
||||||
|
return mPos
|
||||||
|
}
|
||||||
|
|
||||||
private fun deleteDirectoryIfEmpty() {
|
private fun deleteDirectoryIfEmpty() {
|
||||||
val file = File(mDirectory)
|
val file = File(mDirectory)
|
||||||
if (file.isDirectory && file.listFiles().isEmpty()) {
|
if (file.isDirectory && file.listFiles().isEmpty()) {
|
||||||
|
|
Loading…
Reference in a new issue