Added arrival time to data shown in favorites listing
This commit is contained in:
parent
aa07b75efe
commit
5c1ae735e1
@ -650,7 +650,7 @@ public class ViewDeparturesActivity extends Activity implements
|
||||
boardedDeparture.getStationPair()
|
||||
.getDestination().name,
|
||||
boardedDeparture
|
||||
.getEstimatedArrivalTimeText(ViewDeparturesActivity.this)));
|
||||
.getEstimatedArrivalTimeText(ViewDeparturesActivity.this, false)));
|
||||
|
||||
startActivity(Intent.createChooser(intent,
|
||||
getString(R.string.share_arrival_time)));
|
||||
|
@ -92,7 +92,7 @@ public class DepartureArrayAdapter extends ArrayAdapter<Departure> {
|
||||
final String arrivesAtDestinationPrefix = getContext().getString(
|
||||
R.string.arrives_at_destination);
|
||||
final String estimatedArrivalTimeText = departure
|
||||
.getEstimatedArrivalTimeText(getContext());
|
||||
.getEstimatedArrivalTimeText(getContext(), false);
|
||||
|
||||
TextView estimatedArrival = (TextView) view
|
||||
.findViewById(R.id.estimatedArrival);
|
||||
@ -120,7 +120,7 @@ public class DepartureArrayAdapter extends ArrayAdapter<Departure> {
|
||||
return departure.getTrainLengthAndPlatform();
|
||||
} else {
|
||||
final String estimatedArrivalTimeText = departure
|
||||
.getEstimatedArrivalTimeText(getContext());
|
||||
.getEstimatedArrivalTimeText(getContext(), false);
|
||||
if (StringUtils.isBlank(estimatedArrivalTimeText)) {
|
||||
return "";
|
||||
} else {
|
||||
@ -153,7 +153,7 @@ public class DepartureArrayAdapter extends ArrayAdapter<Departure> {
|
||||
((TextView) view.findViewById(R.id.uncertainty)).setText(departure
|
||||
.getUncertaintyText());
|
||||
departureTime.setText(departure
|
||||
.getEstimatedDepartureTimeText(getContext()));
|
||||
.getEstimatedDepartureTimeText(getContext(), false));
|
||||
} else {
|
||||
TimedTextSwitcher uncertaintySwitcher = (TimedTextSwitcher) view
|
||||
.findViewById(R.id.uncertainty);
|
||||
@ -166,7 +166,7 @@ public class DepartureArrayAdapter extends ArrayAdapter<Departure> {
|
||||
return departure.getUncertaintyText();
|
||||
} else {
|
||||
return departure
|
||||
.getEstimatedDepartureTimeText(getContext());
|
||||
.getEstimatedDepartureTimeText(getContext(), false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -165,11 +165,18 @@ public class FavoritesArrayAdapter extends ArrayAdapter<StationPair> {
|
||||
uncertaintyTextSwitcher.setTextProvider(new TextProvider() {
|
||||
@Override
|
||||
public String getText(long tickNumber) {
|
||||
if (tickNumber % 6 <= 1) {
|
||||
final String arrive = etdListener.getFirstDeparture()
|
||||
.getEstimatedArrivalTimeText(getContext(), true);
|
||||
int mod = StringUtils.isNotBlank(arrive) ? 8 : 6;
|
||||
if (tickNumber % mod <= 1) {
|
||||
return pair.getFare();
|
||||
} else if (tickNumber % 6 <= 3) {
|
||||
return etdListener.getFirstDeparture()
|
||||
.getEstimatedDepartureTimeText(getContext());
|
||||
} else if (tickNumber % mod <= 3) {
|
||||
return "Dep "
|
||||
+ etdListener.getFirstDeparture()
|
||||
.getEstimatedDepartureTimeText(
|
||||
getContext(), true);
|
||||
} else if (mod == 8 && tickNumber % mod <= 5) {
|
||||
return "Arr " + arrive;
|
||||
} else {
|
||||
return etdListener.getFirstDeparture()
|
||||
.getUncertaintyText();
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.dougkeen.bart.model;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
@ -14,7 +15,6 @@ import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.support.v4.app.NotificationCompat.Builder;
|
||||
import android.text.format.DateFormat;
|
||||
import android.util.Log;
|
||||
|
||||
import com.dougkeen.bart.BartRunnerApplication;
|
||||
@ -27,6 +27,8 @@ public class Departure implements Parcelable, Comparable<Departure> {
|
||||
private static final int MINIMUM_MERGE_OVERLAP_MILLIS = 5000;
|
||||
private static final int EXPIRE_MINUTES_AFTER_ARRIVAL = 1;
|
||||
|
||||
private static final DateFormat TIME_FORMAT = new SimpleDateFormat("h:mm");
|
||||
|
||||
public Departure() {
|
||||
super();
|
||||
}
|
||||
@ -300,30 +302,48 @@ public class Departure implements Parcelable, Comparable<Departure> {
|
||||
if (minutesLeft < 0) {
|
||||
return "Arrived at destination";
|
||||
} else if (minutesLeft == 0) {
|
||||
return "Arrives ~" + getEstimatedArrivalTimeText(context)
|
||||
return "Arrives ~" + getEstimatedArrivalTimeText(context, false)
|
||||
+ " (<1 min)";
|
||||
} else if (minutesLeft == 1) {
|
||||
return "Arrives ~" + getEstimatedArrivalTimeText(context)
|
||||
return "Arrives ~" + getEstimatedArrivalTimeText(context, false)
|
||||
+ " (1 min)";
|
||||
} else {
|
||||
return "Arrives ~" + getEstimatedArrivalTimeText(context) + " ("
|
||||
+ minutesLeft + " mins)";
|
||||
return "Arrives ~" + getEstimatedArrivalTimeText(context, false)
|
||||
+ " (" + minutesLeft + " mins)";
|
||||
}
|
||||
}
|
||||
|
||||
public String getEstimatedArrivalTimeText(Context context) {
|
||||
return getEstimatedArrivalTimeText(context, false);
|
||||
}
|
||||
|
||||
public String getEstimatedArrivalTimeText(Context context, boolean compact) {
|
||||
if (getEstimatedTripTime() > 0 || arrivalTimeOverride > 0) {
|
||||
return DateFormat.getTimeFormat(context).format(
|
||||
new Date(getEstimatedArrivalTime()));
|
||||
final Date arrivalTime = new Date(getEstimatedArrivalTime());
|
||||
if (compact) {
|
||||
return TIME_FORMAT.format(arrivalTime);
|
||||
} else {
|
||||
return android.text.format.DateFormat.getTimeFormat(context)
|
||||
.format(arrivalTime);
|
||||
}
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public String getEstimatedDepartureTimeText(Context context) {
|
||||
return getEstimatedDepartureTimeText(context, false);
|
||||
}
|
||||
|
||||
public String getEstimatedDepartureTimeText(Context context, boolean compact) {
|
||||
if (getMeanEstimate() > 0) {
|
||||
return DateFormat.getTimeFormat(context).format(
|
||||
new Date(getMeanEstimate()));
|
||||
final Date departureTime = new Date(getMeanEstimate());
|
||||
if (compact) {
|
||||
return TIME_FORMAT.format(departureTime);
|
||||
} else {
|
||||
return android.text.format.DateFormat.getTimeFormat(context)
|
||||
.format(departureTime);
|
||||
}
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user