--- android/TrainInfo/src/dk/thoerup/traininfo/DepartureListAdapter.java 2010/09/16 15:32:42 1066 +++ android/TrainInfo/src/dk/thoerup/traininfo/DepartureListAdapter.java 2012/08/21 19:48:03 1835 @@ -15,6 +15,7 @@ public class DepartureListAdapter extends BaseAdapter { + boolean showDetails = false; private List departures; LayoutInflater inflater; Context context; @@ -28,8 +29,13 @@ super(); this.context = context; - inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + } + + public void toggleShowDetails() { + showDetails = !showDetails; + notifyDataSetChanged(); } public void setDepartures(List departures) { @@ -67,7 +73,7 @@ ((TextView) root.findViewById(R.id.Time)).setText(station.getTime()); ((TextView) root.findViewById(R.id.Destination)).setText(station.getDestination()); - + ((TextView) root.findViewById(R.id.Platform)).setText(station.getPlatform()); if ( (station.getStatus() != null && station.getStatus().length() > 0) || (station.getNote() != null && station.getNote().length() > 0) ) { ImageView image = (ImageView) root.findViewById(R.id.InfoIcon); @@ -90,8 +96,15 @@ ImageView typeIcon = (ImageView) root.findViewById(R.id.TypeIcon); String trainNumber = station.getTrainNumber().trim(); - String code = trainNumber.split(" ")[0].toLowerCase(); + String trainParts[] = trainNumber.split(" "); + String code = trainParts[0].toLowerCase(); + if (showDetails) { + root.findViewById(R.id.departureRow2).setVisibility( View.VISIBLE ); + ((TextView) root.findViewById(R.id.TrainNumber)).setText(trainNumber); + ((TextView) root.findViewById(R.id.Origin)).setText( station.getOrigin() ); + } + Integer imageId = imageMap.get(code); if (imageId != null) { typeIcon.setImageResource(imageId); @@ -102,16 +115,27 @@ return root; } + //TODO: all these traintypes / icons should be explained somewhere private static void buildImageMap() { - imageMap.put("ra", R.drawable.re); //RA = regionaltog arriva - imageMap.put("re", R.drawable.re); //RE = Regionaltog - imageMap.put("l", R.drawable.lyn); //L = Lyn + imageMap.put("ec", R.drawable.ec); //EC = EuroCity + // Missing FP ? imageMap.put("ic", R.drawable.ic); //IC = Intercity + imageMap.put("il", R.drawable.il); //IntercityLyn Nonstop + // Missing Int ? + // Missing IR ? + imageMap.put("l", R.drawable.lyn); //L = Lyn imageMap.put("pp", R.drawable.pp); //PP = Privatbaner (eg. odderbanen eller LokalBanen) + // Missing PX + imageMap.put("ra", R.drawable.re); //RA = regionaltog arriva + imageMap.put("re", R.drawable.re); //RE = Regionaltog imageMap.put("ør", R.drawable.or); //ØR = Øresundstog - imageMap.put("ec", R.drawable.ec); //EC = EuroCity - imageMap.put("sj", R.drawable.sj); // SJ=Svenska Jernbaner - imageMap.put("ie", R.drawable.ie); + + imageMap.put("sj", R.drawable.sj); //SJ=Svenska Jernbaner -- not mentioned on bane.dk + imageMap.put("ie", R.drawable.ie); //what's this ?? -- not mentioned on bane.dk + + //Missing IB ? -- not mentioned on bane.dk + //Missing RX ? -- not mentioned on bane.dk + imageMap.put("a", R.drawable.stog_a); //S-Tog: A banen #00b5f1 imageMap.put("b", R.drawable.stog_b); //S-Tog:B banen #5aba52