SimpleRecyclerView icon indicating copy to clipboard operation
SimpleRecyclerView copied to clipboard

onCellClickListener not working

Open pizzanakin opened this issue 6 years ago • 1 comments

I have added an onCellClickListener to the cells in my recyclerview, which is a list of podcasts. The selected podcast should start playing when the user taps a cell in the list, but the onCellClicked method is never called. I have also added an onCellLongClicked method, and this one works fine, but it is not my intended functionality for the app.

Here is the code where I bind the data and create the listeners:

    List<DataManager.Podcast> podcasts = DownloadData.podcastList;
    List<DataManager.PodcastCell> cells = new ArrayList<>();
    for (DataManager.Podcast podcast:podcasts) {
        DataManager.PodcastCell cell = new DataManager.PodcastCell(podcast);
        cell.setOnCellClickListener(new SimpleCell.OnCellClickListener<DataManager.Podcast>() {
            @Override
            public void onCellClicked(DataManager.Podcast item) {
                Log.d("test", "CLICK");
            }
        });
        cell.setOnCellLongClickListener(new SimpleCell.OnCellLongClickListener<DataManager.Podcast>() {
            @Override
            public void onCellLongClicked(DataManager.Podcast item) {
                Log.d("test", "LONGCLICK");
            }
        });
        cells.add(cell);
    }
    recyclerView.addCells(cells);

And here's the console output when I attempt both types of clicking: 08-23 11:48:55.811 8394-8394/com.gmail.lpizzanakin.myfirstvbgapp D/test: LONGCLICK 08-23 11:48:56.767 8394-8394/com.gmail.lpizzanakin.myfirstvbgapp D/test: LONGCLICK 08-23 11:48:57.579 8394-8394/com.gmail.lpizzanakin.myfirstvbgapp D/test: LONGCLICK 08-23 11:48:58.410 8394-8394/com.gmail.lpizzanakin.myfirstvbgapp D/test: LONGCLICK 08-23 11:49:02.141 8394-8394/com.gmail.lpizzanakin.myfirstvbgapp D/test: LONGCLICK 08-23 11:49:03.442 8394-8394/com.gmail.lpizzanakin.myfirstvbgapp D/test: LONGCLICK 08-23 11:49:04.155 8394-8394/com.gmail.lpizzanakin.myfirstvbgapp D/test: LONGCLICK 08-23 11:49:05.382 8394-8394/com.gmail.lpizzanakin.myfirstvbgapp D/test: LONGCLICK

I don't see any differences between my implementations of both listeners, so I don't think there should be anything wrong with my code.

pizzanakin avatar Aug 23 '18 09:08 pizzanakin

with kotlin works cell.setOnCellClickListener(OnCellClickListener<Book> { Log.d("test", "CLICK") })

VladlinMoiseenko avatar Feb 09 '20 16:02 VladlinMoiseenko