title: Context for RecyclerView.Adapter
body: <p>I want to add <code>ProgressDialog</code> in an adapter. AFAIK, <code>.this</code> for activity, and <code>getActivity.getApplicationContext()</code> for fragment. What about adapter? Is it possible?</p>
  
  <p>I got error <code>Unable to add window -- token null is not valid; is your activity running?</code> when I use <code>mContext.getApplicationContext()</code>.</p>
  
  <p>EDIT:</p>
  
  <p>In a fragment, I show cards by</p>
  
  <pre><code>allGroupsView = (RecyclerView) rootView.findViewById(R.id.allGroupsView);
  adapterGroup = new AdapterGroup(getActivity().getApplicationContext(), results);
  allGroupsView.setAdapter(adapterGroup);
  allGroupsView.setLayoutManager(new LinearLayoutManager(getActivity().getApplicationContext()));
  </code></pre>
  
  <p>In class <code>AdapterGroup</code></p>
  
  <pre><code>public class AdapterGroup extends RecyclerView.Adapter&lt;RecyclerView.ViewHolder&gt; {
  
  private Context mContext;
  private LayoutInflater inflater;
  List&lt;DataGroup&gt; data= Collections.emptyList();
  DataGroup current;
  
  public AdapterGroup(Context context, List&lt;DataGroup&gt; results) {
      this.mContext = context;
      inflater = LayoutInflater.from(mContext);
      this.data = results;
  }
  
  // Inflate the layout when viewholder created
  @Override
  public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
      View view = inflater.inflate(R.layout.card_view_row, parent, false);
      final MyHolder holder = new MyHolder(view);
  
      view.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              Log.d("debug", String.valueOf(holder.getAdapterPosition()));
              getDetails(Config.GET_GROUP_DETAILS_URL, data.get(holder.getAdapterPosition()).groupName, data.get(holder.getAdapterPosition()).description);
          }
      });
  
      return holder;
  }
  
  private void getDetails(String url, String groupName, String description) {
  
      groupName = groupName.replace(" ", "%20");
      description = description.replace(" ", "%20");
  
      final String finalGroupName = groupName;
      final String finalDescription = description;
  
      class GetDetails extends AsyncTask&lt;String, Void, String&gt; {
          ProgressDialog loading;
  
          @Override
          protected void onPreExecute() {
              super.onPreExecute();
              loading = ProgressDialog.show(mContext.getApplicationContext(), null, "Please wait", true, true);
              loading.setCancelable(false);
          } // more code down from here
  </code></pre>