Fix: Remove hardcoded Toast for network error in ContentCardsFragment #88
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Removes the hardcoded
Toastmessage that is displayed when network is unavailable while loading Content Cards in ContentCardsFragment.Problem
The [ContentCardsFragment](https://github.com/braze-inc/braze-android-sdk/blob/master/android-sdk-ui/src/main/java/com/braze/ui/contentcards/ContentCardsFragment.kt#L344-L355) was showing a
Toast.makeText()message withR.string.com_braze_feed_connection_error_titlewhenever network was unavailable. This hardcoded behavior impacts all SDK consumers and may not align with their app's UX/UI guidelines or error handling strategy.Solution
Removed the
Toast.makeText()call from the [networkUnavailable()](https://github.com/braze-inc/braze-android-sdk/blob/master/android-sdk-ui/src/main/java/com/braze/ui/contentcards/ContentCardsFragment.kt#L344) function. The function now only:This aligns the behavior with the Jetpack Compose [ContentCardsList](https://github.com/braze-inc/braze-android-sdk/blob/master/android-sdk-jetpack-compose/src/main/java/com/braze/jetpackcompose/contentcards/ContentCardsList.kt#L132-L136) implementation, which also only logs network unavailability without displaying a Toast.
Changes
Modified:
Toast.makeText()call from networkUnavailable()android.widget.ToastimportCustomization
SDK consumers who need to display custom network error UI can subclass ContentCardsFragment and override the
protected suspend fun networkUnavailable()function.Testing