package com.swiftcleaner.chovey.view.dialog;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;

import androidx.appcompat.widget.AppCompatButton;
import androidx.cardview.widget.CardView;

import com.swiftcleaner.chovey.R;
import com.tool.zxdemo.utils.NativeView;
import com.zxdemo.admob.AdmobHelper;

public class CustomScoreDialog extends Dialog {

    private Activity activity;
    private OnDialogClickListener listener;

    public interface OnDialogClickListener {
        void onCancel();

        void onSubmit();
    }

    private NativeView nativeView;

    public CustomScoreDialog(Activity activity) {
        super(activity, R.style.TransparentDialogTheme);
        this.activity = activity;
        setContentView(R.layout.dialog_function_exit_item);

        AppCompatButton dialog_cancel = findViewById(R.id.dialog_cancel);
        AppCompatButton dialog_ok = findViewById(R.id.dialog_ok);
        CardView cardView = findViewById(R.id.cardview);
        cardView.setCardBackgroundColor(Color.TRANSPARENT);

        NativeView nativeView = findViewById(R.id.fl_ad);
        AdmobHelper.INSTANCE.showNativeAd(activity, (nativeAd) -> {
            nativeView.removeAllViews();
            nativeView.setNativeAd(nativeAd, R.layout.layout_ad_native);
            return null;
        }, null, null);

        dialog_cancel.setOnClickListener(v -> {
            if (listener != null) {
                listener.onCancel();
            }
            dismiss();
        });

        dialog_ok.setOnClickListener(v -> {
            if (listener != null) {
                listener.onSubmit();
            }
            dismiss();
        });

        setCanceledOnTouchOutside(false);
    }

    public void show() {
        super.show();

    }

    public void setOnDialogClickListener(OnDialogClickListener listener) {
        this.listener = listener;
    }
}