pull/457/head
gedoor 4 years ago
parent 09c5cbb593
commit 4e5d8db518
  1. 2
      app/src/main/java/io/legado/app/ui/filepicker/adapter/FileAdapter.kt
  2. 7
      app/src/main/java/io/legado/app/ui/filepicker/adapter/PathAdapter.kt

@ -49,7 +49,7 @@ class FileAdapter(context: Context, val callBack: CallBack) :
fileRoot.path = rootPath ?: path fileRoot.path = rootPath ?: path
data.add(fileRoot) data.add(fileRoot)
} }
if (callBack.isShowUpDir && path != "/") { if (callBack.isShowUpDir && path != PathAdapter.sdCardDirectory) {
//添加“返回上一级目录” //添加“返回上一级目录”
val fileParent = FileItem() val fileParent = FileItem()
fileParent.isDirectory = true fileParent.isDirectory = true

@ -15,8 +15,6 @@ import java.util.*
class PathAdapter(context: Context, val callBack: CallBack) : class PathAdapter(context: Context, val callBack: CallBack) :
SimpleRecyclerAdapter<String>(context, R.layout.item_path_filepicker) { SimpleRecyclerAdapter<String>(context, R.layout.item_path_filepicker) {
private val paths = LinkedList<String>() private val paths = LinkedList<String>()
@Suppress("DEPRECATION")
private val sdCardDirectory = Environment.getExternalStorageDirectory().absolutePath
private val arrowIcon = ConvertUtils.toDrawable(FilePickerIcon.getArrow()) private val arrowIcon = ConvertUtils.toDrawable(FilePickerIcon.getArrow())
fun getPath(position: Int): String { fun getPath(position: Int): String {
@ -37,7 +35,7 @@ class PathAdapter(context: Context, val callBack: CallBack) :
paths.clear() paths.clear()
if (path1 != "/" && path1 != "") { if (path1 != "/" && path1 != "") {
val subDirs = path1.substring(path1.indexOf("/") + 1) val subDirs = path1.substring(path1.indexOf("/") + 1)
.split("/".toRegex()) .split("/")
.dropLastWhile { it.isEmpty() } .dropLastWhile { it.isEmpty() }
.toTypedArray() .toTypedArray()
Collections.addAll(paths, *subDirs) Collections.addAll(paths, *subDirs)
@ -65,5 +63,8 @@ class PathAdapter(context: Context, val callBack: CallBack) :
companion object { companion object {
private const val ROOT_HINT = "SD" private const val ROOT_HINT = "SD"
@Suppress("DEPRECATION")
val sdCardDirectory = Environment.getExternalStorageDirectory().absolutePath
} }
} }

Loading…
Cancel
Save