private String setTime(TimeTable data) { // TODO Auto-generated method stub Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("Asia/Tokyo")); cal.setTimeInMillis(data.getStartDate()); String startTime = getTime(cal); cal.setTimeInMillis(data.getEndDate()); String endTime = getTime(cal); return startTime + "~" + endTime; }
private IndexAdapter addAdapter(String kindIndex) throws Exception { // TODO Auto-generated method stub IndexAdapter adapter; ArrayList<Index> indexList = new ArrayList<Index>(); // ChofufesData chofufesData = LoadJson.loadByJson(getAssets()); // Jsonを解析する ChofufesData chofufesData = null; try { chofufesData = LoadJson.loadByJson(this.Sjson); } catch (Exception e) { // TODO Auto-generated catch block Toast.makeText(this, "データを読み込めません", Toast.LENGTH_SHORT).show(); finish(); e.printStackTrace(); } // indexListに項目を追加する。IndexActivityから渡されたKINDの種類で判断して // どの項目を渡すのかを選択する if (kindIndex.equals(KIND.Roten.toString())) { ArrayList<Roten> rotenList = chofufesData.getRotenList(); /* Collections.sort(rotenList, new Comparator<Roten>(){ @Override public int compare(Roten arg0, Roten arg1) { // TODO Auto-generated method stub return arg0.getTitle().compareTo(arg1.getTitle()); } });*/ for (Roten roten : rotenList) { indexList.add(new Index(roten.getNumber() + "", roten.getTitle(), roten.getDescription())); } } else if (kindIndex.equals(KIND.Shitsunai.toString())) { ArrayList<Shitsunai> shitsunaiList = chofufesData.getShitsunaiList(); /* Collections.sort(shitsunaiList, new Comparator<Shitsunai>(){ @Override public int compare(Shitsunai arg0, Shitsunai arg1) { // TODO Auto-generated method stub return arg0.getTitle().compareTo(arg1.getTitle()); } });*/ for (Shitsunai shitsunai : shitsunaiList) { // String building = Building.getBuilding(shitsunai.getNumber() / 1000); String building = getResources().getStringArray(R.array.building_name)[shitsunai.getNumber() / 1000 - 1]; // int room = shitsunai.getNumber() % 1000; String room; int roomNumber = shitsunai.getNumber() % 1000; if (roomNumber == 0) { room = ""; } else { room = String.valueOf(roomNumber); } indexList.add(new Index(building + room, shitsunai.getTitle(), "")); } } else if (kindIndex.equals(KIND.TimeTable.toString())) { ArrayList<TimeTable> timeTableList = chofufesData.getAozoraList(); /* Collections.sort(timeTableList, new Comparator<TimeTable>(){ @Override public int compare(TimeTable arg0, TimeTable arg1) { // TODO Auto-generated method stub return arg0.getTitle().compareTo(arg1.getTitle()); } });*/ for (TimeTable timeTable : timeTableList) { String date = setTime(timeTable); String stage = getString(Stage.getStage(timeTable.getField())); indexList.add( new Index(date + "@" + stage, timeTable.getTitle(), timeTable.getDescription())); } } adapter = new IndexAdapter(this, 0, indexList); return adapter; }