ElectronicCardInfoOKActivity.java 5.42 KB
package com.hjx.personalcenter.activity;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.hjx.personalcenter.R;
import com.hjx.personalcenter.db.Content;
import com.hjx.personalcenter.db.SaveParam;
import com.hjx.personalcenter.http.HttpManager;
import com.hjx.personalcenter.util.GetDevicesUtil;

/**确认保卡信息
 * Created by h on 2017/8/11.
 */

public class ElectronicCardInfoOKActivity extends FragmentActivity implements View.OnClickListener {
    private Button btn_finish,btn_bangding;
    private ImageView iv_last_step;
    private TextView usename,deviceModel,customer_address,mac_adress,shoptime,deviceNumber,shopadress,phone,tlePhone;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ok_cardinfo);
        SysApplication.getInstance().addActivity(this);
        initView();
        initData();
        initLister();
    }
    private void initView() {
        btn_finish = (Button) findViewById(R.id.btn_finish);
        iv_last_step  = (ImageView) findViewById(R.id.cancel);
        usename = (TextView) findViewById(R.id.iv_card_username);
        deviceModel = (TextView) findViewById(R.id.tv_card_deviceModel);
        customer_address = (TextView) findViewById(R.id.tv_card_adress);
        mac_adress = (TextView) findViewById(R.id.tv_card_mac);
        shoptime = (TextView) findViewById(R.id.tv_card_time);
        deviceNumber = (TextView) findViewById(R.id.tv_card_deviceNumber);
        shopadress = (TextView) findViewById(R.id.tv_card_shopAdress);
        phone = (TextView) findViewById(R.id.tv_card_phone);
        tlePhone = (TextView) findViewById(R.id.tv_card_tleNember);
        btn_bangding = (Button) findViewById(R.id.btn_bangding);
    }

    private void initData() {
        //获取设备信息
        deviceModel.setText(GetDevicesUtil.getDevicesInfo(this).getDeviceModel());
        deviceNumber.setText(GetDevicesUtil.getDevicesInfo(this).getDeviceNumber());
        mac_adress.setText(GetDevicesUtil.getDevicesInfo(this).getMac());
        //获取保卡信息
        usename.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.CUNSTEMNAME));
        customer_address.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.ADRESSCUNSTEM));
        shoptime.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.SHOPTIME));
        shopadress.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.SHOPADRESS));
        tlePhone.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.SHOPTLEPHONE));
        phone.setText(SaveParam.getInstance().getCustomizeParam(this,SaveParam.CARDPHONE));


    }

    private void initLister() {
        iv_last_step.setOnClickListener(this);
        btn_finish.setOnClickListener(this);
        btn_bangding.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        String userID = SaveParam.getInstance().getLoginParam(this,"userId");
        long auserID = 0;
        switch (v.getId()){
            case R.id.btn_finish:
                Content.cardintentflag =1;
                try {
                    auserID = Long.parseLong(userID);
                } catch (NumberFormatException e) {
                    e.printStackTrace();
                }
                HttpManager.getInstance().subcardinfo(this,auserID,usename.getText().toString().trim(),
                        customer_address.getText().toString().trim(),shopadress.getText().toString().trim(),
                        shoptime.getText().toString().trim(),tlePhone.getText().toString().trim(),
                        deviceModel.getText().toString().trim(),deviceNumber.getText().toString().trim(),
                        mac_adress.getText().toString().trim(),phone.getText().toString().trim());
                break;
            case R.id.btn_bangding:
                Content.cardintentflag =2;
                try {
                    auserID = Long.parseLong(userID);
                } catch (NumberFormatException e) {
                    e.printStackTrace();
                }
                HttpManager.getInstance().subcardinfo(this,auserID,usename.getText().toString().trim(),
                        customer_address.getText().toString().trim(),shopadress.getText().toString().trim(),
                        shoptime.getText().toString().trim(),tlePhone.getText().toString().trim(),
                        deviceModel.getText().toString().trim(),deviceNumber.getText().toString().trim(),
                        mac_adress.getText().toString().trim(),phone.getText().toString().trim());

                break;
            case R.id.cancel:
                finish();
                break;
        }
    }
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            SaveParam.getInstance().saveCustomizeParam(ElectronicCardInfoOKActivity.this,SaveParam.CARDPHONE,"");
            return false;//return true;拦截事件传递,从而屏蔽back键。
        }
        if (KeyEvent.KEYCODE_HOME == keyCode) {
            SaveParam.getInstance().saveCustomizeParam(ElectronicCardInfoOKActivity.this,SaveParam.CARDPHONE,"");
            return false;//同理
        }
        return super.onKeyDown(keyCode, event);
    }

}