title: Calling Fragment method from attached RecyclerView.Adapter
body: <p>I recently started coding my first Android project using Android Studio 3.1.2 and SDK 19.</p>
  <p>One of my fragments contains a RecyclerView with a custom RecyclerView.Adapter attached. On the CardView the Adapter gets by its ViewHolder, there can be a button. The target is, if the button is pressed, a method of my fragment should be called, though it's an instance of a custom subclass of Fragment:</p>
  <p>From <strong>RequestingFragment</strong>:</p>
  <pre><code>public abstract class RequestingFragment extends Fragment implements RequestCallbacks {
  
      public final static void startRequest(final RequestOperation, String param) {
          //this is the guy i want to call
      }
  
      //these are the RequestCallbacks, they're all getting called in startRequest()
      public void onSuccess(JSONObject json, String parsingkey) { }
  
      public void onError() { }
  
      public void onFinished() { }
  </code></pre>
  <p>Now one of my <strong>RequestingFragment</strong>s contains a RecyclerView, on which a custom <strong>ErrorCompactAdapter</strong> is attached. Inside the Adapters ViewHolder, where I load the layout for the single CardViews, there's a button, which should call <code>startRequest()</code> onClick from my <strong>RequestingFragment</strong></p>
  <p>From <strong>ErrorCompactAdapter</strong>:</p>
  <pre><code>public class ErrorCompactAdapter extends RecyclerView.Adapter&lt;ErrorCompactAdapter.ErrorCompactViewHolder&gt; {
  
      private Context context;
      private ArrayList&lt;Error&gt; errors;
  
      public ErrorCompactAdapter(Context context, ArrayList&lt;Error&gt; errors) {
          this.context = context;
          this.errors = errors;
      }
      
      public void onBindViewHolder(ErrorCompactViewHolder, int position) {
          //...
          holder.errorTakeOverButton.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  //here's were i'm stuck
              }
          });
          //...
      }
  }
  </code></pre>
  <p>My first approach was to change the <code>context</code> attribute of <strong>ErrorCompactAdapter</strong> to a <strong>RequestingFragment</strong>, so that I can call <code>startRequest()</code> on this.</p>
  <pre><code>private Context context; // private RequestingFragment attacher;
  
  public void onClick(View v) {
      attacher.startRequest(/*params*/);
  }
  </code></pre>
  <p>But i'm very unsure, if the fragment that contains the RecyclerView will be the one which receives the response of the request, or if a somehow &quot;pseudo-anonymous&quot; Fragment will receive the response and simply does nothing with it then. Can someone enlight me, if this is the correct path? Thanks in advance.</p>