jaychang0917 / SimpleRecyclerView

A RecyclerView extension for building list more easily.
Apache License 2.0
935 stars 104 forks source link

onCellClickListener not working #46

Open pizzanakin opened 6 years ago

pizzanakin commented 6 years ago

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.

VladlinMoiseenko commented 4 years ago

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