11package ai.elimu.content_provider.utils.converter
22
33import ai.elimu.model.v2.enums.content.WordType
4- import ai.elimu.model.v2.gson.content.LetterSoundGson
54import ai.elimu.model.v2.gson.content.WordGson
6- import android.content.Context
75import android.database.Cursor
86import android.text.TextUtils
97import android.util.Log
10- import android.widget.Toast
11- import androidx.core.net.toUri
128
139object CursorToWordGsonConverter {
1410
1511 private const val TAG = " CursorToWordGsonConverter"
1612
17- fun getWordGson (cursor : Cursor , context : Context , contentProviderApplicationId : String ): WordGson {
13+ fun getWordGson (cursor : Cursor ): WordGson {
1814 Log .i(TAG , " getWordGson" )
1915
2016 Log .i(TAG ,
@@ -36,28 +32,6 @@ object CursorToWordGsonConverter {
3632 val text = cursor.getString(columnText)
3733 Log .i(TAG , " text: \" $text \" " )
3834
39- val letterSoundGsons = mutableListOf<LetterSoundGson >()
40- val letterSoundsUri = " content://${contentProviderApplicationId} .provider.letter_sound_provider/letter_sounds/by-word-id/${id} " .toUri()
41- Log .i(this ::class .simpleName, " letterSoundsUri: ${letterSoundsUri} " )
42- val letterSoundsCursor = context.contentResolver.query(letterSoundsUri, null , null , null , null )
43- if (letterSoundsCursor == null ) {
44- Log .e(this ::class .simpleName, " letterSoundsCursor == null" )
45- Toast .makeText(context, " letterSoundsCursor == null" , Toast .LENGTH_LONG ).show()
46- } else {
47- Log .i(this ::class .simpleName, " letterSoundsCursor.count: ${letterSoundsCursor.count} " )
48-
49- var isLast = false
50- while (! isLast) {
51- letterSoundsCursor.moveToNext()
52-
53- // Convert from Room to Gson
54- val letterSoundGson = CursorToLetterSoundGsonConverter .getLetterSoundGson(letterSoundsCursor, context, contentProviderApplicationId)
55- letterSoundGsons.add(letterSoundGson)
56-
57- isLast = letterSoundsCursor.isLast
58- }
59- }
60-
6135 val columnWordType = cursor.getColumnIndex(" wordType" )
6236 val wordTypeAsString = cursor.getString(columnWordType)
6337 var wordType: WordType ? = null
@@ -71,7 +45,6 @@ object CursorToWordGsonConverter {
7145 word.revisionNumber = revisionNumber
7246 word.usageCount = usageCount
7347 word.text = text
74- word.letterSounds = letterSoundGsons
7548 word.wordType = wordType
7649
7750 return word
0 commit comments