Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 586b0646 authored by George Lin's avatar George Lin
Browse files

Fix exception when getting grid title

Test: Tested no exception throws when no title key
Bug: 413320613
Flag: com.android.systemui.shared.new_customization_picker_ui
Change-Id: Ice1013a810d4827d80ffbc0237b5ddf5a9011083
parent 9a0e1a00
Loading
Loading
Loading
Loading
+41 −28
Original line number Diff line number Diff line
@@ -53,15 +53,21 @@ constructor(
                    ?.use { cursor ->
                        buildList {
                                while (cursor.moveToNext()) {
                                    try {
                                        val rows = cursor.getInt(cursor.getColumnIndex(COL_ROWS))
                                        val cols = cursor.getInt(cursor.getColumnIndex(COL_COLS))
                                        val titleIndex = cursor.getColumnIndex(COL_GRID_TITLE)
                                        val title =
                                        cursor.getString(cursor.getColumnIndex(COL_GRID_TITLE))
                                            ?: context.getString(
                                                com.android.themepicker.R.string.grid_title_pattern,
                                            if (titleIndex != -1) {
                                                cursor.getString(titleIndex)
                                            } else {
                                                context.getString(
                                                    com.android.themepicker.R.string
                                                        .grid_title_pattern,
                                                    cols,
                                                    rows,
                                                )
                                            }
                                        add(
                                            GridOptionModel(
                                                key =
@@ -83,6 +89,13 @@ constructor(
                                                    ),
                                            )
                                        )
                                    } catch (e: IllegalStateException) {
                                        Log.e(
                                            TAG,
                                            "Fail to read from the cursor to build GridOptionModel",
                                            e,
                                        )
                                    }
                                }
                            }
                            .let { list ->