Skip to content

Commit bd18777

Browse files
committed
fix: exclude letter-sounds from word
#421
1 parent ef6a955 commit bd18777

File tree

2 files changed

+3
-30
lines changed

2 files changed

+3
-30
lines changed

utils/src/main/java/ai/elimu/content_provider/utils/ContentProviderUtil.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ object ContentProviderUtil {
202202
wordsCursor.moveToNext()
203203

204204
// Convert from Room to Gson
205-
val wordGson = CursorToWordGsonConverter.getWordGson(wordsCursor, context, contentProviderApplicationId)
205+
val wordGson = CursorToWordGsonConverter.getWordGson(wordsCursor)
206206

207207
wordGsons.add(wordGson)
208208

@@ -249,7 +249,7 @@ object ContentProviderUtil {
249249
wordCursor.moveToFirst()
250250

251251
// Convert from Room to Gson
252-
wordGson = CursorToWordGsonConverter.getWordGson(wordCursor, context, contentProviderApplicationId)
252+
wordGson = CursorToWordGsonConverter.getWordGson(wordCursor)
253253

254254
wordCursor.close()
255255
Log.i(

utils/src/main/java/ai/elimu/content_provider/utils/converter/CursorToWordGsonConverter.kt

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
11
package ai.elimu.content_provider.utils.converter
22

33
import ai.elimu.model.v2.enums.content.WordType
4-
import ai.elimu.model.v2.gson.content.LetterSoundGson
54
import ai.elimu.model.v2.gson.content.WordGson
6-
import android.content.Context
75
import android.database.Cursor
86
import android.text.TextUtils
97
import android.util.Log
10-
import android.widget.Toast
11-
import androidx.core.net.toUri
128

139
object 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

Comments
 (0)