package com.sakurafish.parrot.callconfirm.activity;

import android.app.Fragment;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;

import com.sakurafish.parrot.callconfirm.R;
import com.sakurafish.parrot.callconfirm.fragment.WebFragment;

import static com.sakurafish.parrot.callconfirm.fragment.BaseWebFragment.EXTRA_TITLE;
import static com.sakurafish.parrot.callconfirm.fragment.BaseWebFragment.EXTRA_URL;


public class WebViewActivity extends AppCompatActivity {

    private Fragment mContent;
    private String mUrl;
    private String mTitle;

    public static Intent createIntent(@NonNull final Context context,
                                      @NonNull final Class clazz,
                                      @NonNull final String url,
                                      @Nullable final String title) {
        Intent intent = new Intent(context, clazz);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.putExtra(EXTRA_URL, url);
        if (!TextUtils.isEmpty(title)) {
            intent.putExtra(EXTRA_TITLE, title);
        }
        return intent;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        setContentView(R.layout.activity_main);

        initialize(savedInstanceState);
    }

    private void initialize(final Bundle savedInstanceState) {
        if (getIntent() != null) {
            mUrl = getIntent().getStringExtra(EXTRA_URL);
            if (getIntent().hasExtra(EXTRA_TITLE)) {
                mTitle = getIntent().getStringExtra(EXTRA_TITLE);
            }
        }

        findViewById(R.id.content).setBackgroundColor(Color.WHITE);

        if (savedInstanceState == null) {
            mContent = WebFragment.getInstance(mUrl, mTitle);
            getFragmentManager().beginTransaction()
                    .add(R.id.content, mContent)
                    .commit();
        } else {
            mContent = getFragmentManager().getFragment(savedInstanceState, "mContent");
            getFragmentManager().beginTransaction()
                    .replace(R.id.content, mContent)
                    .addToBackStack("WebFragment").commit();
        }
    }

    @Override
    public void onSaveInstanceState(final Bundle outState) {
        getFragmentManager().putFragment(outState, "mContent", mContent);
        super.onSaveInstanceState(outState);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        mContent = null;
    }
}

@@ -178,16 +178,60 @@
 tyInfo;%0A
+import android.databinding.DataBindingUtil;%0A
 import a
@@ -462,39 +462,158 @@
 com.
-sakurafish.parrot.callconfirm.R
+google.android.gms.ads.AdRequest;%0Aimport com.sakurafish.parrot.callconfirm.R;%0Aimport com.sakurafish.parrot.callconfirm.databinding.ActivityMainBinding
 ;%0Aim
@@ -672,16 +672,74 @@
 ragment;
+%0Aimport com.sakurafish.parrot.callconfirm.utils.AdsHelper;
 %0A%0Aimport
@@ -962,16 +962,58 @@
 vity %7B%0A%0A
+    private ActivityMainBinding binding;%0A%0A
     priv
@@ -1837,16 +1837,42 @@
         
+binding = DataBindingUtil.
 setConte
@@ -1878,16 +1878,22 @@
 entView(
+this, 
 R.layout
@@ -2839,24 +2839,159 @@
 );%0A        %7D
+%0A%0A        // show AD banner%0A        AdRequest adRequest = new AdsHelper(this).getAdRequest();%0A        binding.adView.loadAd(adRequest);
 %0A    %7D%0A%0A    

Add adView to WebViewActivity