@Override
  protected void init(Object obj) {
    gmEventAdapterLog("tapjoy->init");
    AdWhirlLayout adLayout = getAdwhirlLayout();
    if (adLayout != null) {
      GmTapjoyWrapper.initizlize(
          getAdwhirlActivity(),
          GmAdWhirlEventAdapterData.getPublishID(GmEventADType.tapjoy),
          GmAdWhirlEventAdapterData.getDefaultBannerID(GmEventADType.tapjoy));

      TapjoyConnect.getTapjoyConnectInstance()
          .setBannerAdSize(TapjoyDisplayAdSize.TJC_AD_BANNERSIZE_640X100);
      TapjoyConnect.getTapjoyConnectInstance().getDisplayAd(this);

      mADView = new RelativeLayout(getAdwhirlActivity());

      RelativeLayout.LayoutParams lp =
          new RelativeLayout.LayoutParams(
              RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
      adLayout.addView(mADView, lp);

      // Show AD for certain seconds (extra.cycleTime).
      rotateThreadedDelayed();
      gmEventAdapterLog("tapjoy->rotateThreadedDelayed");
    }
  }
  public void initAdWhirl() {

    setContentView(R.layout.main);
    AdWhirlManager.setConfigExpireTimeout(1000 * 60 * 5);

    AdWhirlLayout adWhirlLayout = (AdWhirlLayout) findViewById(R.id.adwhirl_layout);

    TextView textView = new TextView(this);
    RelativeLayout.LayoutParams layoutParams =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

    int diWidth = 320;
    int diHeight = 52;
    int density = (int) getResources().getDisplayMetrics().density;
    try {

      adWhirlLayout.setAdWhirlInterface(this);
      adWhirlLayout.setMaxWidth((int) (diWidth * density));
      adWhirlLayout.setMaxHeight((int) (diHeight * density));

      layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
      textView.setText("Below AdWhirlLayout");

      // LinearLayout layout = (LinearLayout)findViewById(R.id.layout_main);
      RelativeLayout layout = (RelativeLayout) findViewById(R.id.layout_main);

      if (layout == null) {
        Log.e("AdWhirl", "Layout is null!");
        return;
      }

      // layout.setGravity(Gravity.CENTER_HORIZONTAL);
      // layout.addView(adWhirlLayout, layoutParams);
      // layout.addView(textView, layoutParams);
      layout.invalidate();
    } catch (Exception e) {
      Log.e("ADWHIRL", "Error in code:" + e.toString());
      e.printStackTrace();
    }

    AdWhirlAdapter.setGoogleAdSenseAppName("OpenMBTA");
    AdWhirlAdapter.setGoogleAdSenseCompanyName("Kaja Software");
    // AdWhirlAdapter.setGoogleAdSenseChannel("xxxxxxx");
    // AdWhirlTargeting.setKeywords("My keywords");

  }
 @Override
 public void dispose() {
   gmEventAdapterLog("tapjoy->dispose");
   AdWhirlLayout tmpLayout = getAdwhirlLayout();
   if (tmpLayout != null) {
     if (mADView != null) {
       if (mTapjoyADView != null) {
         mTapjoyADView.setVisibility(View.GONE);
         mADView.removeAllViews();
       }
       mADView.setVisibility(View.GONE);
       tmpLayout.removeView(mADView);
       mADView = null;
       gmEventAdapterLog("adwo->removed");
     }
   }
   super.dispose();
 }
  @Override
  public void getDisplayAdResponse(View adView) {
    gmEventAdapterLog("tapjoy->getDisplayAdResponse");
    AdWhirlLayout adLayout = getAdwhirlLayout();
    if (adLayout != null) {
      mTapjoyADView = adView;
      LayoutParams lp = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
      int width = mADView.getMeasuredWidth();
      // Resize if it's too big.
      if (mTapjoyADView.getLayoutParams().width > width) {
        // 6.4 ratio
        lp = new LayoutParams(width, (width * 10) / 64);
        mTapjoyADView.setLayoutParams(lp);
      }

      Handler handler = adLayout.getHandler();
      if (handler != null) {
        mUpdateADViewFlag = true;
        handler.post(mUpdateADViewRunnable);
      }
    }
  }