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

import android.os.Bundle;
import android.widget.EditText;
import android.widget.TextView;
import com.example.administrator.zhapp.R;
import com.example.administrator.zhapp.activity.sbxdjgl.SqdActivity;
import com.example.administrator.zhapp.entity.TestZkdInfo;
import com.example.administrator.zhapp.fragment.BaseFragment;

/**
 * 设备巡点检管理-签点
 */
public class QiandFragment extends BaseFragment {

    TextView tv_zy;
    TextView tv_bz;
    TextView tv_xm;
    TextView tv_gx;
    TextView tv_kzfl;
    EditText et_gh;
    TextView tv_yjzj;
    TextView tv_zt;



    private SqdActivity mActivity;


    private boolean isEdit = false;
    private TestZkdInfo info;
    private int size;

    public QiandFragment() {
    }

    public static QiandFragment newInstance(boolean b, TestZkdInfo info, int size) {
        Bundle bundle = new Bundle();
        bundle.putBoolean("edit", b);
        bundle.putParcelable("info", info);
        bundle.putInt("size", size);
        QiandFragment fragment = new QiandFragment();
        fragment.setArguments(bundle);
        return fragment;
    }

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


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

    @Override
    protected void initView() {
        tv_zy = view.findViewById(R.id.tv_zy);
        tv_bz = view.findViewById(R.id.tv_bz);
        tv_xm = view.findViewById(R.id.tv_xm);
        tv_gx = view.findViewById(R.id.tv_gx);
        tv_kzfl = view.findViewById(R.id.tv_kzfl);
        et_gh = view.findViewById(R.id.et_gh);
        tv_yjzj = view.findViewById(R.id.tv_yjzj);
        tv_zt = view.findViewById(R.id.tv_zt);


        mActivity = (SqdActivity) getActivity();
        et_gh.setEnabled(isEdit);
        updata(info, 1, size);
    }

    public void initData() {
    }

    public void updata(TestZkdInfo info, int item, int size) {

        tv_xm.setText(info.getXm());
        tv_kzfl.setText(info.getKzfl());
        tv_gx.setText(info.getGx());
        tv_bz.setText(info.getBz());
        tv_zy.setText(info.getZy());
        et_gh.setText(info.getGh());
        tv_yjzj.setText(item + "/" + size);
    }
}
