package com.maplehaze.adsdk.demo;

import android.app.Activity;
import android.os.Bundle;

import androidx.annotation.Nullable;

import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.RadioGroup;

import com.maplehaze.adsdk.MaplehazeSDK;
import com.maplehaze.adsdk.bean.AdEffect;
import com.maplehaze.adsdk.demo.utils.RadioGroupUtil;
import com.maplehaze.adsdk.demo.utils.RestartUtl;
import com.maplehaze.adsdk.demo.utils.SharePfUtil;

public class SplashAdActivity extends Activity implements View.OnClickListener {

    private final static String TAG = "SplashAdActivity";

    private boolean isEnableServerConfig = false;


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash_ad);

        this.findViewById(R.id.loadButton).setOnClickListener(this);
        this.findViewById(R.id.loadOnlyButton).setOnClickListener(this);
        ((EditText) findViewById(R.id.posId)).setText(Constants.SPLASH_POS_ID);






        if (SharePfUtil.getDevelopMode(this)){
            isEnableServerConfig = true;
        }

        if (savedInstanceState!=null){
            RestartUtl.startClearLastTask(this);
        }

    }

    private String getPosID() {
        String posId = ((EditText) findViewById(R.id.posId)).getText().toString();
        return TextUtils.isEmpty(posId) ? Constants.SPLASH_POS_ID : posId;
    }


    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.loadButton:
                SplashActivity.skipSplashActivity(this, false, isEnableServerConfig, getPosID());
                break;
            case R.id.loadOnlyButton:
                SplashActivity.skipSplashActivity(this, true,isEnableServerConfig, getPosID());

                break;
            default:
                break;
        }
    }
}
