com.tk.httpClientErp.initialcheck.InitialcheckDetailActivity.java Source code

Java tutorial

Introduction

Here is the source code for com.tk.httpClientErp.initialcheck.InitialcheckDetailActivity.java

Source

package com.tk.httpClientErp.initialcheck;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.TimeoutException;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONObject;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.TextView;
import android.widget.Toast;

import com.tk.MyStore;
import com.tk.httpClientErp.R;
import com.tk.netUtil.BlToIntOrIntToBl;
import com.tk.netUtil.HttpClientUtil;

public class InitialcheckDetailActivity extends Activity {
    private TextView mId;
    private TextView mFiLicense;
    private TextView mXmName;
    private TextView busno;

    private Button mfirstInspectionButton; // 

    private CheckBox mkqlqq;
    private CheckBox mqblqq;
    private CheckBox mjjykg;
    private CheckBox mxyd;
    private CheckBox msxg;
    private CheckBox myxg;
    private CheckBox mbyclg;
    private CheckBox mdcj;
    private CheckBox mzyb;
    private CheckBox msjhl;
    private CheckBox msjhdb;
    private CheckBox mdrz;
    private CheckBox msrz;
    private CheckBox mqdfbl;
    private CheckBox mhdfbl;
    private CheckBox mmfs;
    private CheckBox mcxfs;
    private CheckBox mtccg;
    private CheckBox msxz;
    private CheckBox mygqjp;
    private CheckBox mdlb;
    private CheckBox mlban;
    private CheckBox mdfs;
    private CheckBox mbzq;
    private CheckBox mdd;
    private CheckBox mxdq;
    private CheckBox mxdh;
    private CheckBox mfwd;
    private CheckBox mzxdq;
    private CheckBox mzxdh;
    private CheckBox mzdd;
    private CheckBox mdcd;
    private CheckBox pzd;
    private CheckBox ddeng;
    private CheckBox xd;
    private CheckBox jyb;
    private CheckBox dlbiao;
    private CheckBox qyb;
    private CheckBox swb;
    private CheckBox qybiao;
    private CheckBox lcb;
    private CheckBox mhq;
    private CheckBox cxbl;
    private CheckBox pxan;
    private CheckBox dqkg;
    private CheckBox dzxsp;
    private CheckBox tbx;

    private String fiId;

