Added departure clock time
This commit is contained in:
parent
7411c0ea12
commit
357fd69506
@ -54,10 +54,11 @@
|
|||||||
android:layout_toRightOf="@id/destinationColorBar"
|
android:layout_toRightOf="@id/destinationColorBar"
|
||||||
bart:tickInterval="1" />
|
bart:tickInterval="1" />
|
||||||
|
|
||||||
<TextView
|
<com.dougkeen.bart.controls.TimedTextSwitcher
|
||||||
android:id="@+id/uncertainty"
|
android:id="@+id/uncertainty"
|
||||||
style="@style/DepartureUncertaintyText"
|
style="@style/DepartureUncertaintyText"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
android:layout_below="@id/topRow" />
|
android:layout_below="@id/topRow"
|
||||||
|
bart:tickInterval="1" />
|
||||||
|
|
||||||
</merge>
|
</merge>
|
@ -82,10 +82,11 @@
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="DepartureUncertaintyText">
|
<style name="DepartureUncertaintyText">
|
||||||
<item name="android:layout_width">wrap_content</item>
|
<item name="android:layout_width">80dp</item>
|
||||||
<item name="android:layout_height">wrap_content</item>
|
<item name="android:layout_height">wrap_content</item>
|
||||||
<item name="android:textSize">16dp</item>
|
<item name="android:textSize">16dp</item>
|
||||||
<item name="android:singleLine">true</item>
|
<item name="android:singleLine">true</item>
|
||||||
|
<item name="android:gravity">right</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="MissingDepartureText">
|
<style name="MissingDepartureText">
|
||||||
|
@ -75,7 +75,7 @@ public class DepartureArrayAdapter extends ArrayAdapter<Departure> {
|
|||||||
|
|
||||||
TimedTextSwitcher textSwitcher = (TimedTextSwitcher) view
|
TimedTextSwitcher textSwitcher = (TimedTextSwitcher) view
|
||||||
.findViewById(R.id.trainLengthText);
|
.findViewById(R.id.trainLengthText);
|
||||||
initTextSwitcher(textSwitcher);
|
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);
|
||||||
@ -118,8 +118,23 @@ public class DepartureArrayAdapter extends ArrayAdapter<Departure> {
|
|||||||
return departure.getCountdownText();
|
return departure.getCountdownText();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
((TextView) view.findViewById(R.id.uncertainty)).setText(departure
|
|
||||||
.getUncertaintyText());
|
TimedTextSwitcher uncertaintySwitcher = (TimedTextSwitcher) view
|
||||||
|
.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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if (departure.isBikeAllowed()) {
|
if (departure.isBikeAllowed()) {
|
||||||
((ImageView) view.findViewById(R.id.bikeIcon))
|
((ImageView) view.findViewById(R.id.bikeIcon))
|
||||||
.setVisibility(View.VISIBLE);
|
.setVisibility(View.VISIBLE);
|
||||||
@ -138,12 +153,13 @@ public class DepartureArrayAdapter extends ArrayAdapter<Departure> {
|
|||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initTextSwitcher(TextSwitcher textSwitcher) {
|
private void initTextSwitcher(TextSwitcher textSwitcher,
|
||||||
|
final int layoutView) {
|
||||||
if (textSwitcher.getInAnimation() == null) {
|
if (textSwitcher.getInAnimation() == null) {
|
||||||
textSwitcher.setFactory(new ViewFactory() {
|
textSwitcher.setFactory(new ViewFactory() {
|
||||||
public View makeView() {
|
public View makeView() {
|
||||||
return LayoutInflater.from(getContext()).inflate(
|
return LayoutInflater.from(getContext()).inflate(
|
||||||
R.layout.train_length_arrival_textview, null);
|
layoutView, null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -196,8 +196,11 @@ public class FavoritesArrayAdapter extends ArrayAdapter<StationPair> {
|
|||||||
uncertaintyTextSwitcher.setTextProvider(new TextProvider() {
|
uncertaintyTextSwitcher.setTextProvider(new TextProvider() {
|
||||||
@Override
|
@Override
|
||||||
public String getText(long tickNumber) {
|
public String getText(long tickNumber) {
|
||||||
if (tickNumber % 4 <= 1) {
|
if (tickNumber % 6 <= 1) {
|
||||||
return pair.getFare();
|
return pair.getFare();
|
||||||
|
} else if (tickNumber % 6 <= 3) {
|
||||||
|
return etdListener.getFirstDeparture()
|
||||||
|
.getEstimatedDepartureTimeText(getContext());
|
||||||
} else {
|
} else {
|
||||||
return etdListener.getFirstDeparture()
|
return etdListener.getFirstDeparture()
|
||||||
.getUncertaintyText();
|
.getUncertaintyText();
|
||||||
|
@ -315,6 +315,15 @@ public class Departure implements Parcelable, Comparable<Departure> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getEstimatedDepartureTimeText(Context context) {
|
||||||
|
if (getMeanEstimate() > 0) {
|
||||||
|
return DateFormat.getTimeFormat(context).format(
|
||||||
|
new Date(getMeanEstimate()));
|
||||||
|
} else {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean hasDeparted() {
|
public boolean hasDeparted() {
|
||||||
return getMeanSecondsLeft() <= 0;
|
return getMeanSecondsLeft() <= 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user