package com.kdanmobile.kdan_others_library_for_android.card;

import android.content.Context;
import android.util.AttributeSet;

import com.bumptech.glide.Glide;
import com.kdanmobile.kdan_others_library_for_android.R;

public class AdonitCreativeStorePromoteCard extends BaseCard {

    private OnClickListener onClickViewNowListener;
    private OnClickListener onClickImageListener;

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

    public AdonitCreativeStorePromoteCard(Context context, AttributeSet attrs) {
        super(context, attrs);
        initView();
    }

    public AdonitCreativeStorePromoteCard(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        initView();
    }

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

    public void setOnClickViewNowListener(OnClickListener onClickViewNowListener) {
        this.onClickViewNowListener = onClickViewNowListener;
    }

    public void setOnClickImageListener(OnClickListener onClickImageListener) {
        this.onClickImageListener = onClickImageListener;
    }

    private void initView() {
        Glide.with(getContext()).load(R.mipmap.cd_adnoitdash3_x_c365).into(getMediaImageView());
        getMediaImageView().setOnClickListener(v -> {
            if (onClickImageListener != null) onClickImageListener.onClick(v);
        });
        getSupportingTextTextView().setVisibility(VISIBLE);
        getSupportingTextTextView().setText(R.string.creative_store_card_description_adonit);
        int c = getContext().getResources().getColor(R.color.card_view_supporting_text_color);
        getSupportingTextTextView().setTextColor(c);
        getAction1Button().setVisibility(VISIBLE);
        getAction1Button().setText(R.string.creative_store_card_view);
        getAction1Button().setOnClickListener(v -> {
            if (onClickViewNowListener != null) onClickViewNowListener.onClick(v);
        });
    }
}
