davideas / FlexibleAdapter

Fast and versatile Adapter for RecyclerView which regroups several features into one library to considerably improve the user experience :-)
Apache License 2.0
3.55k stars 553 forks source link

How to distinguish the click events of different adapters #697

Closed tcqq closed 5 years ago

tcqq commented 5 years ago

@davideas An activity has 2 adapters, how to distinguish the click events of different adapters?

class MainActivity : BaseActivity(),
        FlexibleAdapter.OnItemClickListener {

    private lateinit var oneAdapter: FlexibleAdapter<IFlexible<*>>
    private lateinit var twoAdapter: FlexibleAdapter<IFlexible<*>>

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        oneAdapter = FlexibleAdapter(null, this, true)
        twoAdapter = FlexibleAdapter(null, this, true)
   }

    override fun onItemClick(view: View?, position: Int): Boolean {
        //How to tell if the item currently clicked is from one or two?
   }
}
davideas commented 5 years ago

https://github.com/davideas/FlexibleAdapter/wiki/5.x-%7C-Setting-Up-Advanced#receiving-callbacks-from-different-adapters

tcqq commented 5 years ago

very thankful