Departure listing adapts to screen size

This commit is contained in:
Doug Keen 2013-03-25 12:48:46 -07:00
parent fcc9f2ba21
commit b652b491bd
5 changed files with 139 additions and 40 deletions

View File

@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<size android:height="45dp" android:width="15dp" />
android:shape="rectangle" >
<size android:width="15dp" />
</shape>

View File

@ -0,0 +1,76 @@
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:bart="http://schemas.android.com/apk/res/com.dougkeen.bart"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="@+id/destinationColorBar"
android:layout_width="wrap_content"
android:layout_height="64dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:src="@drawable/basic_rectangle" />
<LinearLayout
android:id="@+id/topRow"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="@id/destinationColorBar" >
<TextView
android:id="@+id/destinationText"
style="@style/DepartureDestinationText"
android:layout_weight="1"
android:ellipsize="marquee"
android:singleLine="true" />
<ImageView
android:id="@+id/bikeIcon"
style="@style/BikeIcon" />
<com.dougkeen.bart.controls.CountdownTextView
android:id="@+id/countdown"
style="@style/DepartureCountdownText"
android:gravity="right"
android:width="90dp"
bart:tickInterval="1" />
</LinearLayout>
<ImageView
android:id="@+id/xferIcon"
style="@style/XferIcon"
android:layout_alignParentRight="true"
android:layout_below="@id/topRow"
android:src="@drawable/xfer" />
<TextView
android:id="@+id/trainLengthText"
style="@style/DepartureUncertaintyText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/topRow"
android:layout_toRightOf="@id/destinationColorBar" />
<TextView
android:id="@+id/uncertainty"
style="@style/DepartureUncertaintyText"
android:layout_alignParentRight="true"
android:layout_below="@id/topRow" />
<TextView
android:id="@+id/estimatedArrival"
style="@style/DepartureUncertaintyText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/trainLengthText"
android:layout_toRightOf="@id/destinationColorBar" />
<TextView
android:id="@+id/departureTime"
style="@style/DepartureUncertaintyText"
android:layout_alignParentRight="true"
android:layout_below="@id/uncertainty" />
</merge>

View File

@ -7,7 +7,7 @@
<ImageView
android:id="@+id/destinationColorBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_height="45dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:src="@drawable/basic_rectangle" />

View File

@ -28,7 +28,7 @@
<ImageView
android:id="@+id/yourTrainDestinationColorBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_height="45dp"
android:layout_alignParentLeft="true"
android:layout_below="@id/yourTrainHeader"
android:src="@drawable/basic_rectangle" />

View File

@ -89,14 +89,24 @@ public class DepartureArrayAdapter extends ArrayAdapter<Departure> {
((TextView) view.findViewById(R.id.destinationText)).setText(departure
.getTrainDestination().toString());
TimedTextSwitcher textSwitcher = (TimedTextSwitcher) view
.findViewById(R.id.trainLengthText);
initTextSwitcher(textSwitcher, R.layout.train_length_arrival_textview);
final String arrivesAtDestinationPrefix = getContext().getString(
R.string.arrives_at_destination);
final String estimatedArrivalTimeText = departure
.getEstimatedArrivalTimeText(getContext());
TextView estimatedArrival = (TextView) view
.findViewById(R.id.estimatedArrival);
if (estimatedArrival != null) {
((TextView) view.findViewById(R.id.trainLengthText))
.setText(departure.getTrainLengthText());
estimatedArrival.setText(arrivesAtDestinationPrefix
+ estimatedArrivalTimeText);
} else {
TimedTextSwitcher textSwitcher = (TimedTextSwitcher) view
.findViewById(R.id.trainLengthText);
initTextSwitcher(textSwitcher,
R.layout.train_length_arrival_textview);
if (!StringUtils.isBlank(estimatedArrivalTimeText)) {
textSwitcher.setCurrentText(arrivesAtDestinationPrefix
+ estimatedArrivalTimeText);
@ -120,6 +130,7 @@ public class DepartureArrayAdapter extends ArrayAdapter<Departure> {
}
}
});
}
ImageView colorBar = (ImageView) view
.findViewById(R.id.destinationColorBar);
@ -135,6 +146,15 @@ public class DepartureArrayAdapter extends ArrayAdapter<Departure> {
}
});
TextView departureTime = (TextView) view
.findViewById(R.id.departureTime);
if (departureTime != null) {
((TextView) view.findViewById(R.id.uncertainty)).setText(departure
.getUncertaintyText());
departureTime.setText(departure
.getEstimatedDepartureTimeText(getContext()));
} else {
TimedTextSwitcher uncertaintySwitcher = (TimedTextSwitcher) view
.findViewById(R.id.uncertainty);
initTextSwitcher(uncertaintySwitcher, R.layout.uncertainty_textview);
@ -150,6 +170,7 @@ public class DepartureArrayAdapter extends ArrayAdapter<Departure> {
}
}
});
}
ImageView bikeIcon = (ImageView) view.findViewById(R.id.bikeIcon);
if (departure.isBikeAllowed()) {