Skip to content

Instantly share code, notes, and snippets.

View rafaelkowal's full-sized avatar

Rafael Kowal rafaelkowal

View GitHub Profile
@rafaelkowal
rafaelkowal / post.md
Created February 13, 2019 18:51 — forked from grantland/post.md
RecyclerView item onClick

RecyclerView item onClick

RecyclerView does not have an OnItemClickListener like it's predecessor, ListView. However, detecting item clicks is pretty simple.

Set an OnClickListener in your ViewHolder creation:

private class MyAdapter extends RecyclerView.Adapter<MyAdapter.ViewHolder>  {

    public static class ViewHolder extends RecyclerView.ViewHolder
public class GridAndListLayout extends TWAbsLayoutManager {
private final int NUM_LANES = 2;
public GridAndListLayout(Context context, Orientation orientation) {
super(context, orientation);
}
private boolean isVertical() {
return (getOrientation() == Orientation.VERTICAL);
}
private static final int PEEK_DRAWER_TIME_SECONDS = 2;
private long downTime;
private long eventTime;
private float x = 0.0f;
private float y = 100.0f;
private int metaState = 0;
protected void peekDrawer() {
downTime = SystemClock.uptimeMillis();
eventTime = SystemClock.uptimeMillis() + 100;