improve portrait file recognizing
This commit is contained in:
parent
3bdca11698
commit
740a19e594
|
@ -266,7 +266,18 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!File(mPath).exists()) {
|
if (mPath.isPortrait() && getPortraitPath() == "") {
|
||||||
|
val newIntent = Intent(this, ViewPagerActivity::class.java)
|
||||||
|
newIntent.putExtras(intent!!.extras!!)
|
||||||
|
newIntent.putExtra(PORTRAIT_PATH, mPath)
|
||||||
|
newIntent.putExtra(PATH, "${mPath.getParentPath().getParentPath()}/${mPath.getFilenameFromPath()}")
|
||||||
|
|
||||||
|
startActivity(newIntent)
|
||||||
|
finish()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!File(mPath).exists() && getPortraitPath() == "") {
|
||||||
finish()
|
finish()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -671,6 +682,8 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
|
|
||||||
private fun getCurrentPhotoFragment() = getCurrentFragment() as? PhotoFragment
|
private fun getCurrentPhotoFragment() = getCurrentFragment() as? PhotoFragment
|
||||||
|
|
||||||
|
private fun getPortraitPath() = intent.getStringExtra(PORTRAIT_PATH) ?: ""
|
||||||
|
|
||||||
private fun isShowHiddenFlagNeeded(): Boolean {
|
private fun isShowHiddenFlagNeeded(): Boolean {
|
||||||
val file = File(mPath)
|
val file = File(mPath)
|
||||||
if (file.isHidden) {
|
if (file.isHidden) {
|
||||||
|
@ -1033,7 +1046,17 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
private fun getPositionInList(items: MutableList<Medium>): Int {
|
private fun getPositionInList(items: MutableList<Medium>): Int {
|
||||||
mPos = 0
|
mPos = 0
|
||||||
for ((i, medium) in items.withIndex()) {
|
for ((i, medium) in items.withIndex()) {
|
||||||
if (medium.path == mPath) {
|
val portraitPath = getPortraitPath()
|
||||||
|
if (portraitPath != "") {
|
||||||
|
val portraitPaths = File(portraitPath).parentFile?.list()
|
||||||
|
if (portraitPaths != null) {
|
||||||
|
for (path in portraitPaths) {
|
||||||
|
if (medium.name == path) {
|
||||||
|
return i
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (medium.path == mPath) {
|
||||||
return i
|
return i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,6 +127,7 @@ const val SET_WALLPAPER_INTENT = "set_wallpaper_intent"
|
||||||
const val IS_VIEW_INTENT = "is_view_intent"
|
const val IS_VIEW_INTENT = "is_view_intent"
|
||||||
const val PICKED_PATHS = "picked_paths"
|
const val PICKED_PATHS = "picked_paths"
|
||||||
const val SHOULD_INIT_FRAGMENT = "should_init_fragment"
|
const val SHOULD_INIT_FRAGMENT = "should_init_fragment"
|
||||||
|
const val PORTRAIT_PATH = "portrait_path"
|
||||||
|
|
||||||
// rotations
|
// rotations
|
||||||
const val ROTATE_BY_SYSTEM_SETTING = 0
|
const val ROTATE_BY_SYSTEM_SETTING = 0
|
||||||
|
|
Loading…
Reference in New Issue