--- android/TrainInfo/src/dk/thoerup/traininfo/DepartureListAdapter.java 2011/05/03 12:38:04 1433 +++ android/TrainInfo/src/dk/thoerup/traininfo/DepartureListAdapter.java 2011/05/03 16:28:56 1434 @@ -15,6 +15,7 @@ public class DepartureListAdapter extends BaseAdapter { + boolean showDetails = false; private List departures; LayoutInflater inflater; Context context; @@ -28,8 +29,20 @@ super(); this.context = context; - inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - + inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + } + + public void setShowDetails(boolean showDetails) { + this.showDetails = showDetails; + } + + public boolean getShowDetails() { + return showDetails; + } + + public void toggleShowDetails() { + showDetails = !showDetails; + notifyDataSetChanged(); } public void setDepartures(List departures) { @@ -90,8 +103,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,6 +122,7 @@ 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 @@ -112,6 +133,7 @@ imageMap.put("ec", R.drawable.ec); //EC = EuroCity imageMap.put("sj", R.drawable.sj); // SJ=Svenska Jernbaner imageMap.put("ie", R.drawable.ie); + //TODO: missing IL: IntercityLyn Nonstop imageMap.put("a", R.drawable.stog_a); //S-Tog: A banen #00b5f1 imageMap.put("b", R.drawable.stog_b); //S-Tog:B banen #5aba52