Skip to content

Commit 453a27e

Browse files
committed
Address Sentry bot issues
1 parent bf02ae7 commit 453a27e

2 files changed

Lines changed: 26 additions & 23 deletions

File tree

sentry-samples/sentry-samples-android/src/main/java/io/sentry/samples/android/navigation/Nav2ComposeRoutes.kt

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -421,12 +421,15 @@ private fun Nav2ComposeActionRoute(
421421
arguments: Map<String, Any?> = emptyMap(),
422422
buttons: List<Pair<String, () -> Unit>>,
423423
) {
424-
Nav2ComposeRouteScaffold(routeSpec) {
425-
routeSpec.displayArguments(arguments).forEach { (label, value) ->
426-
Nav2ComposeRouteInfo(label, value)
427-
}
428-
buttons.forEach { (label, onClick) -> Nav2ComposeRouteButton(label, onClick) }
429-
}
424+
Nav2ComposeRouteScaffold(
425+
routeSpec = routeSpec,
426+
cardContent = {
427+
routeSpec.displayArguments(arguments).forEach { (label, value) ->
428+
Nav2ComposeRouteInfo(label, value)
429+
}
430+
buttons.forEach { (label, onClick) -> Nav2ComposeRouteButton(label, onClick) }
431+
},
432+
)
430433
}
431434

432435
@Composable

sentry-samples/sentry-samples-android/src/main/java/io/sentry/samples/android/navigation/Nav2RouteFragment.kt

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ class Nav2RouteFragment : Fragment() {
6868
activity.navigateTo(Nav2Destination.ProductDetail("7", "product-list"))
6969
},
7070
),
71+
trailingContent = { addProductListItemsToggle() },
7172
)
7273

7374
Nav2RouteNames.PRODUCT_DETAIL -> productDetailLayout(activity)
@@ -131,7 +132,6 @@ class Nav2RouteFragment : Fragment() {
131132
activity.navigateTo(Nav2Destination.Checkout(productId))
132133
},
133134
),
134-
trailingContent = { addProductDetailItemsToggle(productId) },
135135
)
136136
}
137137

@@ -192,7 +192,7 @@ class Nav2RouteFragment : Fragment() {
192192
}
193193
}
194194

195-
private fun LinearLayout.addProductDetailItemsToggle(productId: String) {
195+
private fun LinearLayout.addProductListItemsToggle() {
196196
var itemsCreated = false
197197
var itemsVisible = false
198198
val listContainer =
@@ -215,7 +215,7 @@ class Nav2RouteFragment : Fragment() {
215215
itemsVisible = !itemsVisible
216216
text = if (itemsVisible) "Hide Product Items" else "Show Product Items"
217217
if (itemsVisible && !itemsCreated) {
218-
populateProductDetailItems(listContainer, productId)
218+
populateProductListItems(listContainer)
219219
itemsCreated = true
220220
}
221221
scrollView.visibility = if (itemsVisible) View.VISIBLE else View.GONE
@@ -226,23 +226,23 @@ class Nav2RouteFragment : Fragment() {
226226
addView(scrollView)
227227
}
228228

229-
private fun populateProductDetailItems(listContainer: LinearLayout, productId: String) {
229+
private fun populateProductListItems(listContainer: LinearLayout) {
230230
val ownerSpan = Sentry.getSpan()
231231
val compositionParent =
232232
ownerSpan?.startChild(
233233
OP_PARENT_COMPOSITION,
234-
"Fragment Product Detail Item List Composition",
234+
"Fragment Product List Item List Composition",
235235
)
236236
try {
237-
recordManualUiSpan(compositionParent, OP_COMPOSE, "fragment_product_detail_items") {
238-
repeat(PRODUCT_DETAIL_ITEM_COUNT) { index ->
237+
recordManualUiSpan(compositionParent, OP_COMPOSE, "fragment_product_list_items") {
238+
repeat(PRODUCT_LIST_ITEM_COUNT) { index ->
239239
val itemNumber = index + 1
240240
recordManualUiSpan(
241241
compositionParent,
242242
OP_COMPOSE,
243-
"fragment_product_detail_item_$itemNumber",
243+
"fragment_product_list_item_$itemNumber",
244244
) {
245-
listContainer.addView(productDetailItemRow(productId, itemNumber))
245+
listContainer.addView(productListItemRow(itemNumber))
246246
}
247247
}
248248
}
@@ -254,12 +254,12 @@ class Nav2RouteFragment : Fragment() {
254254
val renderParent =
255255
ownerSpan?.startChild(
256256
OP_PARENT_RENDER,
257-
"Fragment Product Detail Item List Render",
257+
"Fragment Product List Item List Render",
258258
)
259259
try {
260-
recordManualUiSpan(renderParent, OP_RENDER, "fragment_product_detail_items")
261-
repeat(PRODUCT_DETAIL_ITEM_COUNT) { index ->
262-
recordManualUiSpan(renderParent, OP_RENDER, "fragment_product_detail_item_${index + 1}")
260+
recordManualUiSpan(renderParent, OP_RENDER, "fragment_product_list_items")
261+
repeat(PRODUCT_LIST_ITEM_COUNT) { index ->
262+
recordManualUiSpan(renderParent, OP_RENDER, "fragment_product_list_item_${index + 1}")
263263
}
264264
} finally {
265265
renderParent?.finish()
@@ -282,22 +282,22 @@ class Nav2RouteFragment : Fragment() {
282282
}
283283
}
284284

285-
private fun productDetailItemRow(productId: String, itemNumber: Int): View =
285+
private fun productListItemRow(itemNumber: Int): View =
286286
LinearLayout(requireContext()).apply {
287287
orientation = LinearLayout.HORIZONTAL
288288
setPadding(12.dp)
289289
setBackgroundColor(color(android.R.color.white))
290290
addView(
291291
TextView(context).apply {
292-
text = "Product $productId item #$itemNumber"
292+
text = "Product #$itemNumber"
293293
textSize = 14f
294294
setTypeface(null, Typeface.BOLD)
295295
layoutParams = LinearLayout.LayoutParams(0, WRAP_CONTENT, 1f)
296296
}
297297
)
298298
addView(
299299
TextView(context).apply {
300-
text = "SKU-$productId-$itemNumber"
300+
text = "SKU-$itemNumber"
301301
textSize = 14f
302302
}
303303
)
@@ -344,7 +344,7 @@ class Nav2RouteFragment : Fragment() {
344344
private fun color(id: Int): Int = requireContext().getColor(id)
345345

346346
private companion object {
347-
private const val PRODUCT_DETAIL_ITEM_COUNT = 20
347+
private const val PRODUCT_LIST_ITEM_COUNT = 20
348348
private const val OP_PARENT_COMPOSITION = "ui.compose.composition"
349349
private const val OP_COMPOSE = "ui.compose"
350350
private const val OP_PARENT_RENDER = "ui.compose.rendering"

0 commit comments

Comments
 (0)