diff --git a/app/src/main/java/com/casic/endoscope/adapter/CameraPointAdapter.kt b/app/src/main/java/com/casic/endoscope/adapter/CameraPointAdapter.kt index 1c41d5f..61f2f38 100644 --- a/app/src/main/java/com/casic/endoscope/adapter/CameraPointAdapter.kt +++ b/app/src/main/java/com/casic/endoscope/adapter/CameraPointAdapter.kt @@ -14,8 +14,7 @@ class CameraPointAdapter( private val context: Context, private val dataRows: MutableList -) : - RecyclerView.Adapter() { +) : RecyclerView.Adapter() { private var multipleSelected = mutableSetOf() private var selectedItems = ArrayList() @@ -33,11 +32,13 @@ this.dataRows.clear() this.dataRows.addAll(dataRows) notifyDataSetChanged() + multipleSelected.clear() + selectedItems.clear() } override fun onBindViewHolder(holder: ViewHolder, position: Int) { val item = dataRows[position] - holder.setText(R.id.stepNameView, "步骤 ${item.id}") + holder.setText(R.id.stepNameView, "步骤 ${item.step}") .setText(R.id.hAngleView, "水平角度 ${item.hAngle}") .setText(R.id.vAngleView, "垂直角度 ${item.vAngle}") diff --git a/app/src/main/java/com/casic/endoscope/adapter/CameraPointAdapter.kt b/app/src/main/java/com/casic/endoscope/adapter/CameraPointAdapter.kt index 1c41d5f..61f2f38 100644 --- a/app/src/main/java/com/casic/endoscope/adapter/CameraPointAdapter.kt +++ b/app/src/main/java/com/casic/endoscope/adapter/CameraPointAdapter.kt @@ -14,8 +14,7 @@ class CameraPointAdapter( private val context: Context, private val dataRows: MutableList -) : - RecyclerView.Adapter() { +) : RecyclerView.Adapter() { private var multipleSelected = mutableSetOf() private var selectedItems = ArrayList() @@ -33,11 +32,13 @@ this.dataRows.clear() this.dataRows.addAll(dataRows) notifyDataSetChanged() + multipleSelected.clear() + selectedItems.clear() } override fun onBindViewHolder(holder: ViewHolder, position: Int) { val item = dataRows[position] - holder.setText(R.id.stepNameView, "步骤 ${item.id}") + holder.setText(R.id.stepNameView, "步骤 ${item.step}") .setText(R.id.hAngleView, "水平角度 ${item.hAngle}") .setText(R.id.vAngleView, "垂直角度 ${item.vAngle}") diff --git a/app/src/main/java/com/casic/endoscope/bean/CameraPointBean.java b/app/src/main/java/com/casic/endoscope/bean/CameraPointBean.java index 009c2b8..3a20d82 100644 --- a/app/src/main/java/com/casic/endoscope/bean/CameraPointBean.java +++ b/app/src/main/java/com/casic/endoscope/bean/CameraPointBean.java @@ -13,12 +13,14 @@ @Id(autoincrement = true) private Long id;//主键自增 + private int step;//步骤序号 private int hAngle;//水平角度 private int vAngle;//垂直角度 - @Generated(hash = 1444859110) - public CameraPointBean(Long id, int hAngle, int vAngle) { + @Generated(hash = 1436018650) + public CameraPointBean(Long id, int step, int hAngle, int vAngle) { this.id = id; + this.step = step; this.hAngle = hAngle; this.vAngle = vAngle; } @@ -35,6 +37,14 @@ this.id = id; } + public int getStep() { + return this.step; + } + + public void setStep(int step) { + this.step = step; + } + public int getHAngle() { return this.hAngle; } diff --git a/app/src/main/java/com/casic/endoscope/adapter/CameraPointAdapter.kt b/app/src/main/java/com/casic/endoscope/adapter/CameraPointAdapter.kt index 1c41d5f..61f2f38 100644 --- a/app/src/main/java/com/casic/endoscope/adapter/CameraPointAdapter.kt +++ b/app/src/main/java/com/casic/endoscope/adapter/CameraPointAdapter.kt @@ -14,8 +14,7 @@ class CameraPointAdapter( private val context: Context, private val dataRows: MutableList -) : - RecyclerView.Adapter() { +) : RecyclerView.Adapter() { private var multipleSelected = mutableSetOf() private var selectedItems = ArrayList() @@ -33,11 +32,13 @@ this.dataRows.clear() this.dataRows.addAll(dataRows) notifyDataSetChanged() + multipleSelected.clear() + selectedItems.clear() } override fun onBindViewHolder(holder: ViewHolder, position: Int) { val item = dataRows[position] - holder.setText(R.id.stepNameView, "步骤 ${item.id}") + holder.setText(R.id.stepNameView, "步骤 ${item.step}") .setText(R.id.hAngleView, "水平角度 ${item.hAngle}") .setText(R.id.vAngleView, "垂直角度 ${item.vAngle}") diff --git a/app/src/main/java/com/casic/endoscope/bean/CameraPointBean.java b/app/src/main/java/com/casic/endoscope/bean/CameraPointBean.java index 009c2b8..3a20d82 100644 --- a/app/src/main/java/com/casic/endoscope/bean/CameraPointBean.java +++ b/app/src/main/java/com/casic/endoscope/bean/CameraPointBean.java @@ -13,12 +13,14 @@ @Id(autoincrement = true) private Long id;//主键自增 + private int step;//步骤序号 private int hAngle;//水平角度 private int vAngle;//垂直角度 - @Generated(hash = 1444859110) - public CameraPointBean(Long id, int hAngle, int vAngle) { + @Generated(hash = 1436018650) + public CameraPointBean(Long id, int step, int hAngle, int vAngle) { this.id = id; + this.step = step; this.hAngle = hAngle; this.vAngle = vAngle; } @@ -35,6 +37,14 @@ this.id = id; } + public int getStep() { + return this.step; + } + + public void setStep(int step) { + this.step = step; + } + public int getHAngle() { return this.hAngle; } diff --git a/app/src/main/java/com/casic/endoscope/greendao/CameraPointBeanDao.java b/app/src/main/java/com/casic/endoscope/greendao/CameraPointBeanDao.java index b445947..11bc932 100644 --- a/app/src/main/java/com/casic/endoscope/greendao/CameraPointBeanDao.java +++ b/app/src/main/java/com/casic/endoscope/greendao/CameraPointBeanDao.java @@ -12,9 +12,10 @@ import org.greenrobot.greendao.internal.DaoConfig; // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** + +/** * DAO for table "CAMERA_POINT_BEAN". -*/ + */ public class CameraPointBeanDao extends AbstractDao { public static final String TABLENAME = "CAMERA_POINT_BEAN"; @@ -25,29 +26,35 @@ */ public static class Properties { public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property HAngle = new Property(1, int.class, "hAngle", false, "H_ANGLE"); - public final static Property VAngle = new Property(2, int.class, "vAngle", false, "V_ANGLE"); + public final static Property Step = new Property(1, int.class, "step", false, "STEP"); + public final static Property HAngle = new Property(2, int.class, "hAngle", false, "H_ANGLE"); + public final static Property VAngle = new Property(3, int.class, "vAngle", false, "V_ANGLE"); } public CameraPointBeanDao(DaoConfig config) { super(config); } - + public CameraPointBeanDao(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 + "\"CAMERA_POINT_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"H_ANGLE\" INTEGER NOT NULL ," + // 1: hAngle - "\"V_ANGLE\" INTEGER NOT NULL );"); // 2: vAngle + "\"STEP\" INTEGER NOT NULL ," + // 1: step + "\"H_ANGLE\" INTEGER NOT NULL ," + // 2: hAngle + "\"V_ANGLE\" INTEGER NOT NULL );"); // 3: vAngle } - /** Drops the underlying database table. */ + /** + * Drops the underlying database table. + */ public static void dropTable(Database db, boolean ifExists) { String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"CAMERA_POINT_BEAN\""; db.execSQL(sql); @@ -56,58 +63,62 @@ @Override protected final void bindValues(DatabaseStatement stmt, CameraPointBean entity) { stmt.clearBindings(); - + Long id = entity.getId(); if (id != null) { stmt.bindLong(1, id); } - stmt.bindLong(2, entity.getHAngle()); - stmt.bindLong(3, entity.getVAngle()); + stmt.bindLong(2, entity.getStep()); + stmt.bindLong(3, entity.getHAngle()); + stmt.bindLong(4, entity.getVAngle()); } @Override protected final void bindValues(SQLiteStatement stmt, CameraPointBean entity) { stmt.clearBindings(); - + Long id = entity.getId(); if (id != null) { stmt.bindLong(1, id); } - stmt.bindLong(2, entity.getHAngle()); - stmt.bindLong(3, entity.getVAngle()); + stmt.bindLong(2, entity.getStep()); + stmt.bindLong(3, entity.getHAngle()); + stmt.bindLong(4, entity.getVAngle()); } @Override public Long readKey(Cursor cursor, int offset) { return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } + } @Override public CameraPointBean readEntity(Cursor cursor, int offset) { CameraPointBean entity = new CameraPointBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.getInt(offset + 1), // hAngle - cursor.getInt(offset + 2) // vAngle + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.getInt(offset + 1), // step + cursor.getInt(offset + 2), // hAngle + cursor.getInt(offset + 3) // vAngle ); return entity; } - + @Override public void readEntity(Cursor cursor, CameraPointBean entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setHAngle(cursor.getInt(offset + 1)); - entity.setVAngle(cursor.getInt(offset + 2)); - } - + entity.setStep(cursor.getInt(offset + 1)); + entity.setHAngle(cursor.getInt(offset + 2)); + entity.setVAngle(cursor.getInt(offset + 3)); + } + @Override protected final Long updateKeyAfterInsert(CameraPointBean entity, long rowId) { entity.setId(rowId); return rowId; } - + @Override public Long getKey(CameraPointBean entity) { - if(entity != null) { + if (entity != null) { return entity.getId(); } else { return null; @@ -123,5 +134,5 @@ protected final boolean isEntityUpdateable() { return true; } - + } diff --git a/app/src/main/java/com/casic/endoscope/adapter/CameraPointAdapter.kt b/app/src/main/java/com/casic/endoscope/adapter/CameraPointAdapter.kt index 1c41d5f..61f2f38 100644 --- a/app/src/main/java/com/casic/endoscope/adapter/CameraPointAdapter.kt +++ b/app/src/main/java/com/casic/endoscope/adapter/CameraPointAdapter.kt @@ -14,8 +14,7 @@ class CameraPointAdapter( private val context: Context, private val dataRows: MutableList -) : - RecyclerView.Adapter() { +) : RecyclerView.Adapter() { private var multipleSelected = mutableSetOf() private var selectedItems = ArrayList() @@ -33,11 +32,13 @@ this.dataRows.clear() this.dataRows.addAll(dataRows) notifyDataSetChanged() + multipleSelected.clear() + selectedItems.clear() } override fun onBindViewHolder(holder: ViewHolder, position: Int) { val item = dataRows[position] - holder.setText(R.id.stepNameView, "步骤 ${item.id}") + holder.setText(R.id.stepNameView, "步骤 ${item.step}") .setText(R.id.hAngleView, "水平角度 ${item.hAngle}") .setText(R.id.vAngleView, "垂直角度 ${item.vAngle}") diff --git a/app/src/main/java/com/casic/endoscope/bean/CameraPointBean.java b/app/src/main/java/com/casic/endoscope/bean/CameraPointBean.java index 009c2b8..3a20d82 100644 --- a/app/src/main/java/com/casic/endoscope/bean/CameraPointBean.java +++ b/app/src/main/java/com/casic/endoscope/bean/CameraPointBean.java @@ -13,12 +13,14 @@ @Id(autoincrement = true) private Long id;//主键自增 + private int step;//步骤序号 private int hAngle;//水平角度 private int vAngle;//垂直角度 - @Generated(hash = 1444859110) - public CameraPointBean(Long id, int hAngle, int vAngle) { + @Generated(hash = 1436018650) + public CameraPointBean(Long id, int step, int hAngle, int vAngle) { this.id = id; + this.step = step; this.hAngle = hAngle; this.vAngle = vAngle; } @@ -35,6 +37,14 @@ this.id = id; } + public int getStep() { + return this.step; + } + + public void setStep(int step) { + this.step = step; + } + public int getHAngle() { return this.hAngle; } diff --git a/app/src/main/java/com/casic/endoscope/greendao/CameraPointBeanDao.java b/app/src/main/java/com/casic/endoscope/greendao/CameraPointBeanDao.java index b445947..11bc932 100644 --- a/app/src/main/java/com/casic/endoscope/greendao/CameraPointBeanDao.java +++ b/app/src/main/java/com/casic/endoscope/greendao/CameraPointBeanDao.java @@ -12,9 +12,10 @@ import org.greenrobot.greendao.internal.DaoConfig; // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** + +/** * DAO for table "CAMERA_POINT_BEAN". -*/ + */ public class CameraPointBeanDao extends AbstractDao { public static final String TABLENAME = "CAMERA_POINT_BEAN"; @@ -25,29 +26,35 @@ */ public static class Properties { public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property HAngle = new Property(1, int.class, "hAngle", false, "H_ANGLE"); - public final static Property VAngle = new Property(2, int.class, "vAngle", false, "V_ANGLE"); + public final static Property Step = new Property(1, int.class, "step", false, "STEP"); + public final static Property HAngle = new Property(2, int.class, "hAngle", false, "H_ANGLE"); + public final static Property VAngle = new Property(3, int.class, "vAngle", false, "V_ANGLE"); } public CameraPointBeanDao(DaoConfig config) { super(config); } - + public CameraPointBeanDao(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 + "\"CAMERA_POINT_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"H_ANGLE\" INTEGER NOT NULL ," + // 1: hAngle - "\"V_ANGLE\" INTEGER NOT NULL );"); // 2: vAngle + "\"STEP\" INTEGER NOT NULL ," + // 1: step + "\"H_ANGLE\" INTEGER NOT NULL ," + // 2: hAngle + "\"V_ANGLE\" INTEGER NOT NULL );"); // 3: vAngle } - /** Drops the underlying database table. */ + /** + * Drops the underlying database table. + */ public static void dropTable(Database db, boolean ifExists) { String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"CAMERA_POINT_BEAN\""; db.execSQL(sql); @@ -56,58 +63,62 @@ @Override protected final void bindValues(DatabaseStatement stmt, CameraPointBean entity) { stmt.clearBindings(); - + Long id = entity.getId(); if (id != null) { stmt.bindLong(1, id); } - stmt.bindLong(2, entity.getHAngle()); - stmt.bindLong(3, entity.getVAngle()); + stmt.bindLong(2, entity.getStep()); + stmt.bindLong(3, entity.getHAngle()); + stmt.bindLong(4, entity.getVAngle()); } @Override protected final void bindValues(SQLiteStatement stmt, CameraPointBean entity) { stmt.clearBindings(); - + Long id = entity.getId(); if (id != null) { stmt.bindLong(1, id); } - stmt.bindLong(2, entity.getHAngle()); - stmt.bindLong(3, entity.getVAngle()); + stmt.bindLong(2, entity.getStep()); + stmt.bindLong(3, entity.getHAngle()); + stmt.bindLong(4, entity.getVAngle()); } @Override public Long readKey(Cursor cursor, int offset) { return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } + } @Override public CameraPointBean readEntity(Cursor cursor, int offset) { CameraPointBean entity = new CameraPointBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.getInt(offset + 1), // hAngle - cursor.getInt(offset + 2) // vAngle + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.getInt(offset + 1), // step + cursor.getInt(offset + 2), // hAngle + cursor.getInt(offset + 3) // vAngle ); return entity; } - + @Override public void readEntity(Cursor cursor, CameraPointBean entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setHAngle(cursor.getInt(offset + 1)); - entity.setVAngle(cursor.getInt(offset + 2)); - } - + entity.setStep(cursor.getInt(offset + 1)); + entity.setHAngle(cursor.getInt(offset + 2)); + entity.setVAngle(cursor.getInt(offset + 3)); + } + @Override protected final Long updateKeyAfterInsert(CameraPointBean entity, long rowId) { entity.setId(rowId); return rowId; } - + @Override public Long getKey(CameraPointBean entity) { - if(entity != null) { + if (entity != null) { return entity.getId(); } else { return null; @@ -123,5 +134,5 @@ protected final boolean isEntityUpdateable() { return true; } - + } diff --git a/app/src/main/java/com/casic/endoscope/utils/DataBaseManager.kt b/app/src/main/java/com/casic/endoscope/utils/DataBaseManager.kt index 18a424b..a593a5b 100644 --- a/app/src/main/java/com/casic/endoscope/utils/DataBaseManager.kt +++ b/app/src/main/java/com/casic/endoscope/utils/DataBaseManager.kt @@ -15,15 +15,18 @@ private var cameraPointDao = BaseApplication.get().getDaoSession().cameraPointBeanDao - fun cacheCameraPoint(h: Int, v: Int) { + fun cacheCameraPoint(step: Int, h: Int, v: Int) { val bean = CameraPointBean() + bean.step = step bean.hAngle = h bean.vAngle = v cameraPointDao.insert(bean) } - fun deleteCameraPoint(id: Long) { - cameraPointDao.delete(queryCameraPointById(id)) + fun deleteCameraPoints(beans: MutableList) { + beans.forEach { + cameraPointDao.delete(it) + } } fun deleteAllCameraPoint() { diff --git a/app/src/main/java/com/casic/endoscope/adapter/CameraPointAdapter.kt b/app/src/main/java/com/casic/endoscope/adapter/CameraPointAdapter.kt index 1c41d5f..61f2f38 100644 --- a/app/src/main/java/com/casic/endoscope/adapter/CameraPointAdapter.kt +++ b/app/src/main/java/com/casic/endoscope/adapter/CameraPointAdapter.kt @@ -14,8 +14,7 @@ class CameraPointAdapter( private val context: Context, private val dataRows: MutableList -) : - RecyclerView.Adapter() { +) : RecyclerView.Adapter() { private var multipleSelected = mutableSetOf() private var selectedItems = ArrayList() @@ -33,11 +32,13 @@ this.dataRows.clear() this.dataRows.addAll(dataRows) notifyDataSetChanged() + multipleSelected.clear() + selectedItems.clear() } override fun onBindViewHolder(holder: ViewHolder, position: Int) { val item = dataRows[position] - holder.setText(R.id.stepNameView, "步骤 ${item.id}") + holder.setText(R.id.stepNameView, "步骤 ${item.step}") .setText(R.id.hAngleView, "水平角度 ${item.hAngle}") .setText(R.id.vAngleView, "垂直角度 ${item.vAngle}") diff --git a/app/src/main/java/com/casic/endoscope/bean/CameraPointBean.java b/app/src/main/java/com/casic/endoscope/bean/CameraPointBean.java index 009c2b8..3a20d82 100644 --- a/app/src/main/java/com/casic/endoscope/bean/CameraPointBean.java +++ b/app/src/main/java/com/casic/endoscope/bean/CameraPointBean.java @@ -13,12 +13,14 @@ @Id(autoincrement = true) private Long id;//主键自增 + private int step;//步骤序号 private int hAngle;//水平角度 private int vAngle;//垂直角度 - @Generated(hash = 1444859110) - public CameraPointBean(Long id, int hAngle, int vAngle) { + @Generated(hash = 1436018650) + public CameraPointBean(Long id, int step, int hAngle, int vAngle) { this.id = id; + this.step = step; this.hAngle = hAngle; this.vAngle = vAngle; } @@ -35,6 +37,14 @@ this.id = id; } + public int getStep() { + return this.step; + } + + public void setStep(int step) { + this.step = step; + } + public int getHAngle() { return this.hAngle; } diff --git a/app/src/main/java/com/casic/endoscope/greendao/CameraPointBeanDao.java b/app/src/main/java/com/casic/endoscope/greendao/CameraPointBeanDao.java index b445947..11bc932 100644 --- a/app/src/main/java/com/casic/endoscope/greendao/CameraPointBeanDao.java +++ b/app/src/main/java/com/casic/endoscope/greendao/CameraPointBeanDao.java @@ -12,9 +12,10 @@ import org.greenrobot.greendao.internal.DaoConfig; // THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT. -/** + +/** * DAO for table "CAMERA_POINT_BEAN". -*/ + */ public class CameraPointBeanDao extends AbstractDao { public static final String TABLENAME = "CAMERA_POINT_BEAN"; @@ -25,29 +26,35 @@ */ public static class Properties { public final static Property Id = new Property(0, Long.class, "id", true, "_id"); - public final static Property HAngle = new Property(1, int.class, "hAngle", false, "H_ANGLE"); - public final static Property VAngle = new Property(2, int.class, "vAngle", false, "V_ANGLE"); + public final static Property Step = new Property(1, int.class, "step", false, "STEP"); + public final static Property HAngle = new Property(2, int.class, "hAngle", false, "H_ANGLE"); + public final static Property VAngle = new Property(3, int.class, "vAngle", false, "V_ANGLE"); } public CameraPointBeanDao(DaoConfig config) { super(config); } - + public CameraPointBeanDao(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 + "\"CAMERA_POINT_BEAN\" (" + // "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id - "\"H_ANGLE\" INTEGER NOT NULL ," + // 1: hAngle - "\"V_ANGLE\" INTEGER NOT NULL );"); // 2: vAngle + "\"STEP\" INTEGER NOT NULL ," + // 1: step + "\"H_ANGLE\" INTEGER NOT NULL ," + // 2: hAngle + "\"V_ANGLE\" INTEGER NOT NULL );"); // 3: vAngle } - /** Drops the underlying database table. */ + /** + * Drops the underlying database table. + */ public static void dropTable(Database db, boolean ifExists) { String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"CAMERA_POINT_BEAN\""; db.execSQL(sql); @@ -56,58 +63,62 @@ @Override protected final void bindValues(DatabaseStatement stmt, CameraPointBean entity) { stmt.clearBindings(); - + Long id = entity.getId(); if (id != null) { stmt.bindLong(1, id); } - stmt.bindLong(2, entity.getHAngle()); - stmt.bindLong(3, entity.getVAngle()); + stmt.bindLong(2, entity.getStep()); + stmt.bindLong(3, entity.getHAngle()); + stmt.bindLong(4, entity.getVAngle()); } @Override protected final void bindValues(SQLiteStatement stmt, CameraPointBean entity) { stmt.clearBindings(); - + Long id = entity.getId(); if (id != null) { stmt.bindLong(1, id); } - stmt.bindLong(2, entity.getHAngle()); - stmt.bindLong(3, entity.getVAngle()); + stmt.bindLong(2, entity.getStep()); + stmt.bindLong(3, entity.getHAngle()); + stmt.bindLong(4, entity.getVAngle()); } @Override public Long readKey(Cursor cursor, int offset) { return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0); - } + } @Override public CameraPointBean readEntity(Cursor cursor, int offset) { CameraPointBean entity = new CameraPointBean( // - cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id - cursor.getInt(offset + 1), // hAngle - cursor.getInt(offset + 2) // vAngle + cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id + cursor.getInt(offset + 1), // step + cursor.getInt(offset + 2), // hAngle + cursor.getInt(offset + 3) // vAngle ); return entity; } - + @Override public void readEntity(Cursor cursor, CameraPointBean entity, int offset) { entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0)); - entity.setHAngle(cursor.getInt(offset + 1)); - entity.setVAngle(cursor.getInt(offset + 2)); - } - + entity.setStep(cursor.getInt(offset + 1)); + entity.setHAngle(cursor.getInt(offset + 2)); + entity.setVAngle(cursor.getInt(offset + 3)); + } + @Override protected final Long updateKeyAfterInsert(CameraPointBean entity, long rowId) { entity.setId(rowId); return rowId; } - + @Override public Long getKey(CameraPointBean entity) { - if(entity != null) { + if (entity != null) { return entity.getId(); } else { return null; @@ -123,5 +134,5 @@ protected final boolean isEntityUpdateable() { return true; } - + } diff --git a/app/src/main/java/com/casic/endoscope/utils/DataBaseManager.kt b/app/src/main/java/com/casic/endoscope/utils/DataBaseManager.kt index 18a424b..a593a5b 100644 --- a/app/src/main/java/com/casic/endoscope/utils/DataBaseManager.kt +++ b/app/src/main/java/com/casic/endoscope/utils/DataBaseManager.kt @@ -15,15 +15,18 @@ private var cameraPointDao = BaseApplication.get().getDaoSession().cameraPointBeanDao - fun cacheCameraPoint(h: Int, v: Int) { + fun cacheCameraPoint(step: Int, h: Int, v: Int) { val bean = CameraPointBean() + bean.step = step bean.hAngle = h bean.vAngle = v cameraPointDao.insert(bean) } - fun deleteCameraPoint(id: Long) { - cameraPointDao.delete(queryCameraPointById(id)) + fun deleteCameraPoints(beans: MutableList) { + beans.forEach { + cameraPointDao.delete(it) + } } fun deleteAllCameraPoint() { diff --git a/app/src/main/java/com/casic/endoscope/view/MainActivity.kt b/app/src/main/java/com/casic/endoscope/view/MainActivity.kt index 9fa8cf7..99f1691 100644 --- a/app/src/main/java/com/casic/endoscope/view/MainActivity.kt +++ b/app/src/main/java/com/casic/endoscope/view/MainActivity.kt @@ -68,10 +68,11 @@ private var timer: Timer? = null private var timerTask: TimerTask? = null private var seconds = 0L + private var step = 1 private var dataBeans: MutableList = ArrayList() + private var selectedItems: MutableList = ArrayList() private lateinit var weakReferenceHandler: WeakReferenceHandler private lateinit var dataAdapter: CameraPointAdapter - private var selectedItems: MutableList = ArrayList() override fun initViewBinding(): ActivityMainBinding { return ActivityMainBinding.inflate(layoutInflater) @@ -144,14 +145,23 @@ } binding.addButton.setOnClickListener { - DataBaseManager.get.cacheCameraPoint(0, 0) + DataBaseManager.get.cacheCameraPoint(step++, 0, 0) dataBeans = DataBaseManager.get.loadAllCameraPoint() dataAdapter.setRefreshData(dataBeans) } binding.deleteButton.setOnClickListener { - selectedItems.forEach { - Log.d(kTag, "initEvent => ${it.id}") + if (selectedItems.isEmpty()) { + "请先选择要删除的步骤".show(this) + return@setOnClickListener + } + DataBaseManager.get.deleteCameraPoints(selectedItems) + dataBeans = DataBaseManager.get.loadAllCameraPoint() + dataAdapter.setRefreshData(dataBeans) + selectedItems.clear() + if (dataBeans.isEmpty()) { + //步骤清空后,重置步骤序号 + step = 1 } }