kunfei 4 лет назад
Родитель
Сommit
5db6ce80a2

+ 1 - 1
app/src/main/java/io/legado/app/ui/book/remote/RemoteBook.kt

@@ -2,7 +2,7 @@ package io.legado.app.ui.book.remote
 
 data class RemoteBook(
     val filename: String,
-    val urlName: String,
+    val path: String,
     val size: Long,
     val contentType: String,
     val lastModify: Long,

+ 4 - 0
app/src/main/java/io/legado/app/ui/book/remote/RemoteBookActivity.kt

@@ -67,6 +67,10 @@ class RemoteBookActivity : VMBaseActivity<ActivityRemoteBookBinding, RemoteBookV
         return super.onCompatOptionsItemSelected(item)
     }
 
+    override fun openDir(url: String) {
+
+    }
+
     @SuppressLint("NotifyDataSetChanged")
     override fun addToBookshelf(remoteBook: RemoteBook) {
         waitDialog.show()

+ 2 - 1
app/src/main/java/io/legado/app/ui/book/remote/RemoteBookAdapter.kt

@@ -51,7 +51,7 @@ class RemoteBookAdapter (context: Context, val callBack: CallBack) :
         binding.btnDownload.setOnClickListener {
                 getItem(holder.layoutPosition)?.let {
                     if (it.isDir) {
-
+                        callBack.openDir(it.path)
                     } else {
                         callBack.addToBookshelf(it)
                     }
@@ -61,6 +61,7 @@ class RemoteBookAdapter (context: Context, val callBack: CallBack) :
     }
 
     interface CallBack {
+        fun openDir(url: String)
         fun addToBookshelf(remoteBook: RemoteBook)
     }
 }

+ 3 - 5
app/src/main/java/io/legado/app/ui/book/remote/manager/RemoteBookWebDav.kt

@@ -45,14 +45,12 @@ object RemoteBookWebDav : RemoteBookManager() {
             //转化远程文件信息到本地对象
             remoteWebDavFileList.forEach { webDavFile ->
                 var webDavFileName = webDavFile.displayName
-                var webDavUrlName = "${remoteBookUrl}${File.separator}${webDavFile.displayName}"
                 webDavFileName = URLDecoder.decode(webDavFileName, "utf-8")
-                webDavUrlName = URLDecoder.decode(webDavUrlName, "utf-8")
 
                 if (webDavFile.isDir) {
                     remoteBooks.add(
                         RemoteBook(
-                            webDavFileName, webDavUrlName, webDavFile.size,
+                            webDavFileName, webDavFile.path, webDavFile.size,
                             "folder", webDavFile.lastModify, false
                         )
                     )
@@ -65,7 +63,7 @@ object RemoteBookWebDav : RemoteBookManager() {
                         val isOnBookShelf = LocalBook.isOnBookShelf(webDavFileName)
                         remoteBooks.add(
                             RemoteBook(
-                                webDavFileName, webDavUrlName, webDavFile.size,
+                                webDavFileName, webDavFile.path, webDavFile.size,
                                 fileExtension, webDavFile.lastModify, isOnBookShelf
                             )
                         )
@@ -81,7 +79,7 @@ object RemoteBookWebDav : RemoteBookManager() {
      */
     override suspend fun getRemoteBook(remoteBook: RemoteBook): Uri? {
         return AppWebDav.authorization?.let {
-            val webdav = WebDav(remoteBook.urlName, it)
+            val webdav = WebDav(remoteBook.path, it)
             webdav.download().let { bytes ->
                 LocalBook.saveBookFile(bytes, remoteBook.filename)
             }