package com.example.administrator.zhapp.fragment.sbxdjgl;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import com.example.administrator.zhapp.R;
import com.example.administrator.zhapp.activity.sbxdjgl.SqdActivity;
import com.example.administrator.zhapp.fragment.BaseFragment;
import com.example.administrator.zhapp.utils.UiUtlis;

/**
 * 质控点-缺陷工单
 */
public class ZqxgdFragment extends BaseFragment {

    EditText et_gd;
    EditText et_ms;
    EditText et_zy;
    EditText et_bgr;
    EditText et_date;
    Button btn_save;
    Button btn_cancel;

    @Override
    protected void initView() {
        et_gd = view.findViewById(R.id.et_gd);
        et_ms = view.findViewById(R.id.et_ms);
        et_zy = view.findViewById(R.id.et_zy);
        et_bgr = view.findViewById(R.id.et_bgr);
        et_date = view.findViewById(R.id.et_date);
        btn_save = view.findViewById(R.id.btn_save);
        btn_cancel = view.findViewById(R.id.btn_cancel);

        btn_save.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                showToast(UiUtlis.getString(context,R.string.save));
            }
        });

        btn_cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                showToast(UiUtlis.getString(context,R.string.cancel));
            }
        });

        mActivity = (SqdActivity) getActivity();
        setEnabled(isEdit);
    }

    private SqdActivity mActivity;
    private boolean isEdit = false;

    public ZqxgdFragment() {
    }

    public static ZqxgdFragment newInstance(boolean b) {
        Bundle bundle = new Bundle();
        bundle.putBoolean("edit", b);
        ZqxgdFragment fragment = new ZqxgdFragment();
        fragment.setArguments(bundle);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle bundle = getArguments();
        if (bundle != null) {
            isEdit = bundle.getBoolean("edit");
        }
    }

    @Override
    public int getContentViewId() {
        return R.layout.fragment_zqxgd;
    }

    @Override
    public void initData() {

    }

    private void setEnabled(boolean isEdit) {
        et_bgr.setEnabled(isEdit);
        et_date.setEnabled(isEdit);
        et_gd.setEnabled(isEdit);
        et_zy.setEnabled(isEdit);
        et_ms.setEnabled(isEdit);
    }
}
