linisme / SlimAdapter

A slim & clean & typeable Adapter without# VIEWHOLDER
https://raw.githubusercontent.com/MEiDIK/SlimAdapter/master/SlimAdapter.jpg
MIT License
931 stars 117 forks source link

Add containerClick #34

Open miszmaniac opened 6 years ago

miszmaniac commented 6 years ago

Many times, we need to support click on whole element, so if it's possible, could you add methods .click and .longClick without additional ID parameter, and pass that to whole injected view?

JoaoVictordaSilva commented 6 years ago
SlimAdapter.create()
                .register(R.layout.recycler_item, new SlimInjector<Foo>() {
                    @Override
                    public void onInject(Foo data, IViewInjector injector) {
                        injector.clicked(R.id.YOUR_ID_ROOT_ELEMENT, view -> {
                                   //Some Action
                                });
                      }
                })
                .attachTo(mRecycler);

@miszmaniac Try to put ID in your root element. I guess that's what you want.

miszmaniac commented 6 years ago

I know that I can do that this way, it's just cumbersome, and in Kotlin it prevents for use of {}

JoaoVictordaSilva commented 6 years ago

@miszmaniac Just call 'clicked' passing a listener. I'll wait your feedback, if all things are ok make a pull request.

Replace these files. DefaultViewInjector.txt IViewInjector.txt