implement Back navigation at direct subfolder grouping

This commit is contained in:
tibbi 2018-12-16 10:19:10 +01:00
parent a96e3201a3
commit adf02739fe

View file

@ -67,7 +67,8 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
private var mIsSearchOpen = false private var mIsSearchOpen = false
private var mLatestMediaId = 0L private var mLatestMediaId = 0L
private var mLatestMediaDateId = 0L private var mLatestMediaDateId = 0L
private var mCurrentPathPrefix = "" // used at "Group direct subfolders" for navigation private var mCurrentPathPrefix = "" // used at "Group direct subfolders" for navigation
private var mOpenedSubfolders = arrayListOf("") // used at "Group direct subfolders" for navigating Up with the back button
private var mLastMediaHandler = Handler() private var mLastMediaHandler = Handler()
private var mTempShowHiddenHandler = Handler() private var mTempShowHiddenHandler = Handler()
private var mZoomListener: MyRecyclerView.MyZoomListener? = null private var mZoomListener: MyRecyclerView.MyZoomListener? = null
@ -243,6 +244,20 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
} }
} }
override fun onBackPressed() {
if (config.groupDirectSubfolders) {
if (mCurrentPathPrefix.isEmpty()) {
super.onBackPressed()
} else {
mOpenedSubfolders.removeAt(mOpenedSubfolders.size - 1)
mCurrentPathPrefix = mOpenedSubfolders.last()
setupAdapter(mDirs)
}
} else {
super.onBackPressed()
}
}
override fun onCreateOptionsMenu(menu: Menu): Boolean { override fun onCreateOptionsMenu(menu: Menu): Boolean {
if (mIsThirdPartyIntent) { if (mIsThirdPartyIntent) {
menuInflater.inflate(R.menu.menu_main_intent, menu) menuInflater.inflate(R.menu.menu_main_intent, menu)
@ -1064,6 +1079,7 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
} }
} else { } else {
mCurrentPathPrefix = path mCurrentPathPrefix = path
mOpenedSubfolders.add(path)
setupAdapter(mDirs, "") setupAdapter(mDirs, "")
} }
}.apply { }.apply {