修复低版本手机打开本地文件出错的bug

pull/1500/head
gedoor 3 years ago
parent ecb2496cbf
commit 707ead85d8
  1. 6
      app/src/main/java/io/legado/app/model/localBook/LocalBook.kt

@ -31,11 +31,11 @@ object LocalBook {
@Throws(FileNotFoundException::class, SecurityException::class) @Throws(FileNotFoundException::class, SecurityException::class)
fun getBookInputStream(book: Book): InputStream { fun getBookInputStream(book: Book): InputStream {
if (book.bookUrl.isContentScheme()) { val uri = Uri.parse(book.bookUrl)
val uri = Uri.parse(book.bookUrl) if (uri.isContentScheme()) {
return appCtx.contentResolver.openInputStream(uri)!! return appCtx.contentResolver.openInputStream(uri)!!
} }
return FileInputStream(File(book.bookUrl)) return FileInputStream(File(uri.path!!))
} }
@Throws(Exception::class) @Throws(Exception::class)

Loading…
Cancel
Save