package com.tofly.ghrq_route.module.emergencyHandle.ui.view;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;

import com.mgq.base.utils.toast.ToastUtil;
import com.tofly.ghrq_route.R;
import com.tofly.ghrq_route.module.emergencyHandle.domain.EmergencyHandleData;
import com.tofly.ghrq_route.common.ui.view.MyAudioRecordButton;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Amu on 2017/2/21.
 */

public class EmergencyRepairHandleReportModuleLayout extends LinearLayout {
    @BindView(R.id.edit_handle_note)
    EditText editHandleNote;
    @BindView(R.id.btn_add_photo)
    Button btnAddPhoto;
    @BindView(R.id.photo_gallery)
    LinearLayout photoGallery;
    @BindView(R.id.btn_audio_record)
    MyAudioRecordButton btnAudioRecord;

    private Context mContext;

    private boolean isEditable;

    public EmergencyRepairHandleReportModuleLayout(Context context) {
        this(context, null);
    }

    public EmergencyRepairHandleReportModuleLayout(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public EmergencyRepairHandleReportModuleLayout(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);

        mContext = context;

        initView();
        initListener();
    }

    private void initView() {
        inflate(mContext, R.layout.layout_emergency_repair_handle_report_module, this);
        ButterKnife.bind(this);
    }

    private void initListener() {

    }

    public boolean isValid() {
        if (editHandleNote.getText().toString().isEmpty()) {
            editHandleNote.requestFocus();
            ToastUtil.showToast(mContext, mContext.getString(R.string.emergency_repair_handle_empty_note));
            return false;
        }

        return true;
    }

    public void collectData(EmergencyHandleData handleData) {
        String note = editHandleNote.getText().toString();
        handleData.setMaintenanceNotes(note);
    }
}
