5 |
import java.util.Map; |
import java.util.Map; |
6 |
|
|
7 |
import android.content.Context; |
import android.content.Context; |
|
import android.util.Log; |
|
8 |
import android.view.LayoutInflater; |
import android.view.LayoutInflater; |
9 |
import android.view.View; |
import android.view.View; |
10 |
import android.view.ViewGroup; |
import android.view.ViewGroup; |
62 |
public View getView(int position, View convertView, ViewGroup parent) { |
public View getView(int position, View convertView, ViewGroup parent) { |
63 |
DepartureBean station = departures.get(position); |
DepartureBean station = departures.get(position); |
64 |
|
|
65 |
|
View root = inflater.inflate(R.layout.departurerow , parent, false); |
|
View root; |
|
|
if (convertView == null || convertView.getId() != R.id.DepartureRow ) { |
|
|
root = inflater.inflate(R.layout.departurerow , parent, false); |
|
|
} else { |
|
|
root = convertView; |
|
|
} |
|
|
|
|
66 |
|
|
67 |
((TextView) root.findViewById(R.id.Time)).setText(station.getTime()); |
((TextView) root.findViewById(R.id.Time)).setText(station.getTime()); |
68 |
((TextView) root.findViewById(R.id.Destination)).setText(station.getDestination()); |
((TextView) root.findViewById(R.id.Destination)).setText(station.getDestination()); |
70 |
if (station.getStatus().length() > 0 || station.getNote().length() > 0) { |
if (station.getStatus().length() > 0 || station.getNote().length() > 0) { |
71 |
ImageView image = (ImageView) root.findViewById(R.id.InfoIcon); |
ImageView image = (ImageView) root.findViewById(R.id.InfoIcon); |
72 |
|
|
73 |
|
String status = station.getStatus().toLowerCase(); |
74 |
|
String note = station.getNote().toLowerCase(); |
75 |
|
|
76 |
int iconID; |
int iconID; |
77 |
if (station.getStatus().toLowerCase().indexOf("aflyst") > -1 || |
if (status.indexOf("aflyst") > -1 || note.indexOf("aflyst") > -1 ) { |
|
station.getNote().toLowerCase().indexOf("aflyst") > -1 ) { |
|
78 |
iconID = R.drawable.warn20; |
iconID = R.drawable.warn20; |
79 |
|
} else if (note.indexOf("kører kun til") > -1 || note.indexOf("afgår fra") > -1) { //If these strings are present, the train only covers part of the line |
80 |
|
iconID = R.drawable.warnyellow20; |
81 |
} else { |
} else { |
82 |
iconID = R.drawable.info20; |
iconID = R.drawable.info20; |
83 |
} |
} |
108 |
imageMap.put("ør", R.drawable.or); //ØR = Øresundstog |
imageMap.put("ør", R.drawable.or); //ØR = Øresundstog |
109 |
imageMap.put("ec", R.drawable.ec); //EC = EuroCity |
imageMap.put("ec", R.drawable.ec); //EC = EuroCity |
110 |
imageMap.put("sj", R.drawable.sj); // SJ=Svenska Jernbaner |
imageMap.put("sj", R.drawable.sj); // SJ=Svenska Jernbaner |
111 |
|
imageMap.put("ie", R.drawable.ie); |
112 |
|
|
113 |
imageMap.put("a", R.drawable.stog_a); //S-Tog: A banen #00b5f1 |
imageMap.put("a", R.drawable.stog_a); //S-Tog: A banen #00b5f1 |
114 |
imageMap.put("b", R.drawable.stog_b); //S-Tog:B banen #5aba52 |
imageMap.put("b", R.drawable.stog_b); //S-Tog:B banen #5aba52 |