Android Studio 4.0 Tutorial – Part 6
Today let’s pass a productCode from our main RecyclerView Adapter to our ProductInfo Fragment which allows us to lookup all data for a given product.
First we’ll switch our Navigation Components to use a productCode instead of a ProductName, extract a « data » class, then use Kotlin’s find{} function to fetch the product, defaulting to null if it doesn’t exist.
It’s a best practice to pass a unique identifier instead of a product name. Sort of like single source of truth. Questions in the comments 🙂
View code here: https://github.com/danielmalone/Android-Studio-4.0-Tutorial
Connect with me on Twitter! https://twitter.com/DanielMalone
Views :3020
android studio