title: How to finish an activity from Adapter class using RecyclerView
body: <p>I am trying to finish activity from adapter class while clicking <code>Recyclerview</code> item
  using the code </p>
  
  <pre><code>public void onBindViewHolder(@NonNull CountryCodeAdapter.CountryViewHolder holder, int position{
      CountryModel countryMode = countryModels.get(position);
      final String cCode = countryModel.getName();
      holder.llcountryCode.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              Intent i = new Intent(v.getContext(),RegisterActivity.class);                        
              i.putExtra("countryCode", cCode);
              v.getContext().startActivity(i);
              ((AppCompatActivity)context).finish();
          }
      }
  }
  </code></pre>
  
  <p>Also tried  this but didn't work </p>
  
  <pre><code>((Activity)context).finish();
  </code></pre>
  
  <p>And i get this error: </p>
  
  <pre><code>cannot be cast to android.support.v7.app.AppCompatActivity
  </code></pre>