本文整理匯總了Java中de.schildbach.pte.dto.Trip類的典型用法代碼示例。如果您正苦於以下問題:Java Trip類的具體用法?Java Trip怎麽用?Java Trip使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Trip類屬於de.schildbach.pte.dto包,在下文中一共展示了Trip類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: test
import de.schildbach.pte.dto.Trip; //導入依賴的package包/類
@RequestMapping(value = "/connectionRaw", method = RequestMethod.GET)
@ResponseBody
public List<Trip> test(@RequestParam(value = "from", required = true) String from, @RequestParam(value = "to", required = true) String to, @RequestParam(value = "provider", required = false) String providerName, @RequestParam(value = "product", required = true) char product, @RequestParam(value = "timeOffset", required = true, defaultValue = "0") int timeOffset) throws IOException {
NetworkProvider provider;
if(providerName != null)
{
provider = ProviderUtil.getObjectForProvider(providerName);
}
else
provider = new VagfrProvider();
plannedDepartureTime.setTime(new Date().getTime() + timeOffset * 60 * 1000);
char[] products = {product};
QueryTripsResult efaData = provider.queryTrips(new Location(LocationType.STATION, from), null, new Location(LocationType.STATION, to), plannedDepartureTime, true, Product.fromCodes(products), null, null, null, null);
return efaData.trips;
}
示例2: createTripSummary
import de.schildbach.pte.dto.Trip; //導入依賴的package包/類
private TripSummary createTripSummary(Long requestId, Trip trip) {
Validate.notNull(trip);
final Leg firstLeg = trip.legs.get(0);
Long walkDuration = null;
if (firstLeg instanceof Individual) {
final Individual individual = (Individual) firstLeg;
if (individual.type == Trip.Individual.Type.WALK) {
walkDuration = individual.getArrivalTime().getTime()
- individual.getDepartureTime().getTime();
}
}
final long travelDuration = trip.getDuration()
- (walkDuration == null ? 0 : walkDuration);
return new TripSummary(requestId, trip.from, trip.to, walkDuration,
travelDuration, trip.numChanges);
}
示例3: onTripChanged
import de.schildbach.pte.dto.Trip; //導入依賴的package包/類
private void onTripChanged(@Nullable Trip trip) {
if (trip == null) return;
MenuItem reloadMenuItem = toolbar.getMenu().findItem(R.id.action_reload);
if (reloadMenuItem != null) reloadMenuItem.setActionView(null);
TransportNetwork network = viewModel.getTransportNetwork().getValue();
boolean showLineName = network != null && network.hasGoodLineNames();
LegAdapter adapter = new LegAdapter(trip.legs, viewModel, showLineName);
list.setAdapter(adapter);
fromTime.setText(getTime(getContext(), trip.getFirstDepartureTime()));
from.setText(trip.from.uniqueShortName());
toTime.setText(getTime(getContext(), trip.getLastArrivalTime()));
to.setText(trip.to.uniqueShortName());
duration.setText(getDuration(trip.getDuration()));
}
示例4: queryTripSummary
import de.schildbach.pte.dto.Trip; //導入依賴的package包/類
public TripSummary queryTripSummary(Long requestId, Location from,
Location to, Date date) throws IOException {
final QueryTripsResult result = queryTrips(from, to, date);
if (result == null || result.status != QueryTripsResult.Status.OK
|| result.trips.isEmpty()) {
// TODO
return null;
} else {
final Trip tripWithShortestDuration = Collections.min(result.trips,
new Comparator<Trip>() {
public int compare(Trip one, Trip two) {
if (one == two) {
return 0;
}
if (one == null) {
return 1;
}
if (two == null) {
return -1;
}
return Long.compare(one.getDuration(),
two.getDuration());
}
});
final TripSummary tripSummary = createTripSummary(requestId,
tripWithShortestDuration);
return tripSummary;
}
}
示例5: testQueryTrips
import de.schildbach.pte.dto.Trip; //導入依賴的package包/類
@Test
public void testQueryTrips() throws IOException {
final SuggestLocationsResult hotelLocationsResult = provider
.suggestLocations("Singerstr. 109, 10179 Berlin - Mitte, Deutschland");
final List<Location> hotelLocations = hotelLocationsResult
.getLocations();
Assert.assertFalse(hotelLocations.isEmpty());
final Location hotelLocation = hotelLocations.get(0);
final SuggestLocationsResult destinationLocationsResult = provider
.suggestLocations("Berlin U-Bahn Jannowitzbrücke");
final List<Location> destinationLocations = destinationLocationsResult
.getLocations();
Assert.assertFalse(destinationLocations.isEmpty());
final Location destinationLocation = destinationLocations.get(0);
final QueryTripsResult result = provider.queryTrips(hotelLocation,
null, destinationLocation, new Date(), true, Product.ALL,
WalkSpeed.NORMAL, Accessibility.NEUTRAL, null);
Assert.assertFalse(result.trips.isEmpty());
final Trip trip = result.trips.get(0);
int numChanges = trip.numChanges;
boolean firstLeg = true;
long walkDuration = 0;
for (Leg leg : trip.legs) {
if (firstLeg) {
firstLeg = false;
if (leg instanceof Individual) {
final Individual individual = (Individual) leg;
if (individual.type == Trip.Individual.Type.WALK) {
walkDuration = individual.getArrivalTime().getTime()
- individual.getDepartureTime().getTime();
}
}
}
}
long travelDuration = trip.getDuration() - walkDuration;
}
示例6: onTripsLoaded
import de.schildbach.pte.dto.Trip; //導入依賴的package包/類
private void onTripsLoaded(@Nullable Set<Trip> trips) {
if (trips == null) return;
int oldCount = adapter.getItemCount();
adapter.addAll(trips);
if (oldCount > 0) {
swipe.setRefreshing(false);
list.smoothScrollBy(0, queryMoreDirection == BOTTOM ? 200 : -200);
} else {
LceAnimator.showContent(progressBar, list, errorLayout);
}
}
示例7: onClick
import de.schildbach.pte.dto.Trip; //導入依賴的package包/類
@Override
public void onClick(Trip trip) {
Intent i = new Intent(getContext(), TripDetailActivity.class);
i.putExtra(TRIP, trip);
// unfortunately, PTE does not save these locations reliably in the Trip object
i.putExtra(FROM, viewModel.getFromLocation().getValue());
i.putExtra(VIA, viewModel.getViaLocation().getValue());
i.putExtra(TO, viewModel.getToLocation().getValue());
startActivity(i);
}
示例8: filterTrips
import de.schildbach.pte.dto.Trip; //導入依賴的package包/類
private List<TripData> filterTrips(List<Trip> trips, String from, String to, String mode) {
List<TripData> list = new ArrayList();
for (Trip trip : trips) {
Trip.Public leg = trip.getFirstPublicLeg();
if (leg != null) {
Date departureTime = leg.getDepartureTime();
if (departureTime.after(plannedDepartureTime) && leg.departure.id.equals(from) && leg.arrival.id.equals(to) && !leg.departureStop.departureCancelled) {
TripData data = new TripData();
data.setFrom(trip.from.name);
data.setFromId(trip.from.id);
data.setTo(trip.to.name);
data.setToId(trip.to.id);
data.setProduct(leg.line.product.toString());
data.setNumber(leg.line.label);
//Planned time
data.setPlannedDepartureTime(df.format(leg.departureStop.plannedDepartureTime));
data.setPlannedDepartureTimestamp(leg.departureStop.plannedDepartureTime.getTime());
if (mode.equals("esp") && leg.departureStop.getDepartureDelay() / 1000 >= 60) {
//Correct time, because trams with delay arrive most time earlier
Date correctedTime = new Date(leg.departureStop.predictedDepartureTime.getTime() - 60000);
data.setDepartureTime(df.format((correctedTime)));
data.setDepartureTimestamp(correctedTime.getTime());
} else {
//Predicted time
data.setDepartureTime(df.format((leg.departureStop.predictedDepartureTime)));
data.setDepartureTimestamp(leg.departureStop.predictedDepartureTime.getTime());
}
data.setDepartureDelay(leg.departureStop.getDepartureDelay() / 1000);
list.add(data);
}
}
}
return list;
}
示例9: compare
import de.schildbach.pte.dto.Trip; //導入依賴的package包/類
@Override
public int compare(Trip t1, Trip t2) {
return t1.getFirstDepartureTime().compareTo(t2.getFirstDepartureTime());
}
示例10: areItemsTheSame
import de.schildbach.pte.dto.Trip; //導入依賴的package包/類
@Override
public boolean areItemsTheSame(Trip t1, Trip t2) {
return t1.equals(t2);
}
示例11: areContentsTheSame
import de.schildbach.pte.dto.Trip; //導入依賴的package包/類
@Override
public boolean areContentsTheSame(Trip t1, Trip t2) {
return t1.equals(t2);
}
示例12: onBindViewHolder
import de.schildbach.pte.dto.Trip; //導入依賴的package包/類
@Override
public void onBindViewHolder(final TripViewHolder ui, final int position) {
Trip dep = items.get(position);
ui.bind(dep, listener);
}
示例13: addAll
import de.schildbach.pte.dto.Trip; //導入依賴的package包/類
void addAll(Collection<Trip> departures) {
this.items.addAll(departures);
}
示例14: getTrips
import de.schildbach.pte.dto.Trip; //導入依賴的package包/類
LiveData<Set<Trip>> getTrips() {
return tripsRepository.getTrips();
}
示例15: onClick
import de.schildbach.pte.dto.Trip; //導入依賴的package包/類
void onClick(Trip trip);