diff --git a/app/src/main/java/com/casic/detector/extensions/ByteArray.kt b/app/src/main/java/com/casic/detector/extensions/ByteArray.kt new file mode 100644 index 0000000..8094b03 --- /dev/null +++ b/app/src/main/java/com/casic/detector/extensions/ByteArray.kt @@ -0,0 +1,15 @@ +package com.casic.detector.extensions + +/** + * ByteArray转Hex + * */ +fun ByteArray.toHex(): String { + val hexArray = "0123456789ABCDEF".toCharArray() + val hexChars = CharArray(this.size * 2) + for (j in this.indices) { + val v: Int = this[j].toInt() and 0xFF + hexChars[j * 2] = hexArray[v ushr 4] + hexChars[j * 2 + 1] = hexArray[v and 0x0F] + } + return String(hexChars) +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/detector/extensions/ByteArray.kt b/app/src/main/java/com/casic/detector/extensions/ByteArray.kt new file mode 100644 index 0000000..8094b03 --- /dev/null +++ b/app/src/main/java/com/casic/detector/extensions/ByteArray.kt @@ -0,0 +1,15 @@ +package com.casic.detector.extensions + +/** + * ByteArray转Hex + * */ +fun ByteArray.toHex(): String { + val hexArray = "0123456789ABCDEF".toCharArray() + val hexChars = CharArray(this.size * 2) + for (j in this.indices) { + val v: Int = this[j].toInt() and 0xFF + hexChars[j * 2] = hexArray[v ushr 4] + hexChars[j * 2 + 1] = hexArray[v and 0x0F] + } + return String(hexChars) +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/detector/extensions/String.kt b/app/src/main/java/com/casic/detector/extensions/String.kt index aacd89d..84b3d2c 100644 --- a/app/src/main/java/com/casic/detector/extensions/String.kt +++ b/app/src/main/java/com/casic/detector/extensions/String.kt @@ -103,4 +103,21 @@ //根据控件名字取默认值 fun String.getDefaultValue(): String { return SaveKeyValues.getValue(this, "") as String +} + +fun String.hexToString(): String { + val sb = StringBuilder() + val temp: StringBuilder = StringBuilder() + run { + var i = 0 + while (i < this.length - 1) { + // 每两个Hex为一组 + val output = this.substring(i, i + 2) + val decimal = output.toInt(16) + sb.append(decimal.toChar()) + temp.append(decimal) + i += 2 + } + } + return sb.toString() } \ No newline at end of file diff --git a/app/src/main/java/com/casic/detector/extensions/ByteArray.kt b/app/src/main/java/com/casic/detector/extensions/ByteArray.kt new file mode 100644 index 0000000..8094b03 --- /dev/null +++ b/app/src/main/java/com/casic/detector/extensions/ByteArray.kt @@ -0,0 +1,15 @@ +package com.casic.detector.extensions + +/** + * ByteArray转Hex + * */ +fun ByteArray.toHex(): String { + val hexArray = "0123456789ABCDEF".toCharArray() + val hexChars = CharArray(this.size * 2) + for (j in this.indices) { + val v: Int = this[j].toInt() and 0xFF + hexChars[j * 2] = hexArray[v ushr 4] + hexChars[j * 2 + 1] = hexArray[v and 0x0F] + } + return String(hexChars) +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/detector/extensions/String.kt b/app/src/main/java/com/casic/detector/extensions/String.kt index aacd89d..84b3d2c 100644 --- a/app/src/main/java/com/casic/detector/extensions/String.kt +++ b/app/src/main/java/com/casic/detector/extensions/String.kt @@ -103,4 +103,21 @@ //根据控件名字取默认值 fun String.getDefaultValue(): String { return SaveKeyValues.getValue(this, "") as String +} + +fun String.hexToString(): String { + val sb = StringBuilder() + val temp: StringBuilder = StringBuilder() + run { + var i = 0 + while (i < this.length - 1) { + // 每两个Hex为一组 + val output = this.substring(i, i + 2) + val decimal = output.toInt(16) + sb.append(decimal.toChar()) + temp.append(decimal) + i += 2 + } + } + return sb.toString() } \ No newline at end of file diff --git a/app/src/main/java/com/casic/detector/greendao/DaoMaster.java b/app/src/main/java/com/casic/detector/greendao/DaoMaster.java index e344021..cab23bb 100644 --- a/app/src/main/java/com/casic/detector/greendao/DaoMaster.java +++ b/app/src/main/java/com/casic/detector/greendao/DaoMaster.java @@ -19,9 +19,7 @@ public class DaoMaster extends AbstractDaoMaster { public static final int SCHEMA_VERSION = 1; - /** - * Creates underlying database table using DAOs. - */ + /** Creates underlying database table using DAOs. */ public static void createAllTables(Database db, boolean ifNotExists) { LabelBeanDao.createTable(db, ifNotExists); SmallLabelBeanDao.createTable(db, ifNotExists); diff --git a/app/src/main/java/com/casic/detector/extensions/ByteArray.kt b/app/src/main/java/com/casic/detector/extensions/ByteArray.kt new file mode 100644 index 0000000..8094b03 --- /dev/null +++ b/app/src/main/java/com/casic/detector/extensions/ByteArray.kt @@ -0,0 +1,15 @@ +package com.casic.detector.extensions + +/** + * ByteArray转Hex + * */ +fun ByteArray.toHex(): String { + val hexArray = "0123456789ABCDEF".toCharArray() + val hexChars = CharArray(this.size * 2) + for (j in this.indices) { + val v: Int = this[j].toInt() and 0xFF + hexChars[j * 2] = hexArray[v ushr 4] + hexChars[j * 2 + 1] = hexArray[v and 0x0F] + } + return String(hexChars) +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/detector/extensions/String.kt b/app/src/main/java/com/casic/detector/extensions/String.kt index aacd89d..84b3d2c 100644 --- a/app/src/main/java/com/casic/detector/extensions/String.kt +++ b/app/src/main/java/com/casic/detector/extensions/String.kt @@ -103,4 +103,21 @@ //根据控件名字取默认值 fun String.getDefaultValue(): String { return SaveKeyValues.getValue(this, "") as String +} + +fun String.hexToString(): String { + val sb = StringBuilder() + val temp: StringBuilder = StringBuilder() + run { + var i = 0 + while (i < this.length - 1) { + // 每两个Hex为一组 + val output = this.substring(i, i + 2) + val decimal = output.toInt(16) + sb.append(decimal.toChar()) + temp.append(decimal) + i += 2 + } + } + return sb.toString() } \ No newline at end of file diff --git a/app/src/main/java/com/casic/detector/greendao/DaoMaster.java b/app/src/main/java/com/casic/detector/greendao/DaoMaster.java index e344021..cab23bb 100644 --- a/app/src/main/java/com/casic/detector/greendao/DaoMaster.java +++ b/app/src/main/java/com/casic/detector/greendao/DaoMaster.java @@ -19,9 +19,7 @@ public class DaoMaster extends AbstractDaoMaster { public static final int SCHEMA_VERSION = 1; - /** - * Creates underlying database table using DAOs. - */ + /** Creates underlying database table using DAOs. */ public static void createAllTables(Database db, boolean ifNotExists) { LabelBeanDao.createTable(db, ifNotExists); SmallLabelBeanDao.createTable(db, ifNotExists); diff --git a/app/src/main/java/com/casic/detector/greendao/DaoSession.java b/app/src/main/java/com/casic/detector/greendao/DaoSession.java index d950876..6491987 100644 --- a/app/src/main/java/com/casic/detector/greendao/DaoSession.java +++ b/app/src/main/java/com/casic/detector/greendao/DaoSession.java @@ -16,7 +16,7 @@ /** * {@inheritDoc} - * + * * @see org.greenrobot.greendao.AbstractDaoSession */ public class DaoSession extends AbstractDaoSession { @@ -50,7 +50,7 @@ registerDao(SmallLabelBean.class, smallLabelBeanDao); registerDao(TaskBean.class, taskBeanDao); } - + public void clear() { labelBeanDaoConfig.clearIdentityScope(); smallLabelBeanDaoConfig.clearIdentityScope(); diff --git a/app/src/main/java/com/casic/detector/extensions/ByteArray.kt b/app/src/main/java/com/casic/detector/extensions/ByteArray.kt new file mode 100644 index 0000000..8094b03 --- /dev/null +++ b/app/src/main/java/com/casic/detector/extensions/ByteArray.kt @@ -0,0 +1,15 @@ +package com.casic.detector.extensions + +/** + * ByteArray转Hex + * */ +fun ByteArray.toHex(): String { + val hexArray = "0123456789ABCDEF".toCharArray() + val hexChars = CharArray(this.size * 2) + for (j in this.indices) { + val v: Int = this[j].toInt() and 0xFF + hexChars[j * 2] = hexArray[v ushr 4] + hexChars[j * 2 + 1] = hexArray[v and 0x0F] + } + return String(hexChars) +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/detector/extensions/String.kt b/app/src/main/java/com/casic/detector/extensions/String.kt index aacd89d..84b3d2c 100644 --- a/app/src/main/java/com/casic/detector/extensions/String.kt +++ b/app/src/main/java/com/casic/detector/extensions/String.kt @@ -103,4 +103,21 @@ //根据控件名字取默认值 fun String.getDefaultValue(): String { return SaveKeyValues.getValue(this, "") as String +} + +fun String.hexToString(): String { + val sb = StringBuilder() + val temp: StringBuilder = StringBuilder() + run { + var i = 0 + while (i < this.length - 1) { + // 每两个Hex为一组 + val output = this.substring(i, i + 2) + val decimal = output.toInt(16) + sb.append(decimal.toChar()) + temp.append(decimal) + i += 2 + } + } + return sb.toString() } \ No newline at end of file diff --git a/app/src/main/java/com/casic/detector/greendao/DaoMaster.java b/app/src/main/java/com/casic/detector/greendao/DaoMaster.java index e344021..cab23bb 100644 --- a/app/src/main/java/com/casic/detector/greendao/DaoMaster.java +++ b/app/src/main/java/com/casic/detector/greendao/DaoMaster.java @@ -19,9 +19,7 @@ public class DaoMaster extends AbstractDaoMaster { public static final int SCHEMA_VERSION = 1; - /** - * Creates underlying database table using DAOs. - */ + /** Creates underlying database table using DAOs. */ public static void createAllTables(Database db, boolean ifNotExists) { LabelBeanDao.createTable(db, ifNotExists); SmallLabelBeanDao.createTable(db, ifNotExists); diff --git a/app/src/main/java/com/casic/detector/greendao/DaoSession.java b/app/src/main/java/com/casic/detector/greendao/DaoSession.java index d950876..6491987 100644 --- a/app/src/main/java/com/casic/detector/greendao/DaoSession.java +++ b/app/src/main/java/com/casic/detector/greendao/DaoSession.java @@ -16,7 +16,7 @@ /** * {@inheritDoc} - * + * * @see org.greenrobot.greendao.AbstractDaoSession */ public class DaoSession extends AbstractDaoSession { @@ -50,7 +50,7 @@ registerDao(SmallLabelBean.class, smallLabelBeanDao); registerDao(TaskBean.class, taskBeanDao); } - + public void clear() { labelBeanDaoConfig.clearIdentityScope(); smallLabelBeanDaoConfig.clearIdentityScope(); diff --git a/app/src/main/java/com/casic/detector/greendao/LabelBeanDao.java b/app/src/main/java/com/casic/detector/greendao/LabelBeanDao.java index 183a99e..99e1ff9 100644 --- a/app/src/main/java/com/casic/detector/greendao/LabelBeanDao.java +++ b/app/src/main/java/com/casic/detector/greendao/LabelBeanDao.java @@ -12,9 +12,9 @@ import org.greenrobot.greendao.internal.DaoConfig; // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** +/** * DAO for table "LABEL_BEAN". - */ +*/ public class LabelBeanDao extends AbstractDao { public static final String TABLENAME = "LABEL_BEAN"; @@ -57,16 +57,14 @@ public LabelBeanDao(DaoConfig config) { super(config); } - + public LabelBeanDao(DaoConfig config, DaoSession daoSession) { super(config, daoSession); } - /** - * Creates the underlying database table. - */ + /** Creates the underlying database table. */ public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists ? "IF NOT EXISTS ": ""; + String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"LABEL_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id "\"OBJECT_TYPE\" TEXT," + // 1: objectType @@ -376,7 +374,7 @@ if (remark != null) { stmt.bindString(26, remark); } - + String imagePath = entity.getImagePath(); if (imagePath != null) { stmt.bindString(27, imagePath); @@ -386,38 +384,38 @@ @Override public Long readKey(Cursor cursor, int offset) { return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } + } @Override public LabelBean readEntity(Cursor cursor, int offset) { LabelBean entity = new LabelBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // objectType - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // pipelineType - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // pipelineMaterial - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // pipelineDiameter - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // buryDeep - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // lowerType - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // lowerMaterial - cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // lowerDiameter - cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // lowerDeep - cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // buryMethod - cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // area - cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // line - cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13), // road - cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // constructTime - cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15), // owner - cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // objectId - cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17), // identifierId - cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18), // identifierType - cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // identifierDeep - cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20), // person - cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21), // installTime - cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22), // lng - cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23), // lat - cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24), // color - cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25), // remark - cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26) // imagePath + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // objectType + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // pipelineType + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // pipelineMaterial + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // pipelineDiameter + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // buryDeep + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // lowerType + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // lowerMaterial + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // lowerDiameter + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // lowerDeep + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // buryMethod + cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // area + cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // line + cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13), // road + cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // constructTime + cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15), // owner + cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // objectId + cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17), // identifierId + cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18), // identifierType + cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // identifierDeep + cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20), // person + cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21), // installTime + cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22), // lng + cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23), // lat + cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24), // color + cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25), // remark + cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26) // imagePath ); return entity; } @@ -451,17 +449,17 @@ entity.setColor(cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24)); entity.setRemark(cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25)); entity.setImagePath(cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26)); - } - + } + @Override protected final Long updateKeyAfterInsert(LabelBean entity, long rowId) { entity.setId(rowId); return rowId; } - + @Override public Long getKey(LabelBean entity) { - if (entity != null) { + if(entity != null) { return entity.getId(); } else { return null; diff --git a/app/src/main/java/com/casic/detector/extensions/ByteArray.kt b/app/src/main/java/com/casic/detector/extensions/ByteArray.kt new file mode 100644 index 0000000..8094b03 --- /dev/null +++ b/app/src/main/java/com/casic/detector/extensions/ByteArray.kt @@ -0,0 +1,15 @@ +package com.casic.detector.extensions + +/** + * ByteArray转Hex + * */ +fun ByteArray.toHex(): String { + val hexArray = "0123456789ABCDEF".toCharArray() + val hexChars = CharArray(this.size * 2) + for (j in this.indices) { + val v: Int = this[j].toInt() and 0xFF + hexChars[j * 2] = hexArray[v ushr 4] + hexChars[j * 2 + 1] = hexArray[v and 0x0F] + } + return String(hexChars) +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/detector/extensions/String.kt b/app/src/main/java/com/casic/detector/extensions/String.kt index aacd89d..84b3d2c 100644 --- a/app/src/main/java/com/casic/detector/extensions/String.kt +++ b/app/src/main/java/com/casic/detector/extensions/String.kt @@ -103,4 +103,21 @@ //根据控件名字取默认值 fun String.getDefaultValue(): String { return SaveKeyValues.getValue(this, "") as String +} + +fun String.hexToString(): String { + val sb = StringBuilder() + val temp: StringBuilder = StringBuilder() + run { + var i = 0 + while (i < this.length - 1) { + // 每两个Hex为一组 + val output = this.substring(i, i + 2) + val decimal = output.toInt(16) + sb.append(decimal.toChar()) + temp.append(decimal) + i += 2 + } + } + return sb.toString() } \ No newline at end of file diff --git a/app/src/main/java/com/casic/detector/greendao/DaoMaster.java b/app/src/main/java/com/casic/detector/greendao/DaoMaster.java index e344021..cab23bb 100644 --- a/app/src/main/java/com/casic/detector/greendao/DaoMaster.java +++ b/app/src/main/java/com/casic/detector/greendao/DaoMaster.java @@ -19,9 +19,7 @@ public class DaoMaster extends AbstractDaoMaster { public static final int SCHEMA_VERSION = 1; - /** - * Creates underlying database table using DAOs. - */ + /** Creates underlying database table using DAOs. */ public static void createAllTables(Database db, boolean ifNotExists) { LabelBeanDao.createTable(db, ifNotExists); SmallLabelBeanDao.createTable(db, ifNotExists); diff --git a/app/src/main/java/com/casic/detector/greendao/DaoSession.java b/app/src/main/java/com/casic/detector/greendao/DaoSession.java index d950876..6491987 100644 --- a/app/src/main/java/com/casic/detector/greendao/DaoSession.java +++ b/app/src/main/java/com/casic/detector/greendao/DaoSession.java @@ -16,7 +16,7 @@ /** * {@inheritDoc} - * + * * @see org.greenrobot.greendao.AbstractDaoSession */ public class DaoSession extends AbstractDaoSession { @@ -50,7 +50,7 @@ registerDao(SmallLabelBean.class, smallLabelBeanDao); registerDao(TaskBean.class, taskBeanDao); } - + public void clear() { labelBeanDaoConfig.clearIdentityScope(); smallLabelBeanDaoConfig.clearIdentityScope(); diff --git a/app/src/main/java/com/casic/detector/greendao/LabelBeanDao.java b/app/src/main/java/com/casic/detector/greendao/LabelBeanDao.java index 183a99e..99e1ff9 100644 --- a/app/src/main/java/com/casic/detector/greendao/LabelBeanDao.java +++ b/app/src/main/java/com/casic/detector/greendao/LabelBeanDao.java @@ -12,9 +12,9 @@ import org.greenrobot.greendao.internal.DaoConfig; // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** +/** * DAO for table "LABEL_BEAN". - */ +*/ public class LabelBeanDao extends AbstractDao { public static final String TABLENAME = "LABEL_BEAN"; @@ -57,16 +57,14 @@ public LabelBeanDao(DaoConfig config) { super(config); } - + public LabelBeanDao(DaoConfig config, DaoSession daoSession) { super(config, daoSession); } - /** - * Creates the underlying database table. - */ + /** Creates the underlying database table. */ public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists ? "IF NOT EXISTS ": ""; + String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"LABEL_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id "\"OBJECT_TYPE\" TEXT," + // 1: objectType @@ -376,7 +374,7 @@ if (remark != null) { stmt.bindString(26, remark); } - + String imagePath = entity.getImagePath(); if (imagePath != null) { stmt.bindString(27, imagePath); @@ -386,38 +384,38 @@ @Override public Long readKey(Cursor cursor, int offset) { return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } + } @Override public LabelBean readEntity(Cursor cursor, int offset) { LabelBean entity = new LabelBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // objectType - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // pipelineType - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // pipelineMaterial - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // pipelineDiameter - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // buryDeep - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // lowerType - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // lowerMaterial - cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // lowerDiameter - cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // lowerDeep - cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // buryMethod - cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // area - cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // line - cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13), // road - cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // constructTime - cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15), // owner - cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // objectId - cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17), // identifierId - cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18), // identifierType - cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // identifierDeep - cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20), // person - cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21), // installTime - cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22), // lng - cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23), // lat - cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24), // color - cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25), // remark - cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26) // imagePath + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // objectType + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // pipelineType + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // pipelineMaterial + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // pipelineDiameter + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // buryDeep + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // lowerType + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // lowerMaterial + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // lowerDiameter + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // lowerDeep + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // buryMethod + cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // area + cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // line + cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13), // road + cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // constructTime + cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15), // owner + cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // objectId + cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17), // identifierId + cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18), // identifierType + cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // identifierDeep + cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20), // person + cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21), // installTime + cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22), // lng + cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23), // lat + cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24), // color + cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25), // remark + cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26) // imagePath ); return entity; } @@ -451,17 +449,17 @@ entity.setColor(cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24)); entity.setRemark(cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25)); entity.setImagePath(cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26)); - } - + } + @Override protected final Long updateKeyAfterInsert(LabelBean entity, long rowId) { entity.setId(rowId); return rowId; } - + @Override public Long getKey(LabelBean entity) { - if (entity != null) { + if(entity != null) { return entity.getId(); } else { return null; diff --git a/app/src/main/java/com/casic/detector/greendao/SmallLabelBeanDao.java b/app/src/main/java/com/casic/detector/greendao/SmallLabelBeanDao.java index 622e9c2..925c804 100644 --- a/app/src/main/java/com/casic/detector/greendao/SmallLabelBeanDao.java +++ b/app/src/main/java/com/casic/detector/greendao/SmallLabelBeanDao.java @@ -12,9 +12,9 @@ import org.greenrobot.greendao.internal.DaoConfig; // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** +/** * DAO for table "SMALL_LABEL_BEAN". - */ +*/ public class SmallLabelBeanDao extends AbstractDao { public static final String TABLENAME = "SMALL_LABEL_BEAN"; @@ -51,16 +51,14 @@ public SmallLabelBeanDao(DaoConfig config) { super(config); } - + public SmallLabelBeanDao(DaoConfig config, DaoSession daoSession) { super(config, daoSession); } - /** - * Creates the underlying database table. - */ + /** Creates the underlying database table. */ public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists ? "IF NOT EXISTS ": ""; + String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"SMALL_LABEL_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id "\"MARKER_ID\" TEXT," + // 1: markerId @@ -304,7 +302,7 @@ if (memo2 != null) { stmt.bindString(20, memo2); } - + String memo3 = entity.getMemo3(); if (memo3 != null) { stmt.bindString(21, memo3); @@ -314,32 +312,32 @@ @Override public Long readKey(Cursor cursor, int offset) { return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } + } @Override public SmallLabelBean readEntity(Cursor cursor, int offset) { SmallLabelBean entity = new SmallLabelBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // markerId - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // locationNo - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // locationName - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // smallMarkerId - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // cableName - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // cableNo - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // line - cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // pressLevel - cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // cableType - cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // cableSpec - cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // cableBrand - cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // cableStart - cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13), // cableEnd - cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // hasJoint - cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15), // jointCreator - cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // createTime - cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17), // path - cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18), // memo1 - cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // memo2 - cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20) // memo3 + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // markerId + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // locationNo + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // locationName + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // smallMarkerId + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // cableName + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // cableNo + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // line + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // pressLevel + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // cableType + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // cableSpec + cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // cableBrand + cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // cableStart + cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13), // cableEnd + cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // hasJoint + cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15), // jointCreator + cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // createTime + cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17), // path + cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18), // memo1 + cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // memo2 + cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20) // memo3 ); return entity; } @@ -367,17 +365,17 @@ entity.setMemo1(cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18)); entity.setMemo2(cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19)); entity.setMemo3(cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20)); - } - + } + @Override protected final Long updateKeyAfterInsert(SmallLabelBean entity, long rowId) { entity.setId(rowId); return rowId; } - + @Override public Long getKey(SmallLabelBean entity) { - if (entity != null) { + if(entity != null) { return entity.getId(); } else { return null; diff --git a/app/src/main/java/com/casic/detector/extensions/ByteArray.kt b/app/src/main/java/com/casic/detector/extensions/ByteArray.kt new file mode 100644 index 0000000..8094b03 --- /dev/null +++ b/app/src/main/java/com/casic/detector/extensions/ByteArray.kt @@ -0,0 +1,15 @@ +package com.casic.detector.extensions + +/** + * ByteArray转Hex + * */ +fun ByteArray.toHex(): String { + val hexArray = "0123456789ABCDEF".toCharArray() + val hexChars = CharArray(this.size * 2) + for (j in this.indices) { + val v: Int = this[j].toInt() and 0xFF + hexChars[j * 2] = hexArray[v ushr 4] + hexChars[j * 2 + 1] = hexArray[v and 0x0F] + } + return String(hexChars) +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/detector/extensions/String.kt b/app/src/main/java/com/casic/detector/extensions/String.kt index aacd89d..84b3d2c 100644 --- a/app/src/main/java/com/casic/detector/extensions/String.kt +++ b/app/src/main/java/com/casic/detector/extensions/String.kt @@ -103,4 +103,21 @@ //根据控件名字取默认值 fun String.getDefaultValue(): String { return SaveKeyValues.getValue(this, "") as String +} + +fun String.hexToString(): String { + val sb = StringBuilder() + val temp: StringBuilder = StringBuilder() + run { + var i = 0 + while (i < this.length - 1) { + // 每两个Hex为一组 + val output = this.substring(i, i + 2) + val decimal = output.toInt(16) + sb.append(decimal.toChar()) + temp.append(decimal) + i += 2 + } + } + return sb.toString() } \ No newline at end of file diff --git a/app/src/main/java/com/casic/detector/greendao/DaoMaster.java b/app/src/main/java/com/casic/detector/greendao/DaoMaster.java index e344021..cab23bb 100644 --- a/app/src/main/java/com/casic/detector/greendao/DaoMaster.java +++ b/app/src/main/java/com/casic/detector/greendao/DaoMaster.java @@ -19,9 +19,7 @@ public class DaoMaster extends AbstractDaoMaster { public static final int SCHEMA_VERSION = 1; - /** - * Creates underlying database table using DAOs. - */ + /** Creates underlying database table using DAOs. */ public static void createAllTables(Database db, boolean ifNotExists) { LabelBeanDao.createTable(db, ifNotExists); SmallLabelBeanDao.createTable(db, ifNotExists); diff --git a/app/src/main/java/com/casic/detector/greendao/DaoSession.java b/app/src/main/java/com/casic/detector/greendao/DaoSession.java index d950876..6491987 100644 --- a/app/src/main/java/com/casic/detector/greendao/DaoSession.java +++ b/app/src/main/java/com/casic/detector/greendao/DaoSession.java @@ -16,7 +16,7 @@ /** * {@inheritDoc} - * + * * @see org.greenrobot.greendao.AbstractDaoSession */ public class DaoSession extends AbstractDaoSession { @@ -50,7 +50,7 @@ registerDao(SmallLabelBean.class, smallLabelBeanDao); registerDao(TaskBean.class, taskBeanDao); } - + public void clear() { labelBeanDaoConfig.clearIdentityScope(); smallLabelBeanDaoConfig.clearIdentityScope(); diff --git a/app/src/main/java/com/casic/detector/greendao/LabelBeanDao.java b/app/src/main/java/com/casic/detector/greendao/LabelBeanDao.java index 183a99e..99e1ff9 100644 --- a/app/src/main/java/com/casic/detector/greendao/LabelBeanDao.java +++ b/app/src/main/java/com/casic/detector/greendao/LabelBeanDao.java @@ -12,9 +12,9 @@ import org.greenrobot.greendao.internal.DaoConfig; // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** +/** * DAO for table "LABEL_BEAN". - */ +*/ public class LabelBeanDao extends AbstractDao { public static final String TABLENAME = "LABEL_BEAN"; @@ -57,16 +57,14 @@ public LabelBeanDao(DaoConfig config) { super(config); } - + public LabelBeanDao(DaoConfig config, DaoSession daoSession) { super(config, daoSession); } - /** - * Creates the underlying database table. - */ + /** Creates the underlying database table. */ public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists ? "IF NOT EXISTS ": ""; + String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"LABEL_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id "\"OBJECT_TYPE\" TEXT," + // 1: objectType @@ -376,7 +374,7 @@ if (remark != null) { stmt.bindString(26, remark); } - + String imagePath = entity.getImagePath(); if (imagePath != null) { stmt.bindString(27, imagePath); @@ -386,38 +384,38 @@ @Override public Long readKey(Cursor cursor, int offset) { return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } + } @Override public LabelBean readEntity(Cursor cursor, int offset) { LabelBean entity = new LabelBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // objectType - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // pipelineType - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // pipelineMaterial - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // pipelineDiameter - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // buryDeep - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // lowerType - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // lowerMaterial - cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // lowerDiameter - cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // lowerDeep - cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // buryMethod - cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // area - cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // line - cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13), // road - cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // constructTime - cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15), // owner - cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // objectId - cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17), // identifierId - cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18), // identifierType - cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // identifierDeep - cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20), // person - cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21), // installTime - cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22), // lng - cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23), // lat - cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24), // color - cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25), // remark - cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26) // imagePath + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // objectType + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // pipelineType + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // pipelineMaterial + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // pipelineDiameter + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // buryDeep + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // lowerType + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // lowerMaterial + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // lowerDiameter + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // lowerDeep + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // buryMethod + cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // area + cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // line + cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13), // road + cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // constructTime + cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15), // owner + cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // objectId + cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17), // identifierId + cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18), // identifierType + cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // identifierDeep + cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20), // person + cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21), // installTime + cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22), // lng + cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23), // lat + cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24), // color + cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25), // remark + cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26) // imagePath ); return entity; } @@ -451,17 +449,17 @@ entity.setColor(cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24)); entity.setRemark(cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25)); entity.setImagePath(cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26)); - } - + } + @Override protected final Long updateKeyAfterInsert(LabelBean entity, long rowId) { entity.setId(rowId); return rowId; } - + @Override public Long getKey(LabelBean entity) { - if (entity != null) { + if(entity != null) { return entity.getId(); } else { return null; diff --git a/app/src/main/java/com/casic/detector/greendao/SmallLabelBeanDao.java b/app/src/main/java/com/casic/detector/greendao/SmallLabelBeanDao.java index 622e9c2..925c804 100644 --- a/app/src/main/java/com/casic/detector/greendao/SmallLabelBeanDao.java +++ b/app/src/main/java/com/casic/detector/greendao/SmallLabelBeanDao.java @@ -12,9 +12,9 @@ import org.greenrobot.greendao.internal.DaoConfig; // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** +/** * DAO for table "SMALL_LABEL_BEAN". - */ +*/ public class SmallLabelBeanDao extends AbstractDao { public static final String TABLENAME = "SMALL_LABEL_BEAN"; @@ -51,16 +51,14 @@ public SmallLabelBeanDao(DaoConfig config) { super(config); } - + public SmallLabelBeanDao(DaoConfig config, DaoSession daoSession) { super(config, daoSession); } - /** - * Creates the underlying database table. - */ + /** Creates the underlying database table. */ public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists ? "IF NOT EXISTS ": ""; + String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"SMALL_LABEL_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id "\"MARKER_ID\" TEXT," + // 1: markerId @@ -304,7 +302,7 @@ if (memo2 != null) { stmt.bindString(20, memo2); } - + String memo3 = entity.getMemo3(); if (memo3 != null) { stmt.bindString(21, memo3); @@ -314,32 +312,32 @@ @Override public Long readKey(Cursor cursor, int offset) { return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } + } @Override public SmallLabelBean readEntity(Cursor cursor, int offset) { SmallLabelBean entity = new SmallLabelBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // markerId - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // locationNo - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // locationName - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // smallMarkerId - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // cableName - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // cableNo - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // line - cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // pressLevel - cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // cableType - cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // cableSpec - cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // cableBrand - cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // cableStart - cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13), // cableEnd - cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // hasJoint - cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15), // jointCreator - cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // createTime - cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17), // path - cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18), // memo1 - cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // memo2 - cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20) // memo3 + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // markerId + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // locationNo + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // locationName + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // smallMarkerId + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // cableName + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // cableNo + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // line + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // pressLevel + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // cableType + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // cableSpec + cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // cableBrand + cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // cableStart + cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13), // cableEnd + cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // hasJoint + cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15), // jointCreator + cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // createTime + cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17), // path + cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18), // memo1 + cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // memo2 + cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20) // memo3 ); return entity; } @@ -367,17 +365,17 @@ entity.setMemo1(cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18)); entity.setMemo2(cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19)); entity.setMemo3(cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20)); - } - + } + @Override protected final Long updateKeyAfterInsert(SmallLabelBean entity, long rowId) { entity.setId(rowId); return rowId; } - + @Override public Long getKey(SmallLabelBean entity) { - if (entity != null) { + if(entity != null) { return entity.getId(); } else { return null; diff --git a/app/src/main/java/com/casic/detector/greendao/TaskBeanDao.java b/app/src/main/java/com/casic/detector/greendao/TaskBeanDao.java index fb726e0..3f9d999 100644 --- a/app/src/main/java/com/casic/detector/greendao/TaskBeanDao.java +++ b/app/src/main/java/com/casic/detector/greendao/TaskBeanDao.java @@ -12,9 +12,9 @@ import org.greenrobot.greendao.internal.DaoConfig; // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** +/** * DAO for table "TASK_BEAN". - */ +*/ public class TaskBeanDao extends AbstractDao { public static final String TABLENAME = "TASK_BEAN"; @@ -40,16 +40,14 @@ public TaskBeanDao(DaoConfig config) { super(config); } - + public TaskBeanDao(DaoConfig config, DaoSession daoSession) { super(config, daoSession); } - /** - * Creates the underlying database table. - */ + /** Creates the underlying database table. */ public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists ? "IF NOT EXISTS ": ""; + String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"TASK_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id "\"SCANNER\" TEXT," + // 1: scanner @@ -172,7 +170,7 @@ if (lat != null) { stmt.bindString(9, lat); } - + String state = entity.getState(); if (state != null) { stmt.bindString(10, state); @@ -182,21 +180,21 @@ @Override public Long readKey(Cursor cursor, int offset) { return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } + } @Override public TaskBean readEntity(Cursor cursor, int offset) { TaskBean entity = new TaskBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // scanner - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // desc - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // taskId - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskCode - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // markerId - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // markerRealId - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // lng - cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // lat - cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9) // state + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // scanner + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // desc + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // taskId + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskCode + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // markerId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // markerRealId + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // lng + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // lat + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9) // state ); return entity; } @@ -213,17 +211,17 @@ entity.setLng(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); entity.setLat(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); entity.setState(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); - } - + } + @Override protected final Long updateKeyAfterInsert(TaskBean entity, long rowId) { entity.setId(rowId); return rowId; } - + @Override public Long getKey(TaskBean entity) { - if (entity != null) { + if(entity != null) { return entity.getId(); } else { return null; diff --git a/app/src/main/java/com/casic/detector/extensions/ByteArray.kt b/app/src/main/java/com/casic/detector/extensions/ByteArray.kt new file mode 100644 index 0000000..8094b03 --- /dev/null +++ b/app/src/main/java/com/casic/detector/extensions/ByteArray.kt @@ -0,0 +1,15 @@ +package com.casic.detector.extensions + +/** + * ByteArray转Hex + * */ +fun ByteArray.toHex(): String { + val hexArray = "0123456789ABCDEF".toCharArray() + val hexChars = CharArray(this.size * 2) + for (j in this.indices) { + val v: Int = this[j].toInt() and 0xFF + hexChars[j * 2] = hexArray[v ushr 4] + hexChars[j * 2 + 1] = hexArray[v and 0x0F] + } + return String(hexChars) +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/detector/extensions/String.kt b/app/src/main/java/com/casic/detector/extensions/String.kt index aacd89d..84b3d2c 100644 --- a/app/src/main/java/com/casic/detector/extensions/String.kt +++ b/app/src/main/java/com/casic/detector/extensions/String.kt @@ -103,4 +103,21 @@ //根据控件名字取默认值 fun String.getDefaultValue(): String { return SaveKeyValues.getValue(this, "") as String +} + +fun String.hexToString(): String { + val sb = StringBuilder() + val temp: StringBuilder = StringBuilder() + run { + var i = 0 + while (i < this.length - 1) { + // 每两个Hex为一组 + val output = this.substring(i, i + 2) + val decimal = output.toInt(16) + sb.append(decimal.toChar()) + temp.append(decimal) + i += 2 + } + } + return sb.toString() } \ No newline at end of file diff --git a/app/src/main/java/com/casic/detector/greendao/DaoMaster.java b/app/src/main/java/com/casic/detector/greendao/DaoMaster.java index e344021..cab23bb 100644 --- a/app/src/main/java/com/casic/detector/greendao/DaoMaster.java +++ b/app/src/main/java/com/casic/detector/greendao/DaoMaster.java @@ -19,9 +19,7 @@ public class DaoMaster extends AbstractDaoMaster { public static final int SCHEMA_VERSION = 1; - /** - * Creates underlying database table using DAOs. - */ + /** Creates underlying database table using DAOs. */ public static void createAllTables(Database db, boolean ifNotExists) { LabelBeanDao.createTable(db, ifNotExists); SmallLabelBeanDao.createTable(db, ifNotExists); diff --git a/app/src/main/java/com/casic/detector/greendao/DaoSession.java b/app/src/main/java/com/casic/detector/greendao/DaoSession.java index d950876..6491987 100644 --- a/app/src/main/java/com/casic/detector/greendao/DaoSession.java +++ b/app/src/main/java/com/casic/detector/greendao/DaoSession.java @@ -16,7 +16,7 @@ /** * {@inheritDoc} - * + * * @see org.greenrobot.greendao.AbstractDaoSession */ public class DaoSession extends AbstractDaoSession { @@ -50,7 +50,7 @@ registerDao(SmallLabelBean.class, smallLabelBeanDao); registerDao(TaskBean.class, taskBeanDao); } - + public void clear() { labelBeanDaoConfig.clearIdentityScope(); smallLabelBeanDaoConfig.clearIdentityScope(); diff --git a/app/src/main/java/com/casic/detector/greendao/LabelBeanDao.java b/app/src/main/java/com/casic/detector/greendao/LabelBeanDao.java index 183a99e..99e1ff9 100644 --- a/app/src/main/java/com/casic/detector/greendao/LabelBeanDao.java +++ b/app/src/main/java/com/casic/detector/greendao/LabelBeanDao.java @@ -12,9 +12,9 @@ import org.greenrobot.greendao.internal.DaoConfig; // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** +/** * DAO for table "LABEL_BEAN". - */ +*/ public class LabelBeanDao extends AbstractDao { public static final String TABLENAME = "LABEL_BEAN"; @@ -57,16 +57,14 @@ public LabelBeanDao(DaoConfig config) { super(config); } - + public LabelBeanDao(DaoConfig config, DaoSession daoSession) { super(config, daoSession); } - /** - * Creates the underlying database table. - */ + /** Creates the underlying database table. */ public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists ? "IF NOT EXISTS ": ""; + String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"LABEL_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id "\"OBJECT_TYPE\" TEXT," + // 1: objectType @@ -376,7 +374,7 @@ if (remark != null) { stmt.bindString(26, remark); } - + String imagePath = entity.getImagePath(); if (imagePath != null) { stmt.bindString(27, imagePath); @@ -386,38 +384,38 @@ @Override public Long readKey(Cursor cursor, int offset) { return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } + } @Override public LabelBean readEntity(Cursor cursor, int offset) { LabelBean entity = new LabelBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // objectType - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // pipelineType - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // pipelineMaterial - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // pipelineDiameter - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // buryDeep - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // lowerType - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // lowerMaterial - cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // lowerDiameter - cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // lowerDeep - cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // buryMethod - cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // area - cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // line - cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13), // road - cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // constructTime - cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15), // owner - cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // objectId - cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17), // identifierId - cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18), // identifierType - cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // identifierDeep - cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20), // person - cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21), // installTime - cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22), // lng - cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23), // lat - cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24), // color - cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25), // remark - cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26) // imagePath + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // objectType + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // pipelineType + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // pipelineMaterial + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // pipelineDiameter + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // buryDeep + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // lowerType + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // lowerMaterial + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // lowerDiameter + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // lowerDeep + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // buryMethod + cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // area + cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // line + cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13), // road + cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // constructTime + cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15), // owner + cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // objectId + cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17), // identifierId + cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18), // identifierType + cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // identifierDeep + cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20), // person + cursor.isNull(offset + 21) ? null : cursor.getString(offset + 21), // installTime + cursor.isNull(offset + 22) ? null : cursor.getString(offset + 22), // lng + cursor.isNull(offset + 23) ? null : cursor.getString(offset + 23), // lat + cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24), // color + cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25), // remark + cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26) // imagePath ); return entity; } @@ -451,17 +449,17 @@ entity.setColor(cursor.isNull(offset + 24) ? null : cursor.getString(offset + 24)); entity.setRemark(cursor.isNull(offset + 25) ? null : cursor.getString(offset + 25)); entity.setImagePath(cursor.isNull(offset + 26) ? null : cursor.getString(offset + 26)); - } - + } + @Override protected final Long updateKeyAfterInsert(LabelBean entity, long rowId) { entity.setId(rowId); return rowId; } - + @Override public Long getKey(LabelBean entity) { - if (entity != null) { + if(entity != null) { return entity.getId(); } else { return null; diff --git a/app/src/main/java/com/casic/detector/greendao/SmallLabelBeanDao.java b/app/src/main/java/com/casic/detector/greendao/SmallLabelBeanDao.java index 622e9c2..925c804 100644 --- a/app/src/main/java/com/casic/detector/greendao/SmallLabelBeanDao.java +++ b/app/src/main/java/com/casic/detector/greendao/SmallLabelBeanDao.java @@ -12,9 +12,9 @@ import org.greenrobot.greendao.internal.DaoConfig; // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** +/** * DAO for table "SMALL_LABEL_BEAN". - */ +*/ public class SmallLabelBeanDao extends AbstractDao { public static final String TABLENAME = "SMALL_LABEL_BEAN"; @@ -51,16 +51,14 @@ public SmallLabelBeanDao(DaoConfig config) { super(config); } - + public SmallLabelBeanDao(DaoConfig config, DaoSession daoSession) { super(config, daoSession); } - /** - * Creates the underlying database table. - */ + /** Creates the underlying database table. */ public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists ? "IF NOT EXISTS ": ""; + String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"SMALL_LABEL_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id "\"MARKER_ID\" TEXT," + // 1: markerId @@ -304,7 +302,7 @@ if (memo2 != null) { stmt.bindString(20, memo2); } - + String memo3 = entity.getMemo3(); if (memo3 != null) { stmt.bindString(21, memo3); @@ -314,32 +312,32 @@ @Override public Long readKey(Cursor cursor, int offset) { return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } + } @Override public SmallLabelBean readEntity(Cursor cursor, int offset) { SmallLabelBean entity = new SmallLabelBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // markerId - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // locationNo - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // locationName - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // smallMarkerId - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // cableName - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // cableNo - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // line - cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // pressLevel - cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // cableType - cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // cableSpec - cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // cableBrand - cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // cableStart - cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13), // cableEnd - cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // hasJoint - cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15), // jointCreator - cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // createTime - cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17), // path - cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18), // memo1 - cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // memo2 - cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20) // memo3 + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // markerId + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // locationNo + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // locationName + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // smallMarkerId + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // cableName + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // cableNo + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // line + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // pressLevel + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // cableType + cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // cableSpec + cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // cableBrand + cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // cableStart + cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13), // cableEnd + cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // hasJoint + cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15), // jointCreator + cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // createTime + cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17), // path + cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18), // memo1 + cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // memo2 + cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20) // memo3 ); return entity; } @@ -367,17 +365,17 @@ entity.setMemo1(cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18)); entity.setMemo2(cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19)); entity.setMemo3(cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20)); - } - + } + @Override protected final Long updateKeyAfterInsert(SmallLabelBean entity, long rowId) { entity.setId(rowId); return rowId; } - + @Override public Long getKey(SmallLabelBean entity) { - if (entity != null) { + if(entity != null) { return entity.getId(); } else { return null; diff --git a/app/src/main/java/com/casic/detector/greendao/TaskBeanDao.java b/app/src/main/java/com/casic/detector/greendao/TaskBeanDao.java index fb726e0..3f9d999 100644 --- a/app/src/main/java/com/casic/detector/greendao/TaskBeanDao.java +++ b/app/src/main/java/com/casic/detector/greendao/TaskBeanDao.java @@ -12,9 +12,9 @@ import org.greenrobot.greendao.internal.DaoConfig; // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** +/** * DAO for table "TASK_BEAN". - */ +*/ public class TaskBeanDao extends AbstractDao { public static final String TABLENAME = "TASK_BEAN"; @@ -40,16 +40,14 @@ public TaskBeanDao(DaoConfig config) { super(config); } - + public TaskBeanDao(DaoConfig config, DaoSession daoSession) { super(config, daoSession); } - /** - * Creates the underlying database table. - */ + /** Creates the underlying database table. */ public static void createTable(Database db, boolean ifNotExists) { - String constraint = ifNotExists ? "IF NOT EXISTS ": ""; + String constraint = ifNotExists? "IF NOT EXISTS ": ""; db.execSQL("CREATE TABLE " + constraint + "\"TASK_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id "\"SCANNER\" TEXT," + // 1: scanner @@ -172,7 +170,7 @@ if (lat != null) { stmt.bindString(9, lat); } - + String state = entity.getState(); if (state != null) { stmt.bindString(10, state); @@ -182,21 +180,21 @@ @Override public Long readKey(Cursor cursor, int offset) { return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } + } @Override public TaskBean readEntity(Cursor cursor, int offset) { TaskBean entity = new TaskBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // scanner - cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // desc - cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // taskId - cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskCode - cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // markerId - cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // markerRealId - cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // lng - cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // lat - cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9) // state + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // scanner + cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // desc + cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // taskId + cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskCode + cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // markerId + cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // markerRealId + cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // lng + cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // lat + cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9) // state ); return entity; } @@ -213,17 +211,17 @@ entity.setLng(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7)); entity.setLat(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8)); entity.setState(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9)); - } - + } + @Override protected final Long updateKeyAfterInsert(TaskBean entity, long rowId) { entity.setId(rowId); return rowId; } - + @Override public Long getKey(TaskBean entity) { - if (entity != null) { + if(entity != null) { return entity.getId(); } else { return null; diff --git a/app/src/main/java/com/casic/detector/view/InstallLabelActivity.kt b/app/src/main/java/com/casic/detector/view/InstallLabelActivity.kt index 09c5ae1..c6f6879 100644 --- a/app/src/main/java/com/casic/detector/view/InstallLabelActivity.kt +++ b/app/src/main/java/com/casic/detector/view/InstallLabelActivity.kt @@ -8,6 +8,7 @@ import android.media.SoundPool import android.os.Bundle import android.os.Handler +import android.os.Message import android.provider.Settings import android.util.Log import android.view.View @@ -30,6 +31,7 @@ import com.luck.picture.lib.interfaces.OnResultCallbackListener import com.pengxh.kt.lite.extensions.* import com.pengxh.kt.lite.utils.SaveKeyValues +import com.pengxh.kt.lite.utils.WeakReferenceHandler import com.pengxh.kt.lite.vm.LoadState import com.pengxh.kt.lite.widget.dialog.NoNetworkDialog import kotlinx.android.synthetic.main.activity_install_label.* @@ -42,7 +44,7 @@ import java.util.* @SuppressLint("SetTextI18n") -class InstallLabelActivity : SerialPortActivity() { +class InstallLabelActivity : SerialPortActivity(), Handler.Callback { private val kTag = "InstallLabelActivity" private val context: Context = this@InstallLabelActivity @@ -59,6 +61,7 @@ private lateinit var taskViewModel: TaskViewModel private lateinit var soundPool: SoundPool private val gpioManager by lazy { GpioManager() } + private lateinit var weakReferenceHandler: WeakReferenceHandler override fun initData(savedInstanceState: Bundle?) { imageAdapter = EditableImageAdapter(this, 3, 3f) @@ -79,6 +82,8 @@ identifierDeepView.setText("identifierDeepView".getDefaultValue()) personDeptView.setText("personDeptView".getDefaultValue()) + weakReferenceHandler = WeakReferenceHandler(this) + soundPool = SoundPool(10, AudioManager.STREAM_SYSTEM, 5) soundPool.load(this, R.raw.ring4, 1) } @@ -337,15 +342,16 @@ } } - //TODO 搜索标识器 readLabelButton.setOnClickListener { - reception = "0" gpioManager.setGpioHigh("18") + LoadingDialogHub.show(this, "标识器读取中,请稍后...") + // 1000ms后发送读标识器或搜索信号 - Handler().postDelayed({ // 发送读标识器或搜索信号 + weakReferenceHandler.postDelayed({ try { - outputStream?.write(0x02) + // 发送读标识器或搜索信号 + outputStream?.write("2".toByteArray()) outputStream?.flush() } catch (e: IOException) { e.printStackTrace() @@ -354,47 +360,41 @@ } } - private var reception = "" - - override fun onDataReceived(buffer: ByteArray?, size: Int) { + //[48, 48, 48, 56, 57, 56, 55, 53, 49, 52, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] Log.d(kTag, "onDataReceived => " + buffer.contentToString()) if (buffer != null) { - reception = String.format( - "%010d", hex2Str( - byte2hex(buffer).substring(6, 22) - ).toLong(16) - ) - Log.d(kTag, "onDataReceived => $reception") + val message = weakReferenceHandler.obtainMessage() + message.what = 2023061601 + message.obj = buffer + weakReferenceHandler.sendMessage(message) } } - private fun byte2hex(buffer: ByteArray): String { - var h = "" - for (i in buffer.indices) { - var temp = Integer.toHexString(buffer[i].toInt() and 0xFF) - if (temp.length == 1) { - temp = "0$temp" - } - h += temp - } - return h - } + override fun handleMessage(msg: Message): Boolean { + if (msg.what == 2023061601) { + val buffer = msg.obj as ByteArray + val hex = buffer.toHex() + //30303038393837353134000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 + if (hex.length >= 20) { + soundPool.play(1, 1f, 1f, 0, 0, 1f) - private fun hex2Str(hex: String): String { - val sb = StringBuilder() - val temp = StringBuilder() - run { - var i = 0 - while (i < hex.length - 1) { - val output = hex.substring(i, i + 2) - val decimal = output.toInt(16) - sb.append(decimal.toChar()) - temp.append(decimal) - i += 2 + val identifierId = hex.substring(0, 20).hexToString() + + gpioManager.setGpioLow("18") + + //查本地库 + val result = DataBaseManager.get.queryLabelById(identifierId) + if (result.isEmpty()) { + identifierIdView.text = identifierId + } else { + "此标识器已安装,请更换标识器!".show(this) + } + + LoadingDialogHub.dismiss() } } - return sb.toString() + return true } private fun takePicture() {