From ab38641a9d418428e57661b3d4180a13f4e928dc Mon Sep 17 00:00:00 2001 From: 1552980358 <1552980358@qq.com> Date: Wed, 9 Sep 2020 10:21:27 +0800 Subject: [PATCH] ReaderProvider.kt: Modify initial process of `sMatcher` Signed-off-by: 1552980358 <1552980358@qq.com> --- .../java/io/legado/app/api/ReaderProvider.kt | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/io/legado/app/api/ReaderProvider.kt b/app/src/main/java/io/legado/app/api/ReaderProvider.kt index d7802f235..a8cbf9f16 100644 --- a/app/src/main/java/io/legado/app/api/ReaderProvider.kt +++ b/app/src/main/java/io/legado/app/api/ReaderProvider.kt @@ -29,18 +29,19 @@ class ReaderProvider : ContentProvider() { private val postBodyKey = "json" private val sMatcher by lazy { - val uriMatcher = UriMatcher(UriMatcher.NO_MATCH) - val authority = "${context?.applicationInfo?.packageName}.readerProvider" - uriMatcher.addURI(authority, "source/insert", RequestCode.saveSource.ordinal) - uriMatcher.addURI(authority, "sources/insert", RequestCode.saveSources.ordinal) - uriMatcher.addURI(authority, "book/insert", RequestCode.saveBook.ordinal) - uriMatcher.addURI(authority, "sources/delete", RequestCode.deleteSources.ordinal) - uriMatcher.addURI(authority, "source/query", RequestCode.getSource.ordinal) - uriMatcher.addURI(authority, "sources/query", RequestCode.getSources.ordinal) - uriMatcher.addURI(authority, "books/query", RequestCode.getBookshelf.ordinal) - uriMatcher.addURI(authority, "book/chapter/query", RequestCode.getChapterList.ordinal) - uriMatcher.addURI(authority, "book/content/query", RequestCode.getBookContent.ordinal) - return@lazy uriMatcher + UriMatcher(UriMatcher.NO_MATCH).apply { + "${context?.applicationInfo?.packageName}.readerProvider".also { authority -> + addURI(authority, "source/insert", RequestCode.saveSource.ordinal) + addURI(authority, "sources/insert", RequestCode.saveSources.ordinal) + addURI(authority, "book/insert", RequestCode.saveBook.ordinal) + addURI(authority, "sources/delete", RequestCode.deleteSources.ordinal) + addURI(authority, "source/query", RequestCode.getSource.ordinal) + addURI(authority, "sources/query", RequestCode.getSources.ordinal) + addURI(authority, "books/query", RequestCode.getBookshelf.ordinal) + addURI(authority, "book/chapter/query", RequestCode.getChapterList.ordinal) + addURI(authority, "book/content/query", RequestCode.getBookContent.ordinal) + } + } } override fun onCreate(): Boolean {