package com.smaato.sdk.demoapp;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;

import com.smaato.sdk.demoapp.banner.BannerAdsActivity;
import com.smaato.sdk.demoapp.cmpconsenttool.CMPConsentToolActivity;
import com.smaato.sdk.demoapp.cmpconsenttool.model.CMPSettings;
import com.smaato.sdk.demoapp.cmpconsenttool.model.SubjectToGdpr;
import com.smaato.sdk.demoapp.interstitial.InterstitialAdsActivity;
import com.smaato.sdk.demoapp.utils.ToastUtils;

public class HomeActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_home);
        getSupportActionBar().setTitle(R.string.activity_name_ad_types);

        findViewById(R.id.banner_ads).setOnClickListener(
                (View v) -> startActivity(new Intent(HomeActivity.this, BannerAdsActivity.class))
        );

        findViewById(R.id.interstitial_ads).setOnClickListener(
                (View v) -> startActivity(new Intent(HomeActivity.this, InterstitialAdsActivity.class))
        );

        findViewById(R.id.mediation_ads).setOnClickListener(
                (View v) -> startActivity(new Intent(HomeActivity.this, MediationAdsActivity.class))
        );

        findViewById(R.id.video_ads).setOnClickListener(
                (View v) -> ToastUtils.showNotImplementedYet(HomeActivity.this)
        );

        findViewById(R.id.gdpr_consent_dialogue).setOnClickListener(
                (View v) -> {
                    CMPSettings cmpSettings = new CMPSettings(
                            SubjectToGdpr.CMPGDPREnabled, /* is GDPR enabled */
                            "https://demofiles.smaato.com/cmp/index.html", /* consent tool url */
                            null /* consent string */
                    );
                    CMPConsentToolActivity.openCmpConsentToolView(cmpSettings, HomeActivity.this, null);
                }
        );

        findViewById(R.id.settings).setOnClickListener(
                (View v) -> startActivity(new Intent(HomeActivity.this, SettingsActivity.class))
        );
    }
}
