SlimAdapter icon indicating copy to clipboard operation
SlimAdapter copied to clipboard

Add containerClick

Open miszmaniac opened this issue 7 years ago • 3 comments
trafficstars

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?

miszmaniac avatar Jan 19 '18 13:01 miszmaniac

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.

JoaoVictordaSilva avatar Jan 19 '18 14:01 JoaoVictordaSilva

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

miszmaniac avatar Jan 19 '18 14:01 miszmaniac

@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

JoaoVictordaSilva avatar Feb 14 '18 13:02 JoaoVictordaSilva