pull/1990/head
kunfei 2 years ago
parent 6619a3a97c
commit c9ccda2ca7
  1. 2
      app/src/main/java/io/legado/app/ui/book/remote/RemoteBook.kt
  2. 4
      app/src/main/java/io/legado/app/ui/book/remote/RemoteBookActivity.kt
  3. 3
      app/src/main/java/io/legado/app/ui/book/remote/RemoteBookAdapter.kt
  4. 8
      app/src/main/java/io/legado/app/ui/book/remote/manager/RemoteBookWebDav.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,

@ -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()

@ -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)
}
}

@ -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)
}

Loading…
Cancel
Save