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