agoda-com / Kakao

This repo is no longer supported. Please visit a https://github.com/KakaoCup/Kakao
Apache License 2.0
1.11k stars 102 forks source link

RecyclerView inside RecyclerView items, cannot get it to be recognized #236

Closed Nikola-Milovic closed 3 years ago

Nikola-Milovic commented 4 years ago

A question, I have a setup of a food menu, with menu items, that furthermore contain additional items for price options / Menu fragment with menuRecycleView-> Menu Item with optionsRecycleView -> Option Item

    class MenuScreen : Screen<MenuScreen>() {
 // this is the fragments recycleview
        val menuRecyclerView =
            KRecyclerView(builder = { withId(R.id.menu_recycleView) }, itemTypeBuilder = {
                itemType(::MenuItem)
            })
    }

// this is the menu item that has the options
    class MenuItem(parent: Matcher<View>) : KRecyclerItem<MenuItem>(parent) { 
        val name: KTextView = KTextView(parent) {withId((R.id.name_textView))
         // here is the problem
        val optionsRecycleView  = KRecyclerView({
            withId(R.id.options_recycle_view)
            isDescendantOfA { withMatcher(parent) }
        }, {
            itemType(::OptionItem)
        })
        }
    }

 // this is the options item
    class OptionItem(parent: Matcher<View>) : KRecyclerItem<OptionItem>(parent) {
        var optionsName : KTextView = KTextView(parent){withId(R.id.option_textView)}
        var price : KTextView = KTextView(parent){withId(R.id.price_textView)}
    }

    private val screen = MenuScreen()

And when I try to use it here

    @Test
    fun RecyclerViewItemsContainCorrectData() {
        screen {
            menuRecyclerView {
                for (i in 0..2) {
                    // 1
                    scrollTo(i)
                    childAt<MenuItem>(i) {
                        name.hasText("Title" + (i + 1))//this works
                        optionsRecycleView. //unrecognized
                    }
                }
            }
        }
    }

I've tried several setups, looked through some older issues and commits, but unfortunately my knowledge is limited and I've exhausted the changes I could've tried. I am not too familiar with Kakao as a whole either. I've checked my XML's and stuff to avoid collisions of ID and similar stuff that came to mind as well, but doesn't seem to be the case. If any additional info is needed feel free to ask me!