private void updateNodeOnDatabase(Node node) { String tableName; PointBean.Type type = node.point.getType(); if (type == PointBean.Type.MARK) { tableName = "mark"; } else if (type == PointBean.Type.XIANG_TI) { tableName = "xiangti"; } else if (type == PointBean.Type.GAN) { tableName = "gan"; } else if (type == PointBean.Type.JING) { tableName = "jing"; } else if (type == PointBean.Type.LU_PAI_HAO) { tableName = "lupaihao"; } else if (type == PointBean.Type.FANG_DA_JI_XIANG) { tableName = "fangdajixiang"; } else { Log.w(TAG, "无法为" + type.toString() + "对象更新数据库"); return; } SQLiteAction.storePoint(mSQLiteDatabase, tableName, node.point); }
private ArrayList<Node> createNodes() { ArrayList<Node> nodes = new ArrayList<>(); String[] tables = new String[] {"mark", "xiangti", "jing", "gan", "lupaihao", "fangdajixiang"}; for (String tableName : tables) { Cursor c = SQLiteAction.queryPoint(mSQLiteDatabase, tableName); if (c != null) { if (c.moveToFirst()) { for (int i = 0; i < c.getCount(); ++i) { c.moveToPosition(i); String synchronize = c.getString(c.getColumnIndex("synchronize")); if (synchronize != null && synchronize.equalsIgnoreCase("true")) { continue; } Node node = new Node(); node.id = mNodeCounter; mNodeCounter++; PointBean point = new PointBean(); point.setSynchronize(false); String id = c.getString(c.getColumnIndex("id")); if (id != null && !id.equalsIgnoreCase("")) { point.setId(id); } byte[] geometrys = c.getBlob(c.getColumnIndex("geometry")); if (geometrys != null && geometrys.length > 0) { Geometry geometry = GeometryEngine.geometryFromEsriShape(geometrys, Geometry.Type.POINT); point.setGeometry(geometry); } String name = c.getString(c.getColumnIndex("name")); if (name != null && !name.equalsIgnoreCase("")) { point.setName(name); } String typeString = c.getString(c.getColumnIndex("type")); if (typeString != null && !typeString.equalsIgnoreCase("")) { Integer index = Integer.parseInt(typeString); PointBean.Type type = PointBean.Type.values()[index]; point.setType(type); } String description = c.getString(c.getColumnIndex("description")); if (description != null && !description.equalsIgnoreCase("")) { point.setDescription(description); } String remark = c.getString(c.getColumnIndex("remark")); if (remark != null && !remark.equalsIgnoreCase("")) { point.setRemark(remark); } String imageId = c.getString(c.getColumnIndex("imageIds")); if (imageId != null && !imageId.equalsIgnoreCase("")) { String[] imageIds = imageId.split("#"); point.setImageIds(imageIds); } String creator = c.getString(c.getColumnIndex("creator")); if (creator != null && !creator.equalsIgnoreCase("")) { point.setCreator(creator); } String createTime = c.getString(c.getColumnIndex("createtime")); if (createTime != null && !createTime.equalsIgnoreCase("")) { point.setCreateTime(Long.parseLong(createTime)); } String lastEditor = c.getString(c.getColumnIndex("lasteditor")); if (lastEditor != null && !lastEditor.equalsIgnoreCase("")) { point.setLastEditor(lastEditor); } String modifyTime = c.getString(c.getColumnIndex("modifytime")); if (modifyTime != null && !modifyTime.equalsIgnoreCase("")) { point.setModifyTime(Long.parseLong(modifyTime)); } node.point = point; nodes.add(node); } } } } return nodes; }