title: Show interstitial ads after click recyclerview item in fragment
body: <p>I have a custom recyclerview with many intent that go to new activity in fragment. The concept is like this, when user click the item on recyclerview, I want to display a interstitial ads before the new activity is appear. Then if user close the ads or ads failed to loaded, it automatically close the ads it and appear the next activity..how to do it ? </p>
  
  <p>Remember, i use a fragment not activity.</p>
  
  <p>This is my code so far</p>
  
  <pre><code>public class HomeAdapter extends RecyclerView.Adapter&lt;HomeAdapter.ViewHolder&gt; {
  
  
      public static class ViewHolder extends RecyclerView.ViewHolder {
  
          private InterstitialAd interstitialAd;
  
          private TextView homeTitle, homeDesc;
          ImageView homeImage;
  
          private Context context;
  
          public ViewHolder(View itemView) {
              super(itemView);
              createInterstitial();
              context = itemView.getContext();
              homeTitle = (TextView)itemView.findViewById(R.id.homeTitle);
              homeDesc = (TextView)itemView.findViewById(R.id.homeDesc);
              homeImage = (ImageView)itemView.findViewById(R.id.homeImage);
  
              itemView.setOnClickListener(new View.OnClickListener() {
                  @Override
                  public void onClick(View view) {
                      final Intent intent;
                      switch (getAdapterPosition()) {
                          case 0:
                              showInterstitial();
                              intent = new Intent(context, AllBlock.class);
                              break;
                          case 1:
                              showInterstitial();
                              intent = new Intent(context, BasicBlock.class);
                              break;
  
                          default:
                              intent = new Intent(context, AllBlock.class);
                              break;
                      }
                      context.startActivity(intent);
                  }
              });
          }
  
          public void createInterstitial() {
              interstitialAd = new InterstitialAd(context);
              interstitialAd.setAdUnitId("ca-app-pub-3940256099942544/1033173712");
              interstitialAd.setAdListener(new AdListener() {
                  @Override
                  public void onAdLoaded() {
  
                  }
                  @Override
                  public void onAdClosed() {
                      loadInterstitial();
                  }
              });
          }
  
          public void loadInterstitial() {
              AdRequest interstitialRequest = new AdRequest.Builder().build();
              interstitialAd.loadAd(interstitialRequest);
          }
  
          public void showInterstitial() {
              if (interstitialAd.isLoaded()) {
                  interstitialAd.show();
              } else {
                  loadInterstitial();
              }
          }
      }
  </code></pre>