Departure listing adapts to screen size
This commit is contained in:
parent
fcc9f2ba21
commit
b652b491bd
@ -1,5 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:shape="rectangle">
|
android:shape="rectangle" >
|
||||||
<size android:height="45dp" android:width="15dp" />
|
|
||||||
|
<size android:width="15dp" />
|
||||||
|
|
||||||
</shape>
|
</shape>
|
76
res/layout-h480dp/departure_listing.xml
Normal file
76
res/layout-h480dp/departure_listing.xml
Normal 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>
|
@ -7,7 +7,7 @@
|
|||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/destinationColorBar"
|
android:id="@+id/destinationColorBar"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="45dp"
|
||||||
android:layout_alignParentLeft="true"
|
android:layout_alignParentLeft="true"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:src="@drawable/basic_rectangle" />
|
android:src="@drawable/basic_rectangle" />
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/yourTrainDestinationColorBar"
|
android:id="@+id/yourTrainDestinationColorBar"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="45dp"
|
||||||
android:layout_alignParentLeft="true"
|
android:layout_alignParentLeft="true"
|
||||||
android:layout_below="@id/yourTrainHeader"
|
android:layout_below="@id/yourTrainHeader"
|
||||||
android:src="@drawable/basic_rectangle" />
|
android:src="@drawable/basic_rectangle" />
|
||||||
|
@ -89,37 +89,48 @@ public class DepartureArrayAdapter extends ArrayAdapter<Departure> {
|
|||||||
((TextView) view.findViewById(R.id.destinationText)).setText(departure
|
((TextView) view.findViewById(R.id.destinationText)).setText(departure
|
||||||
.getTrainDestination().toString());
|
.getTrainDestination().toString());
|
||||||
|
|
||||||
TimedTextSwitcher textSwitcher = (TimedTextSwitcher) view
|
|
||||||
.findViewById(R.id.trainLengthText);
|
|
||||||
initTextSwitcher(textSwitcher, R.layout.train_length_arrival_textview);
|
|
||||||
|
|
||||||
final String arrivesAtDestinationPrefix = getContext().getString(
|
final String arrivesAtDestinationPrefix = getContext().getString(
|
||||||
R.string.arrives_at_destination);
|
R.string.arrives_at_destination);
|
||||||
final String estimatedArrivalTimeText = departure
|
final String estimatedArrivalTimeText = departure
|
||||||
.getEstimatedArrivalTimeText(getContext());
|
.getEstimatedArrivalTimeText(getContext());
|
||||||
if (!StringUtils.isBlank(estimatedArrivalTimeText)) {
|
|
||||||
textSwitcher.setCurrentText(arrivesAtDestinationPrefix
|
TextView estimatedArrival = (TextView) view
|
||||||
|
.findViewById(R.id.estimatedArrival);
|
||||||
|
if (estimatedArrival != null) {
|
||||||
|
((TextView) view.findViewById(R.id.trainLengthText))
|
||||||
|
.setText(departure.getTrainLengthText());
|
||||||
|
estimatedArrival.setText(arrivesAtDestinationPrefix
|
||||||
+ estimatedArrivalTimeText);
|
+ estimatedArrivalTimeText);
|
||||||
} else {
|
} else {
|
||||||
textSwitcher.setCurrentText(departure.getTrainLengthText());
|
TimedTextSwitcher textSwitcher = (TimedTextSwitcher) view
|
||||||
}
|
.findViewById(R.id.trainLengthText);
|
||||||
textSwitcher.setTextProvider(new TextProvider() {
|
initTextSwitcher(textSwitcher,
|
||||||
@Override
|
R.layout.train_length_arrival_textview);
|
||||||
public String getText(long tickNumber) {
|
|
||||||
if (tickNumber % 4 == 0) {
|
if (!StringUtils.isBlank(estimatedArrivalTimeText)) {
|
||||||
return departure.getTrainLengthText();
|
textSwitcher.setCurrentText(arrivesAtDestinationPrefix
|
||||||
} else {
|
+ estimatedArrivalTimeText);
|
||||||
final String estimatedArrivalTimeText = departure
|
} else {
|
||||||
.getEstimatedArrivalTimeText(getContext());
|
textSwitcher.setCurrentText(departure.getTrainLengthText());
|
||||||
if (StringUtils.isBlank(estimatedArrivalTimeText)) {
|
}
|
||||||
return "";
|
textSwitcher.setTextProvider(new TextProvider() {
|
||||||
|
@Override
|
||||||
|
public String getText(long tickNumber) {
|
||||||
|
if (tickNumber % 4 == 0) {
|
||||||
|
return departure.getTrainLengthText();
|
||||||
} else {
|
} else {
|
||||||
return arrivesAtDestinationPrefix
|
final String estimatedArrivalTimeText = departure
|
||||||
+ estimatedArrivalTimeText;
|
.getEstimatedArrivalTimeText(getContext());
|
||||||
|
if (StringUtils.isBlank(estimatedArrivalTimeText)) {
|
||||||
|
return "";
|
||||||
|
} else {
|
||||||
|
return arrivesAtDestinationPrefix
|
||||||
|
+ estimatedArrivalTimeText;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
|
|
||||||
ImageView colorBar = (ImageView) view
|
ImageView colorBar = (ImageView) view
|
||||||
.findViewById(R.id.destinationColorBar);
|
.findViewById(R.id.destinationColorBar);
|
||||||
@ -135,22 +146,32 @@ public class DepartureArrayAdapter extends ArrayAdapter<Departure> {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
TimedTextSwitcher uncertaintySwitcher = (TimedTextSwitcher) view
|
TextView departureTime = (TextView) view
|
||||||
.findViewById(R.id.uncertainty);
|
.findViewById(R.id.departureTime);
|
||||||
initTextSwitcher(uncertaintySwitcher, R.layout.uncertainty_textview);
|
|
||||||
|
|
||||||
uncertaintySwitcher.setTextProvider(new TextProvider() {
|
if (departureTime != null) {
|
||||||
@Override
|
((TextView) view.findViewById(R.id.uncertainty)).setText(departure
|
||||||
public String getText(long tickNumber) {
|
.getUncertaintyText());
|
||||||
if (tickNumber % 4 == 0) {
|
departureTime.setText(departure
|
||||||
return departure.getUncertaintyText();
|
.getEstimatedDepartureTimeText(getContext()));
|
||||||
} else {
|
} else {
|
||||||
return departure
|
TimedTextSwitcher uncertaintySwitcher = (TimedTextSwitcher) view
|
||||||
.getEstimatedDepartureTimeText(getContext());
|
.findViewById(R.id.uncertainty);
|
||||||
|
initTextSwitcher(uncertaintySwitcher, R.layout.uncertainty_textview);
|
||||||
|
|
||||||
|
uncertaintySwitcher.setTextProvider(new TextProvider() {
|
||||||
|
@Override
|
||||||
|
public String getText(long tickNumber) {
|
||||||
|
if (tickNumber % 4 == 0) {
|
||||||
|
return departure.getUncertaintyText();
|
||||||
|
} else {
|
||||||
|
return departure
|
||||||
|
.getEstimatedDepartureTimeText(getContext());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
|
|
||||||
ImageView bikeIcon = (ImageView) view.findViewById(R.id.bikeIcon);
|
ImageView bikeIcon = (ImageView) view.findViewById(R.id.bikeIcon);
|
||||||
if (departure.isBikeAllowed()) {
|
if (departure.isBikeAllowed()) {
|
||||||
bikeIcon.setImageDrawable(bikeDrawable);
|
bikeIcon.setImageDrawable(bikeDrawable);
|
||||||
|
Loading…
Reference in New Issue
Block a user