package de.frajul.endlessroll.views;

import android.content.Context;
import android.graphics.Typeface;
import android.support.annotation.DrawableRes;
import android.support.annotation.StringRes;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import de.frajul.endlessroll.R;

/**
 * Created by Julian on 01.08.2016.
 */
public class PriceButton {

    private Context context;

    private View layout;
    private TextView title;
    private TextView price;
    private ImageView currencyView;

    public PriceButton(Context context, Typeface typeface, View layout, View.OnClickListener onClickListener) {
        this.context = context;
        this.layout = layout;
        layout.setOnClickListener(onClickListener);

        title = (TextView) layout.findViewById(R.id.price_button_title);
        title.setTypeface(typeface);
        price = (TextView) layout.findViewById(R.id.price_button_price);
        price.setTypeface(typeface);
        currencyView = (ImageView) layout.findViewById(R.id.price_button_currency);
    }

    public void init(@StringRes int title, int price, @DrawableRes int currencyDrawable) {
        this.title.setText(title);
        this.price.setText(price + "");
        this.currencyView.setImageDrawable(context.getResources().getDrawable(currencyDrawable));
    }

    public void setLayoutEnabled(boolean enabled){
        layout.setEnabled(enabled);
    }

    public void setLayoutVisible(int visibility){
        layout.setVisibility(visibility);
    }

}
