CodeBox.java 2.0 KB
package com.myproject.bean;

import com.myproject.util.StorageConstants;

/**
 * 用于展示到界面
 * Created by sunke on 2017/10/13.
 */
public class CodeBox {
    //显示的位置
    private int location = 0;
    private String msg = "";
    private boolean valid = false;
    private String codeType;

    public CodeBox(int location, String msg, boolean valid, String codeType) {
        this.location = location;
        this.msg = msg;
        this.valid = valid;
        this.codeType = codeType;
    }

    public CodeBox(CodeBean codeBean) {
        this.valid = codeBean.isValid();
        if(valid){
            msg = codeBean.getBarcode().getBarcode();
        }else{
            msg = codeBean.getError();
        }
        StorageConstants.CODE_TYPE type = codeBean.getCodeType();
        if(type == null){
            type = StorageConstants.CODE_TYPE.FIXTURE;
        }
        codeType = type.name();

        int cameraIndex = codeBean.getCameraIndex();
        float locationX = codeBean.getLocationX();
        float locationY = codeBean.getLocationY();
        if(locationX != 0 && locationY != 0){
            if(cameraIndex == 1){
                if(locationX < 1400){
                    location = 1;
                }else {
                    location = 2;
                }
            }else {
                if(locationX < 1000){
                    location = 4;
                }else {
                    location = 3;
                }
            }
        }
    }

    public int getLocation() {
        return location;
    }

    public void setLocation(int location) {
        this.location = location;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public String getCodeType() {
        return codeType;
    }

    public void setCodeType(String codeType) {
        this.codeType = codeType;
    }

    public boolean isValid() {
        return valid;
    }

    public void setValid(boolean valid) {
        this.valid = valid;
    }
}