From f607f0eb25b95c8cdc0f6e18b25f6541c6fd734c Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 18 Sep 2020 09:47:12 +0800 Subject: [PATCH] up ReaderProvider.kt --- .../java/io/legado/app/api/ReaderProvider.kt | 35 ++++--------------- 1 file changed, 7 insertions(+), 28 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 fcf50aa9c..3ae8c7963 100644 --- a/app/src/main/java/io/legado/app/api/ReaderProvider.kt +++ b/app/src/main/java/io/legado/app/api/ReaderProvider.kt @@ -7,10 +7,7 @@ import android.content.ContentProvider import android.content.ContentResolver import android.content.ContentValues import android.content.UriMatcher -import android.database.CharArrayBuffer -import android.database.ContentObserver -import android.database.Cursor -import android.database.DataSetObserver +import android.database.* import android.net.Uri import android.os.Bundle import com.google.gson.Gson @@ -109,40 +106,22 @@ class ReaderProvider : ContentProvider() { uri: Uri, values: ContentValues?, selection: String?, selectionArgs: Array? ) = throw UnsupportedOperationException("Not yet implemented") - + /** * Simple inner class to deliver json callback data. * * Only getString() makes sense. */ - private class SimpleCursor(data: ReturnData?) : Cursor { + private class SimpleCursor(data: ReturnData?) : MatrixCursor(arrayOf("result"), 1) { private val mData: String = Gson().toJson(data) - override fun getCount() = 1 - - override fun getPosition() = 0 - - override fun move(i: Int) = true - - override fun moveToPosition(i: Int) = true - - override fun moveToFirst() = true - - override fun moveToLast() = true - - override fun moveToNext() = true - - override fun moveToPrevious() = true - - override fun isFirst() = true - - override fun isLast() = true - - override fun isBeforeFirst() = true + init { + addRow(arrayOf(mData)) + } - override fun isAfterLast() = true + override fun getCount() = 1 override fun getColumnIndex(s: String) = 0