package com.kdanmobile.kdan_others_library_for_android.card;

import android.content.Context;
import android.util.AttributeSet;
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 NoteledgePromoteCard extends LinearLayout {

    private Runnable intentPlayNl;

    private Button tryNow;

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

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

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

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

    public void setTryNlClickListener(Runnable intentPlayNl) {
        this.intentPlayNl = intentPlayNl;
    }

    private void initView() {
        View view = inflate(getContext(), R.layout.widget_noteledge_promote_card, this);
        ImageView imageView = (ImageView) view.findViewById(R.id.imageView_noteledge_card_cover);
        tryNow = (Button) view.findViewById(R.id.button_promote_card_noteledge_try_now);

        imageView.setOnClickListener(view1 -> {
            if (intentPlayNl != null) intentPlayNl.run();
        });

        tryNow.setOnClickListener(view12 -> {
            if (intentPlayNl != null) intentPlayNl.run();
        });
    }
}
