|
|
|
@ -14,7 +14,6 @@ import android.database.DataSetObserver |
|
|
|
|
import android.net.Uri |
|
|
|
|
import android.os.Bundle |
|
|
|
|
import com.google.gson.Gson |
|
|
|
|
import io.legado.app.App |
|
|
|
|
import io.legado.app.web.controller.BookshelfController |
|
|
|
|
import io.legado.app.web.controller.SourceController |
|
|
|
|
import io.legado.app.web.utils.ReturnData |
|
|
|
@ -28,9 +27,10 @@ class ReaderProvider : ContentProvider() { |
|
|
|
|
saveSource, saveSources, saveBook, deleteSources, getSource, getSources, getBookshelf, getChapterList, getBookContent |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
companion object { |
|
|
|
|
const val POST_BODY_KEY = "json" |
|
|
|
|
private val authority = "${App.INSTANCE.packageName}.ReaderProvider" |
|
|
|
|
private val postBodyKey = "json" |
|
|
|
|
private val authority by lazy { |
|
|
|
|
"${context?.applicationInfo?.packageName}.ReaderProvider" |
|
|
|
|
} |
|
|
|
|
private val sMatcher = UriMatcher(UriMatcher.NO_MATCH) |
|
|
|
|
|
|
|
|
|
init { |
|
|
|
@ -80,7 +80,6 @@ class ReaderProvider : ContentProvider() { |
|
|
|
|
RequestCode.getBookContent.ordinal |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun delete( |
|
|
|
|
uri: Uri, |
|
|
|
@ -105,13 +104,13 @@ class ReaderProvider : ContentProvider() { |
|
|
|
|
if (sMatcher.match(uri) < 0) return null |
|
|
|
|
when (RequestCode.values()[sMatcher.match(uri)]) { |
|
|
|
|
RequestCode.saveSource -> values?.let { |
|
|
|
|
SourceController.saveSource(values.getAsString(POST_BODY_KEY)) |
|
|
|
|
SourceController.saveSource(values.getAsString(postBodyKey)) |
|
|
|
|
} |
|
|
|
|
RequestCode.saveBook -> values?.let { |
|
|
|
|
BookshelfController.saveBook(values.getAsString(POST_BODY_KEY)) |
|
|
|
|
BookshelfController.saveBook(values.getAsString(postBodyKey)) |
|
|
|
|
} |
|
|
|
|
RequestCode.saveSources -> values?.let { |
|
|
|
|
SourceController.saveSources(values.getAsString(POST_BODY_KEY)) |
|
|
|
|
SourceController.saveSources(values.getAsString(postBodyKey)) |
|
|
|
|
} |
|
|
|
|
else -> throw IllegalStateException( |
|
|
|
|
"Unexpected value: " + RequestCode.values()[sMatcher.match(uri)].name |
|
|
|
|