implement navigation between grouped direct subfolders

This commit is contained in:
tibbi 2018-12-15 22:32:11 +01:00
parent 59c6f91100
commit ce4dee2573

View file

@ -67,6 +67,7 @@ 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 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
@ -920,8 +921,12 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
val currentPaths = LinkedHashSet<String>() val currentPaths = LinkedHashSet<String>()
folders.forEach { folders.forEach {
val path = it val path = it
if (path != internalPath && path != sdPath) { if (!path.equals(internalPath, true) && !path.equals(sdPath, true)) {
if (folders.any { it != path && (File(path).parent == it || File(it).parent == File(path).parent) }) { if (mCurrentPathPrefix.isNotEmpty()) {
if (File(path).parent.equals(mCurrentPathPrefix, true) || path == mCurrentPathPrefix) {
currentPaths.add(path)
}
} else if (folders.any { !it.equals(path, true) && (File(path).parent.equals(it, true) || File(it).parent.equals(File(path).parent, true)) }) {
val parent = File(path).parent val parent = File(path).parent
currentPaths.add(parent) currentPaths.add(parent)
} else { } else {
@ -934,12 +939,16 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
currentPaths.forEach { currentPaths.forEach {
val path = it val path = it
currentPaths.forEach { currentPaths.forEach {
if (it != path && File(it).parent == path) { if (!it.equals(path) && File(it).parent.equals(path)) {
areDirectSubfoldersAvailable = true areDirectSubfoldersAvailable = true
} }
} }
} }
if (folders.size == currentPaths.size) {
return currentPaths
}
folders.clear() folders.clear()
folders.addAll(currentPaths) folders.addAll(currentPaths)
return if (areDirectSubfoldersAvailable) { return if (areDirectSubfoldersAvailable) {
@ -1035,11 +1044,14 @@ class MainActivity : SimpleActivity(), DirectoryOperationsListener {
val fastscroller = if (config.scrollHorizontally) directories_horizontal_fastscroller else directories_vertical_fastscroller val fastscroller = if (config.scrollHorizontally) directories_horizontal_fastscroller else directories_vertical_fastscroller
DirectoryAdapter(this, dirsToShow, this, directories_grid, isPickIntent(intent) || isGetAnyContentIntent(intent), fastscroller) { DirectoryAdapter(this, dirsToShow, this, directories_grid, isPickIntent(intent) || isGetAnyContentIntent(intent), fastscroller) {
val clickedDir = it as Directory val clickedDir = it as Directory
if (clickedDir.subfoldersCount == 1 || !config.groupDirectSubfolders) {
val path = clickedDir.path val path = clickedDir.path
if (clickedDir.subfoldersCount == 1 || !config.groupDirectSubfolders) {
if (path != config.tempFolderPath) { if (path != config.tempFolderPath) {
itemClicked(path) itemClicked(path)
} }
} else {
mCurrentPathPrefix = path
setupAdapter(mDirs, "")
} }
}.apply { }.apply {
setupZoomListener(mZoomListener) setupZoomListener(mZoomListener)