i am trying to put a list in my app with a listener on each element where clicking on it opens a new activity with a parameter given by the field. It sounds quite easy but as i moved from listview to recyclerview i am facing an error
The first time i click on an item, and only the first one, it takes 5/6 seconds to open and throws an exception like the following
RuntimeException: Performing stop of activity that is not resumed
on the activity that keeps the list
This is the code i am using to set up the listener in the viewholder
public static class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
private final AdapterRequestListController controller;
// each data item is just a string in this case
public TextView elapsedTime;
public View rootView;
public ViewHolder(View v, AdapterRequestListController controller) {
super(v);
elapsedTime = (TextView) v.findViewById(R.id.rlr_reply_title);
rootView = v;
this.controller = controller;
v.setOnClickListener(this);
}
@Override
public void onClick(View v) {
controller.openReply(getAdapterPosition());
}
}
I looked for the problem in the controller (that is actually my activity) but nothing changed, ao i moved to the adapter and the very strange thing is that if i put the listener in the onbind method of the adapter it does not happen
I don't like to put it there for many reasons (tons of listener updated every time it scrolls)
Any suggestions or ideas? Thanks!
This is the complete exception
E/ActivityThread: Performing stop of activity that is not resumed: {it.mb.s/it.mb.s.working.ActivityVI}
java.lang.RuntimeException: Performing stop of activity that is not resumed: {it.mb.s/it.mb.s.working.ActivityVI}
at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:3465)
at android.app.ActivityThread.handleStopActivity(ActivityThread.java:3550)
at android.app.ActivityThread.-wrap20(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1373)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
UPDATE 2
this is the method that actually runs the intent
@Override
public void openReply(int position) {
//TODO
Log.d(TAG, position + " fired");
Intent intent = new Intent(this, ActivityViewReply.class);
Bundle bundle = new Bundle();
bundle.putSerializable(ActivityViewReply.REQUEST_FIELD_NAME, meRequests.get(position));
intent.putExtras(bundle);
startActivity(intent);
}