|
1 | | -package ai.elimu.content_provider.utils.converter; |
2 | | - |
3 | | -import android.database.Cursor; |
4 | | -import android.util.Log; |
5 | | - |
6 | | -import java.util.Arrays; |
7 | | - |
8 | | -import ai.elimu.model.v2.gson.content.LetterGson; |
9 | | - |
10 | | -public class CursorToLetterGsonConverter { |
11 | | - |
12 | | - public static LetterGson getLetterGson(Cursor cursor) { |
13 | | - Log.i(CursorToLetterGsonConverter.class.getName(), "getLetterGson"); |
14 | | - |
15 | | - Log.i(CursorToLetterGsonConverter.class.getName(), "Arrays.toString(cursor.getColumnNames()): " + Arrays.toString(cursor.getColumnNames())); |
16 | | - |
17 | | - int columnIndexId = cursor.getColumnIndex("id"); |
18 | | - Long id = cursor.getLong(columnIndexId); |
19 | | - Log.i(CursorToLetterGsonConverter.class.getName(), "id: " + id); |
20 | | - |
21 | | - int columnIndexRevisionNumber = cursor.getColumnIndex("revisionNumber"); |
22 | | - Integer revisionNumber = cursor.getInt(columnIndexRevisionNumber); |
23 | | - Log.i(CursorToLetterGsonConverter.class.getName(), "revisionNumber: " + revisionNumber); |
24 | | - |
25 | | - int columnIndexText = cursor.getColumnIndex("text"); |
26 | | - String text = cursor.getString(columnIndexText); |
27 | | - Log.i(CursorToLetterGsonConverter.class.getName(), "text: \"" + text + "\""); |
28 | | - |
29 | | - int columnIndexIsDiacritic = cursor.getColumnIndex("diacritic"); |
30 | | - Boolean isDiacritic = (cursor.getInt(columnIndexIsDiacritic) > 0); |
31 | | - Log.i(CursorToLetterGsonConverter.class.getName(), "isDiacritic: " + isDiacritic); |
32 | | - |
33 | | - LetterGson letter = new LetterGson(); |
34 | | - letter.setId(id); |
35 | | - letter.setRevisionNumber(revisionNumber); |
36 | | - letter.setText(text); |
37 | | - letter.setDiacritic(isDiacritic); |
38 | | - |
39 | | - return letter; |
| 1 | +package ai.elimu.content_provider.utils.converter |
| 2 | + |
| 3 | +import ai.elimu.model.v2.gson.content.LetterGson |
| 4 | +import android.database.Cursor |
| 5 | +import android.util.Log |
| 6 | + |
| 7 | +object CursorToLetterGsonConverter { |
| 8 | + @JvmStatic |
| 9 | + fun getLetterGson(cursor: Cursor): LetterGson { |
| 10 | + Log.i(CursorToLetterGsonConverter::class.java.name, "getLetterGson") |
| 11 | + |
| 12 | + Log.i( |
| 13 | + CursorToLetterGsonConverter::class.java.name, |
| 14 | + "Arrays.toString(cursor.getColumnNames()): " + cursor.columnNames.contentToString() |
| 15 | + ) |
| 16 | + |
| 17 | + val columnIndexId = cursor.getColumnIndex("id") |
| 18 | + val id = cursor.getLong(columnIndexId) |
| 19 | + Log.i(CursorToLetterGsonConverter::class.java.name, "id: $id") |
| 20 | + |
| 21 | + val columnIndexRevisionNumber = cursor.getColumnIndex("revisionNumber") |
| 22 | + val revisionNumber = cursor.getInt(columnIndexRevisionNumber) |
| 23 | + Log.i( |
| 24 | + CursorToLetterGsonConverter::class.java.name, |
| 25 | + "revisionNumber: $revisionNumber" |
| 26 | + ) |
| 27 | + |
| 28 | + val columnIndexText = cursor.getColumnIndex("text") |
| 29 | + val text = cursor.getString(columnIndexText) |
| 30 | + Log.i(CursorToLetterGsonConverter::class.java.name, "text: \"$text\"") |
| 31 | + |
| 32 | + val columnIndexIsDiacritic = cursor.getColumnIndex("diacritic") |
| 33 | + val isDiacritic = (cursor.getInt(columnIndexIsDiacritic) > 0) |
| 34 | + Log.i( |
| 35 | + CursorToLetterGsonConverter::class.java.name, |
| 36 | + "isDiacritic: $isDiacritic" |
| 37 | + ) |
| 38 | + |
| 39 | + val letter = LetterGson() |
| 40 | + letter.id = id |
| 41 | + letter.revisionNumber = revisionNumber |
| 42 | + letter.text = text |
| 43 | + letter.diacritic = isDiacritic |
| 44 | + |
| 45 | + return letter |
40 | 46 | } |
41 | 47 | } |
0 commit comments