/*
 * Copyright (c) 2016, Aegir Labs LLC. All rights reserved.
 */

package com.aegir.demo.views;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.aegir.demo.R;
import com.aegir.demo.model.BaseFloorItem;
import com.aegir.demo.model.FloorItem;

/**
 * View used in FloorItemAdapter. Displays a Floor.
 */
public class BuildingItemView extends RelativeLayout {

    // region Fields

    private TextView titleTextView;

    // endregion

    // region Constructors

    /**
     * @param c the activity context
     */
    public BuildingItemView(Context c) {
        this(c, null);
    }

    /**
     * @param context the activity context
     * @param attrs   layout attributes
     */
    public BuildingItemView(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    /**
     * @param context  the activity context
     * @param attrs    layout attributes
     * @param defStyle style resource
     */
    public BuildingItemView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        LayoutInflater.from(context).inflate(R.layout.building_item_view_children, this, true);
        setupChildren();
    }

    // endregion

    // region Public Methods

    /**
     * @param parent the parent to use for inflation
     * @return new view instance
     */
    public static BuildingItemView inflate(ViewGroup parent) {
        BuildingItemView buildingItemView = (BuildingItemView) LayoutInflater.from(parent.getContext())
                .inflate(R.layout.building_item_view, parent, false);
        return buildingItemView;
    }

    /**
     * @param building
     */
    public void setItem(BaseFloorItem building) {
        titleTextView.setText(building.getName());
    }

    // endregion

    // region Private Methods

    /**
     *
     */
    private void setupChildren() {
        titleTextView = (TextView) findViewById(R.id.tv_building_name);
    }

    // endregion
}
