T
T
terminator-light2018-08-15 22:13:46
Android
terminator-light, 2018-08-15 22:13:46

Would it be correct to pass a reference to the RecyclerView.Adapter activity?

There is an EditorActivity activity and adapter and holder classes.
Through EditorActivity I pass a list of elements and 2 event handlers OnClickListener and OnLongClickListener to the adapter.
The task is that with the click event, a modal window appears, and with a long click, the element is colored and becomes selected, and at the same time, the "delete selected" button appears below. Also when there is 1 selected element, the click event performed the action that happens on a long click, i.e. selection, otherwise, showing a modal window.
How to proceed: 1. pass links to event handlers to the adapter or a link to the EditorActivity itself; 2. Transfer the handler code itself and the "delete selected" button to the adapter. In the event handler for showing the modal, several queries are also made to the sqlite database. Actually, should such code be in the adapter?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Zagaevsky, 2018-08-15
@terminator-light

SOLID .
The responsibility of the adapter is to turn the data into views. And that's it. Under no circumstances should there be any other code in it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question