|
|
@ -38,7 +38,7 @@ object BookHelp { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun clearCache() { |
|
|
|
fun clearCache() { |
|
|
|
if (downloadUri.isDocumentUri(App.INSTANCE)) { |
|
|
|
if (downloadPath.isContentPath()) { |
|
|
|
DocumentFile.fromTreeUri(App.INSTANCE, downloadUri) |
|
|
|
DocumentFile.fromTreeUri(App.INSTANCE, downloadUri) |
|
|
|
?.findFile(cacheFolderName) |
|
|
|
?.findFile(cacheFolderName) |
|
|
|
?.delete() |
|
|
|
?.delete() |
|
|
@ -55,7 +55,7 @@ object BookHelp { |
|
|
|
@Synchronized |
|
|
|
@Synchronized |
|
|
|
fun saveContent(book: Book, bookChapter: BookChapter, content: String) { |
|
|
|
fun saveContent(book: Book, bookChapter: BookChapter, content: String) { |
|
|
|
if (content.isEmpty()) return |
|
|
|
if (content.isEmpty()) return |
|
|
|
if (downloadUri.isDocumentUri(App.INSTANCE)) { |
|
|
|
if (downloadPath.isContentPath()) { |
|
|
|
DocumentFile.fromTreeUri(App.INSTANCE, downloadUri)?.let { root -> |
|
|
|
DocumentFile.fromTreeUri(App.INSTANCE, downloadUri)?.let { root -> |
|
|
|
DocumentUtils.getDirDocument( |
|
|
|
DocumentUtils.getDirDocument( |
|
|
|
root, |
|
|
|
root, |
|
|
@ -91,7 +91,7 @@ object BookHelp { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun getChapterCount(book: Book): Int { |
|
|
|
fun getChapterCount(book: Book): Int { |
|
|
|
if (downloadUri.isDocumentUri(App.INSTANCE)) { |
|
|
|
if (downloadPath.isContentPath()) { |
|
|
|
DocumentFile.fromTreeUri(App.INSTANCE, downloadUri)?.let { root -> |
|
|
|
DocumentFile.fromTreeUri(App.INSTANCE, downloadUri)?.let { root -> |
|
|
|
return DocumentUtils.createFolderIfNotExist( |
|
|
|
return DocumentUtils.createFolderIfNotExist( |
|
|
|
root, |
|
|
|
root, |
|
|
@ -112,7 +112,7 @@ object BookHelp { |
|
|
|
book.isLocalBook() -> { |
|
|
|
book.isLocalBook() -> { |
|
|
|
return true |
|
|
|
return true |
|
|
|
} |
|
|
|
} |
|
|
|
downloadUri.isDocumentUri(App.INSTANCE) -> { |
|
|
|
downloadPath.isContentPath() -> { |
|
|
|
DocumentFile.fromTreeUri(App.INSTANCE, downloadUri)?.let { root -> |
|
|
|
DocumentFile.fromTreeUri(App.INSTANCE, downloadUri)?.let { root -> |
|
|
|
return DocumentUtils.exists( |
|
|
|
return DocumentUtils.exists( |
|
|
|
root, |
|
|
|
root, |
|
|
@ -137,7 +137,7 @@ object BookHelp { |
|
|
|
book.isLocalBook() -> { |
|
|
|
book.isLocalBook() -> { |
|
|
|
return AnalyzeTxtFile.getContent(book, bookChapter) |
|
|
|
return AnalyzeTxtFile.getContent(book, bookChapter) |
|
|
|
} |
|
|
|
} |
|
|
|
downloadUri.isDocumentUri(App.INSTANCE) -> { |
|
|
|
downloadPath.isContentPath() -> { |
|
|
|
DocumentFile.fromTreeUri(App.INSTANCE, downloadUri)?.let { root -> |
|
|
|
DocumentFile.fromTreeUri(App.INSTANCE, downloadUri)?.let { root -> |
|
|
|
return DocumentUtils.getDirDocument( |
|
|
|
return DocumentUtils.getDirDocument( |
|
|
|
root, |
|
|
|
root, |
|
|
@ -163,7 +163,7 @@ object BookHelp { |
|
|
|
fun delContent(book: Book, bookChapter: BookChapter) { |
|
|
|
fun delContent(book: Book, bookChapter: BookChapter) { |
|
|
|
when { |
|
|
|
when { |
|
|
|
book.isLocalBook() -> return |
|
|
|
book.isLocalBook() -> return |
|
|
|
downloadUri.isDocumentUri(App.INSTANCE) -> { |
|
|
|
downloadPath.isContentPath() -> { |
|
|
|
DocumentFile.fromTreeUri(App.INSTANCE, downloadUri)?.let { root -> |
|
|
|
DocumentFile.fromTreeUri(App.INSTANCE, downloadUri)?.let { root -> |
|
|
|
DocumentUtils.getDirDocument( |
|
|
|
DocumentUtils.getDirDocument( |
|
|
|
root, |
|
|
|
root, |
|
|
|