private List<Floor> createAllFloorsFromExternalFile() throws IOException { List<Floor> result = new ArrayList<Floor>(); String fileName = "floors.csv"; InputStream is = context.getAssets().open(fileName); InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr); String readStr; br.readLine(); // 첫 줄 버림. while ((readStr = br.readLine()) != null) { String[] tokens = readStr.split(delimiter); Floor floor = new Floor(); floor.setId(Integer.parseInt(tokens[0])); floor.setName(tokens[1]); // tokens[2] : image file floor.setImageWidth(Integer.parseInt(tokens[3])); floor.setImageHeight(Integer.parseInt(tokens[4])); floor.setImageOriginX(Integer.parseInt(tokens[5])); floor.setImageOriginY(Integer.parseInt(tokens[6])); floor.setImageScale(Double.parseDouble(tokens[7])); floor.setZ(Double.parseDouble(tokens[8])); result.add(floor); } return result; }
@Override public void onClick(View v) { // TODO Auto-generated method stub if (v == addButton) { Intent intent = new Intent(selectBuildingActivity.this, createFloorDialog.class); startActivityForResult(intent, REQUEST_CREATE_FLOOR); } else { Tag t = (Tag) v.getTag(R.id.floorlistkey); switch (t.type) { case KEY_DELETE: try { svc.removeFloorById(FloorList.get(t.count).getId().intValue()); svc.updateIntoDB(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } FloorList.remove(t.count); adapter.notifyDataSetChanged(); break; case KEY_SELECT: Intent intent = new Intent(selectBuildingActivity.this, workMappingActivity.class); // Floor f = FloorList.get(t.count); intent.putExtra("img", f.getImage()); Log.e("fd", "aa" + f.getImage()); intent.putExtra("z", f.getZ()); intent.putExtra("scale", f.getImageScale()); // startActivity(intent); break; case KEY_COLLECT: Intent c_intent = new Intent(selectBuildingActivity.this, collectActivity.class); // Floor cf = FloorList.get(t.count); c_intent.putExtra("img", cf.getImage()); c_intent.putExtra("z", cf.getZ()); c_intent.putExtra("scale", cf.getImageScale()); // startActivity(c_intent); break; } } }
public void FloorInit() { id = 0; FloorList = new ArrayList<Floor>(); Floor[] floor_arr = null; try { Log.e("DB service", "Service : " + svc.toString()); Log.e("DB service", "callgetallfloor"); floor_arr = svc.getAllFloors(); Log.e("DB service", "Service : " + floor_arr); if (floor_arr == null) return; } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (floor_arr != null) { for (Floor f : floor_arr) { FloorList.add(f); Log.e("fd", f.toString()); id = f.getId().intValue(); } } }
@Override public View getView(int position, View convertView, ViewGroup parent) { View v = convertView; if (v == null) { LayoutInflater vi = ((Activity) context).getLayoutInflater(); v = vi.inflate(ResourceId, null); } Floor item = items.get(position); TextView name = (TextView) v.findViewById(R.id.adapterview_select_building_floor_list_title); name.setText(item.getName()); Button delete = (Button) v.findViewById(R.id.adapterview_select_building_floor_list_delete); delete.setTag(R.id.floorlistkey, new Tag(KEY_DELETE, position)); Button select = (Button) v.findViewById(R.id.adapterview_select_building_floor_list_select); select.setTag(R.id.floorlistkey, new Tag(KEY_SELECT, position)); Button collect = (Button) v.findViewById(R.id.adapterview_select_building_floor_list_collect); collect.setTag(R.id.floorlistkey, new Tag(KEY_COLLECT, position)); delete.setOnClickListener(l); collect.setOnClickListener(l); select.setOnClickListener(l); return v; }