mirror of
https://github.com/gedoor/legado.git
synced 2024-08-30 09:23:26 +08:00
优化
This commit is contained in:
parent
6cd087be87
commit
aabb73477e
@ -263,6 +263,8 @@ class CacheActivity : VMBaseActivity<ActivityCacheBookBinding, CacheViewModel>()
|
|||||||
val path = ACache.get().getAsString(exportBookPathKey)
|
val path = ACache.get().getAsString(exportBookPathKey)
|
||||||
if (path.isNullOrEmpty()) {
|
if (path.isNullOrEmpty()) {
|
||||||
selectExportFolder(position)
|
selectExportFolder(position)
|
||||||
|
} else if (FileDoc.fromUri(path.parseToUri(), true).checkWrite() != true) {
|
||||||
|
selectExportFolder(position)
|
||||||
} else if (enableCustomExport()) {// 启用自定义导出 and 导出类型为Epub
|
} else if (enableCustomExport()) {// 启用自定义导出 and 导出类型为Epub
|
||||||
configExportSection(path, position)
|
configExportSection(path, position)
|
||||||
} else {
|
} else {
|
||||||
|
@ -274,7 +274,7 @@ class BackupConfigFragment : PreferenceFragment(),
|
|||||||
if (backupPath.isContentScheme()) {
|
if (backupPath.isContentScheme()) {
|
||||||
val uri = Uri.parse(backupPath)
|
val uri = Uri.parse(backupPath)
|
||||||
val doc = DocumentFile.fromTreeUri(requireContext(), uri)
|
val doc = DocumentFile.fromTreeUri(requireContext(), uri)
|
||||||
if (doc?.canWrite() == true) {
|
if (doc?.checkWrite() == true) {
|
||||||
waitDialog.setText("备份中…")
|
waitDialog.setText("备份中…")
|
||||||
waitDialog.setOnCancelListener {
|
waitDialog.setOnCancelListener {
|
||||||
backupJob?.cancel()
|
backupJob?.cancel()
|
||||||
|
@ -287,6 +287,16 @@ fun FileDoc.delete() {
|
|||||||
asDocumentFile()?.delete()
|
asDocumentFile()?.delete()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun FileDoc.checkWrite(): Boolean? {
|
||||||
|
if (!isDir) {
|
||||||
|
throw NoStackTraceException("只能检查目录")
|
||||||
|
}
|
||||||
|
asFile()?.let {
|
||||||
|
return it.checkWrite()
|
||||||
|
}
|
||||||
|
return asDocumentFile()?.checkWrite()
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DocumentFile 的 listFiles() 非常的慢,尽量不要使用
|
* DocumentFile 的 listFiles() 非常的慢,尽量不要使用
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user