George B George B - 11 days ago 13
Android Question

"ViewPostImeInputStage processPointer 0" in log when item in RecyclerView is tapped?

In my app I am creating, I have a list of items. When a user taps on one of these items, a new window is supposed to open, displaying the information inside the item that the user tapped on. Here is my java code for that-

public class NoteListFragment extends Fragment {

private FloatingActionButton mFab;
private View mRootView;
private List<Note> mNotes;
private RecyclerView mRecyclerView;
private NoteListAdapter mAdapter;
private RecyclerView.LayoutManager mLayoutManager;


public NoteListFragment() {
// Required empty public constructor
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment and hold the reference
//in mRootView
mRootView = inflater.inflate(R.layout.fragment_note_list, container, false);

//Get a programmatic reference to the Floating Action Button
mFab = (FloatingActionButton)mRootView.findViewById(R.id.fab);

//attach an onClick listener to the Floating Action Button
mFab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(getActivity(), NoteEditorActivity.class));
}
});

setupList();
return mRootView;
}


private void setupList() {
mRecyclerView = (RecyclerView) mRootView.findViewById(R.id.note_recycler_view);
mRecyclerView.setHasFixedSize(true);
mLayoutManager = new LinearLayoutManager(getActivity());
mRecyclerView.setLayoutManager(mLayoutManager);

final GestureDetector mGestureDetector =
new GestureDetector(getActivity(), new GestureDetector.SimpleOnGestureListener(){
@Override
public boolean onSingleTapUp(MotionEvent e) {
return true;
}
});


mRecyclerView.addOnItemTouchListener(new RecyclerView.OnItemTouchListener() {
@Override
public boolean onInterceptTouchEvent(RecyclerView recyclerView, MotionEvent motionEvent) {
View child = recyclerView.findChildViewUnder(motionEvent.getX(), motionEvent.getY());

if (child != null && mGestureDetector.onTouchEvent(motionEvent)) {
int position = recyclerView.getChildLayoutPosition(child);
Note selectedNote = mNotes.get(position);
Intent editorIntent = new Intent(getActivity(), NoteEditorActivity.class);
editorIntent.putExtra("id", selectedNote.getId());
}
System.out.print("Failed to load Editor class.");
return false;

}

@Override
public void onTouchEvent(RecyclerView rv, MotionEvent e) {

}

@Override
public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {

}
});

mAdapter = new NoteListAdapter(mNotes, getActivity());
mRecyclerView.setAdapter(mAdapter);
mNotes = NoteManager.newInstance(getActivity()).getAllNotes();
}

}


For some reason, when I tap one of the items, nothing happens, and the log says

11-26 09:45:17.963 12963-12963/com.example.simplenotepad D/ViewRootImpl: ViewPostImeInputStage processPointer 0
11-26 09:45:18.073 12963-12963/com.example.simplenotepad D/ViewRootImpl: ViewPostImeInputStage processPointer 1


What does this mean? How do I fix this? Thanks!

Answer

You are not calling the activity in the RecyclerView on touch event.

The code with the correction is:

mRecyclerView.addOnItemTouchListener(new RecyclerView.OnItemTouchListener() {
    @Override
    public boolean onInterceptTouchEvent(RecyclerView recyclerView, MotionEvent motionEvent) {
        View child = recyclerView.findChildViewUnder(motionEvent.getX(), motionEvent.getY());

        if (child != null && mGestureDetector.onTouchEvent(motionEvent)) {
            int position = recyclerView.getChildLayoutPosition(child);
            Note selectedNote = mNotes.get(position);
            Intent editorIntent = new Intent(getActivity(), NoteEditorActivity.class);
            editorIntent.putExtra("id", selectedNote.getId());
            startActivity(editorIntent);
        }
        System.out.print("Failed to load Editor class.");
        return false;

    }