package com.kdanmobile.kdan_others_library_for_android.card;

import android.content.Context;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.kdanmobile.kdan_others_library_for_android.R;


public class ADPromoteCard extends LinearLayout {

    private Runnable intentPlayAd;

    private Button tryNow;

    public ADPromoteCard(Context context) {
        super(context);
        initView();
    }

    public void setButtonColor(int color) {
        tryNow.setTextColor(color);
    }

    public void setTryAdClickListener(Runnable intentPlayAd){
        this.intentPlayAd = intentPlayAd;
    }

    private void initView() {
        View view = inflate(getContext(), R.layout.widget_ad_promote_card, this);
        tryNow = (Button) view.findViewById(R.id.button_promote_card_ad_try_now);
        ImageView imageView = (ImageView) view.findViewById(R.id.image_view_promote_card_ad);

        tryNow.setOnClickListener(view1 -> {
            if (intentPlayAd != null) intentPlayAd.run();
        });

        imageView.setOnClickListener(view12 -> {
            if (intentPlayAd != null) intentPlayAd.run();
        });
    }
}