    private HashMap<String, Object> mFiHashMap;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_firstinspectiondetail);
        fiId = getIntent().getStringExtra("id");
        mFiHashMap = MyStore.getBeanByParam(fiId, "id", MyStore.firstInspectionList);

        mId = (TextView) findViewById(R.id.fi_detail_id);
        mFiLicense = (TextView) findViewById(R.id.fi_license_detail);
        mXmName = (TextView) findViewById(R.id.fi_detail_xmName);
        busno = (TextView) findViewById(R.id.fi_bus_no);

        mId.setText(mFiHashMap.get("id").toString());
        mFiLicense.setText(mFiHashMap.get("license").toString());
        mXmName.setText(mFiHashMap.get("xmName").toString());
        busno.setText(mFiHashMap.get("bus_no").toString());

        mkqlqq = (CheckBox) findViewById(R.id.fi_kqlqq);
        mkqlqq.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("kqlqq"))));
        mkqlqq.setOnCheckedChangeListener(checkBoxCommon("kqlqq", mFiHashMap));

        mqblqq = (CheckBox) findViewById(R.id.fi_qblqq);
        mqblqq.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("qblqq"))));
        mqblqq.setOnCheckedChangeListener(checkBoxCommon("qblqq", mFiHashMap));

        mjjykg = (CheckBox) findViewById(R.id.fi_jjykg);
        mjjykg.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("jjykg"))));
        mjjykg.setOnCheckedChangeListener(checkBoxCommon("jjykg", mFiHashMap));

        mxyd = (CheckBox) findViewById(R.id.fi_xyd);
        mxyd.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("xyd"))));
        mxyd.setOnCheckedChangeListener(checkBoxCommon("xyd", mFiHashMap));

        msxg = (CheckBox) findViewById(R.id.fi_sxg);
        msxg.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("sxg"))));
        msxg.setOnCheckedChangeListener(checkBoxCommon("sxg", mFiHashMap));

        myxg = (CheckBox) findViewById(R.id.fi_yxg);
        myxg.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("yxg"))));
        myxg.setOnCheckedChangeListener(checkBoxCommon("yxg", mFiHashMap));

        mbyclg = (CheckBox) findViewById(R.id.fi_byclg);
        mbyclg.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("byclg"))));
        mbyclg.setOnCheckedChangeListener(checkBoxCommon("byclg", mFiHashMap));

        mdcj = (CheckBox) findViewById(R.id.fi_dcj);
        mdcj.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("dcj"))));
        mdcj.setOnCheckedChangeListener(checkBoxCommon("dcj", mFiHashMap));

        mzyb = (CheckBox) findViewById(R.id.fi_zyb);
        mzyb.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("zyb"))));
        mzyb.setOnCheckedChangeListener(checkBoxCommon("zyb", mFiHashMap));

        msjhl = (CheckBox) findViewById(R.id.fi_sjhl);
        msjhl.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("sjhl"))));
        msjhl.setOnCheckedChangeListener(checkBoxCommon("sjhl", mFiHashMap));

        msjhdb = (CheckBox) findViewById(R.id.fi_sjhdb);
        msjhdb.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("sjhdb"))));
        msjhdb.setOnCheckedChangeListener(checkBoxCommon("sjhdb", mFiHashMap));

        mdrz = (CheckBox) findViewById(R.id.fi_drz);
        mdrz.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("drz"))));
        mdrz.setOnCheckedChangeListener(checkBoxCommon("drz", mFiHashMap));

        msrz = (CheckBox) findViewById(R.id.fi_srz);
        msrz.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("srz"))));
        msrz.setOnCheckedChangeListener(checkBoxCommon("srz", mFiHashMap));

        mqdfbl = (CheckBox) findViewById(R.id.fi_qdfbl);
        mqdfbl.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("qdfbl"))));
        mqdfbl.setOnCheckedChangeListener(checkBoxCommon("qdfbl", mFiHashMap));

        mhdfbl = (CheckBox) findViewById(R.id.fi_hdfbl);
        mhdfbl.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("hdfbl"))));
        mhdfbl.setOnCheckedChangeListener(checkBoxCommon("hdfbl", mFiHashMap));

        mmfs = (CheckBox) findViewById(R.id.fi_mfs);
        mmfs.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("mfs"))));
        mmfs.setOnCheckedChangeListener(checkBoxCommon("mfs", mFiHashMap));

        mcxfs = (CheckBox) findViewById(R.id.fi_cxfs);
        mcxfs.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("cxfs"))));
        mcxfs.setOnCheckedChangeListener(checkBoxCommon("cxfs", mFiHashMap));

        mtccg = (CheckBox) findViewById(R.id.fi_tccg);
        mtccg.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("tccg"))));
        mtccg.setOnCheckedChangeListener(checkBoxCommon("tccg", mFiHashMap));

        msxz = (CheckBox) findViewById(R.id.fi_sxz);
        msxz.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("sxz"))));
        msxz.setOnCheckedChangeListener(checkBoxCommon("sxz", mFiHashMap));

        mygqjp = (CheckBox) findViewById(R.id.fi_ygqjp);
        mygqjp.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("ygqjp"))));
        mygqjp.setOnCheckedChangeListener(checkBoxCommon("ygqjp", mFiHashMap));

        mdlb = (CheckBox) findViewById(R.id.fi_dlb);
        mdlb.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("dlb"))));
        mdlb.setOnCheckedChangeListener(checkBoxCommon("dlb", mFiHashMap));

        mlban = (CheckBox) findViewById(R.id.fi_lban);
        mlban.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("lban"))));
        mlban.setOnCheckedChangeListener(checkBoxCommon("lban", mFiHashMap));

        mdfs = (CheckBox) findViewById(R.id.fi_dfs);
        mdfs.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("dfs"))));
        mdfs.setOnCheckedChangeListener(checkBoxCommon("dfs", mFiHashMap));

        mbzq = (CheckBox) findViewById(R.id.fi_bzq);
        mbzq.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("bzq"))));
        mbzq.setOnCheckedChangeListener(checkBoxCommon("bzq", mFiHashMap));

        mdd = (CheckBox) findViewById(R.id.fi_dd);
        mdd.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("dd"))));
        mdd.setOnCheckedChangeListener(checkBoxCommon("dd", mFiHashMap));

        mxdq = (CheckBox) findViewById(R.id.fi_xdq);
        mxdq.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("xdq"))));
        mxdq.setOnCheckedChangeListener(checkBoxCommon("xdq", mFiHashMap));

        mxdh = (CheckBox) findViewById(R.id.fi_xdh);
        mxdh.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("xdh"))));
        mxdh.setOnCheckedChangeListener(checkBoxCommon("xdh", mFiHashMap));

        mfwd = (CheckBox) findViewById(R.id.fi_fwd);
        mfwd.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("fwd"))));
        mfwd.setOnCheckedChangeListener(checkBoxCommon("fwd", mFiHashMap));

        mzxdq = (CheckBox) findViewById(R.id.fi_zxdq);
        mzxdq.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("zxdq"))));
        mzxdq.setOnCheckedChangeListener(checkBoxCommon("zxdq", mFiHashMap));

        mzxdh = (CheckBox) findViewById(R.id.fi_zxdh);
        mzxdh.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("zxdh"))));
        mzxdh.setOnCheckedChangeListener(checkBoxCommon("zxdh", mFiHashMap));

        mzdd = (CheckBox) findViewById(R.id.fi_zdd);
        mzdd.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("zdd"))));
        mzdd.setOnCheckedChangeListener(checkBoxCommon("zdd", mFiHashMap));

        mdcd = (CheckBox) findViewById(R.id.fi_dcd);
        mdcd.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("dcd"))));
        mdcd.setOnCheckedChangeListener(checkBoxCommon("dcd", mFiHashMap));

        pzd = (CheckBox) findViewById(R.id.fi_pzd);
        pzd.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("pzd"))));
        pzd.setOnCheckedChangeListener(checkBoxCommon("pzd", mFiHashMap));

        ddeng = (CheckBox) findViewById(R.id.fi_ddeng);
        ddeng.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("ddeng"))));
        ddeng.setOnCheckedChangeListener(checkBoxCommon("ddeng", mFiHashMap));

        xd = (CheckBox) findViewById(R.id.fi_xd);
        xd.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("xd"))));
        xd.setOnCheckedChangeListener(checkBoxCommon("xd", mFiHashMap));

        jyb = (CheckBox) findViewById(R.id.fi_jyb);
        jyb.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("jyb"))));
        jyb.setOnCheckedChangeListener(checkBoxCommon("jyb", mFiHashMap));

        dlbiao = (CheckBox) findViewById(R.id.fi_dlbiao);
        dlbiao.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("dlbiao"))));
        dlbiao.setOnCheckedChangeListener(checkBoxCommon("dlbiao", mFiHashMap));

        qyb = (CheckBox) findViewById(R.id.fi_qyb);
        qyb.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("qyb"))));
        qyb.setOnCheckedChangeListener(checkBoxCommon("qyb", mFiHashMap));

        swb = (CheckBox) findViewById(R.id.fi_swb);
        swb.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("swb"))));
        swb.setOnCheckedChangeListener(checkBoxCommon("swb", mFiHashMap));

        qybiao = (CheckBox) findViewById(R.id.fi_qybiao);
        qybiao.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("qybiao"))));
        qybiao.setOnCheckedChangeListener(checkBoxCommon("qybiao", mFiHashMap));

        lcb = (CheckBox) findViewById(R.id.fi_lcb);
        lcb.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("lcb"))));
        lcb.setOnCheckedChangeListener(checkBoxCommon("lcb", mFiHashMap));

        mhq = (CheckBox) findViewById(R.id.fi_mhq);
        mhq.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("mhq"))));
        mhq.setOnCheckedChangeListener(checkBoxCommon("mhq", mFiHashMap));

        cxbl = (CheckBox) findViewById(R.id.fi_cxbl);
        cxbl.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("cxbl"))));
        cxbl.setOnCheckedChangeListener(checkBoxCommon("cxbl", mFiHashMap));

        pxan = (CheckBox) findViewById(R.id.fi_pxan);
        pxan.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("pxan"))));
        pxan.setOnCheckedChangeListener(checkBoxCommon("pxan", mFiHashMap));

        dqkg = (CheckBox) findViewById(R.id.fi_dqkg);
        dqkg.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("dqkg"))));
        dqkg.setOnCheckedChangeListener(checkBoxCommon("dqkg", mFiHashMap));

        dzxsp = (CheckBox) findViewById(R.id.fi_dzxsp);
        dzxsp.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("dzxsp"))));
        dzxsp.setOnCheckedChangeListener(checkBoxCommon("dzxsp", mFiHashMap));

        tbx = (CheckBox) findViewById(R.id.fi_tbx);
        tbx.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("tbx"))));
        tbx.setOnCheckedChangeListener(checkBoxCommon("tbx", mFiHashMap));

        // 
        mfirstInspectionButton = (Button) findViewById(R.id.firstInspection_button);
        mfirstInspectionButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                List<NameValuePair> params = new ArrayList<NameValuePair>();
                JSONObject fiInfoJsonObj = new JSONObject(mFiHashMap);
                params.add(new BasicNameValuePair("fiInfo", fiInfoJsonObj.toString()));
                try {
                    final String reultString = HttpClientUtil.postRequest("/android.do?method=savefiDetail", params,
                            MyStore.sessionID);
                    InitialcheckDetailActivity.this.runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            Toast.makeText(InitialcheckDetailActivity.this,
                                    HttpClientUtil.callBackSuccOrFail(reultString, "resualt"), Toast.LENGTH_SHORT)
                                    .show();
                        }
                    });
                } catch (TimeoutException e) {
                    e.printStackTrace();
                    InitialcheckDetailActivity.this.runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            Toast.makeText(InitialcheckDetailActivity.this, MyStore.TIMEOUTLOGIN,
                                    Toast.LENGTH_SHORT).show();
                        }
                    });
                }
                InitialcheckDetailActivity.this.finish();
                if (HttpClientUtil.reSUCCorFAILE)
                    MyStore.deletBeanById(fiId, "id", MyStore.firstInspectionList); // List
            }
        });
    }

    /**
     * Checkbox
     * 
     * @param paremString
     * @param busHaMap
     * @return
     */
    private OnCheckedChangeListener checkBoxCommon(final String paramString,
            final HashMap<String, Object> busHaMap) {
        OnCheckedChangeListener changeListener = new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                busHaMap.put(paramString, isChecked);
            }
        };
        return changeListener;
    }
}