Loading src/com/android/customization/model/grid/DefaultShapeGridManager.kt +67 −37 Original line number Diff line number Diff line Loading @@ -58,11 +58,16 @@ constructor( ) add( GridOptionModel( key = cursor.getString(cursor.getColumnIndex(COL_GRID_KEY)), key = cursor.getString( cursor.getColumnIndex(COL_GRID_KEY) ), title = title, isCurrent = cursor .getString(cursor.getColumnIndex(COL_IS_DEFAULT)) .getString( cursor.getColumnIndex(COL_IS_DEFAULT) ) .toBoolean(), rows = rows, cols = cols, Loading @@ -70,6 +75,16 @@ constructor( ) } } .let { list -> // In this list, exactly one item should have isCurrent true. val isCurrentCount = list.count { it.isCurrent } if (isCurrentCount != 1) { throw IllegalStateException( "Exactly one grid option should have isCurrent = true. Found $isCurrentCount." ) } list } } } else { null Loading @@ -87,20 +102,35 @@ constructor( add( ShapeOptionModel( key = cursor.getString(cursor.getColumnIndex(COL_SHAPE_KEY)), cursor.getString( cursor.getColumnIndex(COL_SHAPE_KEY) ), title = cursor.getString( cursor.getColumnIndex(COL_SHAPE_TITLE) ), path = cursor.getString(cursor.getColumnIndex(COL_PATH)), path = cursor.getString(cursor.getColumnIndex(COL_PATH)), isCurrent = cursor .getString(cursor.getColumnIndex(COL_IS_DEFAULT)) .getString( cursor.getColumnIndex(COL_IS_DEFAULT) ) .toBoolean(), ) ) } } .let { list -> // In this list, exactly one item should have isCurrent true. val isCurrentCount = list.count { it.isCurrent } if (isCurrentCount != 1) { throw IllegalStateException( "Exactly one shape option should have isCurrent = true. Found $isCurrentCount." ) } list } } } else { null Loading Loading
src/com/android/customization/model/grid/DefaultShapeGridManager.kt +67 −37 Original line number Diff line number Diff line Loading @@ -58,11 +58,16 @@ constructor( ) add( GridOptionModel( key = cursor.getString(cursor.getColumnIndex(COL_GRID_KEY)), key = cursor.getString( cursor.getColumnIndex(COL_GRID_KEY) ), title = title, isCurrent = cursor .getString(cursor.getColumnIndex(COL_IS_DEFAULT)) .getString( cursor.getColumnIndex(COL_IS_DEFAULT) ) .toBoolean(), rows = rows, cols = cols, Loading @@ -70,6 +75,16 @@ constructor( ) } } .let { list -> // In this list, exactly one item should have isCurrent true. val isCurrentCount = list.count { it.isCurrent } if (isCurrentCount != 1) { throw IllegalStateException( "Exactly one grid option should have isCurrent = true. Found $isCurrentCount." ) } list } } } else { null Loading @@ -87,20 +102,35 @@ constructor( add( ShapeOptionModel( key = cursor.getString(cursor.getColumnIndex(COL_SHAPE_KEY)), cursor.getString( cursor.getColumnIndex(COL_SHAPE_KEY) ), title = cursor.getString( cursor.getColumnIndex(COL_SHAPE_TITLE) ), path = cursor.getString(cursor.getColumnIndex(COL_PATH)), path = cursor.getString(cursor.getColumnIndex(COL_PATH)), isCurrent = cursor .getString(cursor.getColumnIndex(COL_IS_DEFAULT)) .getString( cursor.getColumnIndex(COL_IS_DEFAULT) ) .toBoolean(), ) ) } } .let { list -> // In this list, exactly one item should have isCurrent true. val isCurrentCount = list.count { it.isCurrent } if (isCurrentCount != 1) { throw IllegalStateException( "Exactly one shape option should have isCurrent = true. Found $isCurrentCount." ) } list } } } else { null Loading