eleith
/
calchoochoo
Archived
1
0
Fork 0

catch up from last few updates

This commit is contained in:
eleith 2017-06-25 23:44:58 -07:00
parent e2ade910e1
commit a1b4251f91
17 changed files with 203 additions and 97 deletions

View File

@ -8,8 +8,8 @@ android {
applicationId "com.eleith.calchoochoo"
minSdkVersion 22
targetSdkVersion 25
versionCode 8
versionName "1.7"
versionCode 12
versionName "1.11"
resValue "string", "GOOGLE_MAPS_API_KEY", GOOGLE_MAPS_API_KEY
}
buildTypes {

View File

@ -112,7 +112,7 @@ public class ChooChooRouterManager {
tripFilterSelectMoreFragment.setArguments(arguments);
tripFilterSuggestionsFragment.setArguments(arguments);
if (arguments.getString(BundleKeys.STOP_DESTINATION) != null && arguments.getString(BundleKeys.STOP_SOURCE) != null) {
if (arguments.getString(BundleKeys.STOP_DESTINATION_ID) != null && arguments.getString(BundleKeys.STOP_SOURCE_ID) != null) {
updateAppBarFragments(tripFilterFragmentResults, tripFilterSuggestionsFragment, stateID);
} else {
updateAppBarFragments(tripFilterFragmentResults, tripFilterSelectMoreFragment, stateID);
@ -298,10 +298,10 @@ public class ChooChooRouterManager {
arguments.putInt(BundleKeys.STOP_METHOD, stopMethod);
if (stopSourceId != null) {
arguments.putString(BundleKeys.STOP_SOURCE, stopSourceId);
arguments.putString(BundleKeys.STOP_SOURCE_ID, stopSourceId);
}
if (stopDestinationId != null) {
arguments.putString(BundleKeys.STOP_DESTINATION, stopDestinationId);
arguments.putString(BundleKeys.STOP_DESTINATION_ID, stopDestinationId);
}
if (stopDateTime != null) {

View File

@ -2,9 +2,7 @@ package com.eleith.calchoochoo;
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import com.eleith.calchoochoo.dagger.ChooChooComponent;
import com.eleith.calchoochoo.dagger.ChooChooModule;
@ -17,18 +15,15 @@ import com.eleith.calchoochoo.utils.RxBusMessage.RxMessage;
import com.eleith.calchoochoo.utils.RxBusMessage.RxMessageKeys;
import com.eleith.calchoochoo.utils.RxBusMessage.RxMessageNextTrains;
import com.eleith.calchoochoo.utils.RxBusMessage.RxMessageStop;
import com.eleith.calchoochoo.utils.TripUtils;
import com.google.android.gms.common.api.GoogleApiClient;
import org.joda.time.LocalDateTime;
import org.parceler.Parcels;
import java.util.ArrayList;
import javax.inject.Inject;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import rx.Subscription;
import rx.functions.Action1;
@ -57,9 +52,11 @@ public class StopActivity extends AppCompatActivity {
subscription = rxBus.observeEvents(RxMessage.class).subscribe(new HandleRxMessages());
ChooChooDrawer chooChooDrawer = new ChooChooDrawer(this, getWindow().getDecorView().getRootView());
Intent intent = getIntent();
if (intent != null) {
if (savedInstanceState != null && intent == null) {
unWrapBundle(savedInstanceState);
} else if(intent != null){
Bundle bundle = intent.getExtras();
if (bundle != null) {
String stopId = bundle.getString(BundleKeys.STOP);
@ -103,6 +100,20 @@ public class StopActivity extends AppCompatActivity {
return chooChooComponent;
}
@Override
protected void onSaveInstanceState(Bundle outState) {
outState.putParcelable(BundleKeys.STOP, Parcels.wrap(stop));
outState.putParcelable(BundleKeys.POSSIBLE_TRAINS, Parcels.wrap(possibleTrains));
super.onSaveInstanceState(outState);
}
private void unWrapBundle(Bundle bundle) {
if (bundle != null) {
stop = Parcels.unwrap(bundle.getParcelable(BundleKeys.STOP));
possibleTrains = Parcels.unwrap(bundle.getParcelable(BundleKeys.POSSIBLE_TRAINS));
}
}
private void loadFragment() {
if (possibleTrains != null && stop != null) {
chooChooRouterManager.loadStopsFragments(stop, possibleTrains);

View File

@ -19,6 +19,8 @@ import com.eleith.calchoochoo.utils.RxBusMessage.RxMessageLocation;
import com.eleith.calchoochoo.utils.RxBusMessage.RxMessageStops;
import com.google.android.gms.common.api.GoogleApiClient;
import org.parceler.Parcels;
import java.util.ArrayList;
import javax.inject.Inject;
@ -57,8 +59,13 @@ public class StopSearchActivity extends AppCompatActivity {
subscription = rxBus.observeEvents(RxMessage.class).subscribe(handleRxMessages());
subscriptionLocation = rxBus.observeEvents(RxMessageLocation.class).take(1).subscribe(handleRxLocationMessages());
chooChooLoader.loadParentStops();
deviceLocation.requestLocation();
if (savedInstanceState == null) {
chooChooLoader.loadParentStops();
deviceLocation.requestLocation();
} else {
unWrapBundle(savedInstanceState);
}
}
@Override
@ -93,6 +100,24 @@ public class StopSearchActivity extends AppCompatActivity {
return chooChooComponent;
}
@Override
protected void onSaveInstanceState(Bundle outState) {
outState.putParcelable(BundleKeys.STOPS, Parcels.wrap(stops));
outState.putInt(BundleKeys.SEARCH_REASON, reason);
outState.putStringArrayList(BundleKeys.STOP_IDS, filteredStopIds);
outState.putParcelable(BundleKeys.LOCATION, location);
super.onSaveInstanceState(outState);
}
private void unWrapBundle(Bundle bundle) {
if (bundle != null) {
stops = Parcels.unwrap(bundle.getParcelable(BundleKeys.STOPS));
filteredStopIds = bundle.getStringArrayList(BundleKeys.STOP_IDS);
reason = bundle.getInt(BundleKeys.SEARCH_REASON);
location = bundle.getParcelable(BundleKeys.LOCATION);
}
}
private void loadFragments() {
if (stops != null && location != null) {
chooChooRouterManager.loadSearchForSpotFragment(stops, reason, filteredStopIds, location);

View File

@ -82,21 +82,31 @@ public class TripActivity extends AppCompatActivity {
chooChooFab.setImageDrawable(getDrawable(R.drawable.ic_add_alarm_black_24dp));
chooChooFab.setBackgroundTintList(ColorStateList.valueOf(ColorUtils.getThemeColor(this, R.attr.colorAccent)));
Intent intent = getIntent();
if (intent != null) {
Bundle bundle = intent.getExtras();
if (bundle != null) {
tripId = bundle.getString(BundleKeys.TRIP);
sourceId = bundle.getString(BundleKeys.STOP_SOURCE);
destinationId = bundle.getString(BundleKeys.STOP_DESTINATION);
stopMethod = bundle.getInt(BundleKeys.STOP_METHOD);
stopDateTime = new LocalDateTime(bundle.getLong(BundleKeys.STOP_DATETIME, new LocalDateTime().toDateTime().getMillis()));
if (savedInstanceState != null) {
unWrapBundle(savedInstanceState);
} else {
Intent intent = getIntent();
if (intent != null) {
Bundle bundle = intent.getExtras();
if (bundle != null) {
tripId = bundle.getString(BundleKeys.TRIP);
sourceId = bundle.getString(BundleKeys.STOP_SOURCE);
destinationId = bundle.getString(BundleKeys.STOP_DESTINATION);
stopMethod = bundle.getInt(BundleKeys.STOP_METHOD);
stopDateTime = new LocalDateTime(bundle.getLong(BundleKeys.STOP_DATETIME, new LocalDateTime().toDateTime().getMillis()));
}
}
chooChooLoader.loadTripStops(tripId);
if (tripId != null) {
if (tripStops == null) {
chooChooLoader.loadTripStops(tripId);
}
if (destinationId != null) {
if (destinationId != null && possibleTrip == null) {
chooChooLoader.loadPossibleTrip(tripId, sourceId, destinationId);
}
loadFragments();
}
}
}
@ -197,6 +207,32 @@ public class TripActivity extends AppCompatActivity {
}
}
private void unWrapBundle(Bundle bundle) {
if (bundle != null) {
tripId = bundle.getString(BundleKeys.TRIP);
sourceId = bundle.getString(BundleKeys.STOP_SOURCE);
destinationId = bundle.getString(BundleKeys.STOP_DESTINATION);
stopMethod = bundle.getInt(BundleKeys.STOP_METHOD);
stopDateTime = new LocalDateTime(bundle.getLong(BundleKeys.STOP_DATETIME, new LocalDateTime().toDateTime().getMillis()));
trip = Parcels.unwrap(bundle.getParcelable(BundleKeys.TRIP_NAME));
possibleTrip = Parcels.unwrap(bundle.getParcelable(BundleKeys.POSSIBLE_TRIP));
tripStops = Parcels.unwrap(bundle.getParcelable(BundleKeys.TRIP_STOP_STOPTIMES));
}
}
@Override
protected void onSaveInstanceState(Bundle outState) {
outState.putString(BundleKeys.TRIP, tripId);
outState.putString(BundleKeys.STOP_SOURCE, sourceId);
outState.putString(BundleKeys.STOP_DESTINATION, destinationId);
outState.putInt(BundleKeys.STOP_METHOD, stopMethod);
outState.putLong(BundleKeys.STOP_DATETIME, stopDateTime.toDateTime().getMillis());
outState.putParcelable(BundleKeys.TRIP_STOP_STOPTIMES, Parcels.wrap(tripStops));
outState.putParcelable(BundleKeys.TRIP_NAME, Parcels.wrap(trip));
outState.putParcelable(BundleKeys.POSSIBLE_TRIP, Parcels.wrap(possibleTrip));
super.onSaveInstanceState(outState);
}
private class HandleRxMessages implements Action1<RxMessage> {
@Override
public void call(RxMessage rxMessage) {

View File

@ -22,6 +22,8 @@ import com.eleith.calchoochoo.utils.RxBusMessage.RxMessageStopsAndDetails;
import com.google.android.gms.common.api.GoogleApiClient;
import org.joda.time.LocalDateTime;
import org.parceler.Parcel;
import org.parceler.Parcels;
import java.util.ArrayList;
@ -67,28 +69,38 @@ public class TripFilterActivity extends AppCompatActivity {
subscription = rxBus.observeEvents(RxMessage.class).subscribe(handleRxMessage());
Intent intent = getIntent();
if (intent != null) {
Bundle bundle = intent.getExtras();
if (bundle != null) {
stopSourceId = bundle.getString(BundleKeys.STOP_SOURCE);
stopDestinationId = bundle.getString(BundleKeys.STOP_DESTINATION);
stopMethod = bundle.getInt(BundleKeys.STOP_METHOD);
stopDateTime = bundle.getLong(BundleKeys.STOP_DATETIME, new LocalDateTime().toDateTime().getMillis());
if (stopSourceId != null && stopSourceId.equals(stopDestinationId)) {
stopDestinationId = null;
if (savedInstanceState != null) {
unWrapBundle(savedInstanceState);
} else {
Intent intent = getIntent();
if (intent != null) {
Bundle bundle = intent.getExtras();
if (bundle != null) {
stopSourceId = bundle.getString(BundleKeys.STOP_SOURCE);
stopDestinationId = bundle.getString(BundleKeys.STOP_DESTINATION);
stopMethod = bundle.getInt(BundleKeys.STOP_METHOD);
stopDateTime = bundle.getLong(BundleKeys.STOP_DATETIME, new LocalDateTime().toDateTime().getMillis());
}
}
if (stopDestinationId != null && stopSourceId != null) {
subscriptionTrips = rxBus.observeEvents(RxMessagePossibleTrips.class).take(1).subscribe(handleRxMessagePossibleTrips());
chooChooLoader.loadPossibleTrips(stopSourceId, stopDestinationId, new LocalDateTime(stopDateTime));
} else {
chooChooRouterManager.loadTripFilterFragment(null, stopMethod, new LocalDateTime(stopDateTime), stopSourceId, stopDestinationId);
}
} else {
stopDateTime = new LocalDateTime().toDateTime().getMillis();
if (stopSourceId != null && stopSourceId.equals(stopDestinationId)) {
stopDestinationId = null;
}
if (stopMethod == null) {
stopMethod = RxMessageStopsAndDetails.DETAIL_DEPARTING;
}
if (stopDateTime == null) {
stopDateTime = new LocalDateTime().toDateTime().getMillis();
}
if (possibleTrips != null && possibleTrips.size() > 0) {
chooChooRouterManager.loadTripFilterFragment(possibleTrips, stopMethod, new LocalDateTime(stopDateTime), stopSourceId, stopDestinationId);
} else if (stopDestinationId != null && stopSourceId != null) {
subscriptionTrips = rxBus.observeEvents(RxMessagePossibleTrips.class).take(1).subscribe(handleRxMessagePossibleTrips());
chooChooLoader.loadPossibleTrips(stopSourceId, stopDestinationId, new LocalDateTime(stopDateTime));
} else {
chooChooRouterManager.loadTripFilterFragment(null, stopMethod, new LocalDateTime(stopDateTime), stopSourceId, stopDestinationId);
}
}
@ -147,6 +159,24 @@ public class TripFilterActivity extends AppCompatActivity {
}
}
private void unWrapBundle(Bundle bundle) {
stopSourceId = bundle.getString(BundleKeys.STOP_SOURCE);
stopDestinationId = bundle.getString(BundleKeys.STOP_DESTINATION);
stopMethod = bundle.getInt(BundleKeys.STOP_METHOD);
stopDateTime = bundle.getLong(BundleKeys.STOP_DATETIME, new LocalDateTime().toDateTime().getMillis());
possibleTrips = Parcels.unwrap(bundle.getParcelable(BundleKeys.POSSIBLE_TRIPS));
}
@Override
protected void onSaveInstanceState(Bundle outState) {
outState.putString(BundleKeys.STOP_SOURCE, stopSourceId);
outState.putString(BundleKeys.STOP_DESTINATION, stopDestinationId);
outState.putInt(BundleKeys.STOP_METHOD, stopMethod);
outState.putLong(BundleKeys.STOP_DATETIME, stopDateTime);
outState.putParcelable(BundleKeys.POSSIBLE_TRIPS, Parcels.wrap(possibleTrips));
super.onSaveInstanceState(outState);
}
public ChooChooComponent getComponent() {
return chooChooComponent;
}

View File

@ -48,6 +48,7 @@ public class StopTrainsAdapter extends RecyclerView.Adapter<StopTrainsAdapter.Ro
}
public void setPossibleTrains(ArrayList<PossibleTrain> possibleTrains) {
this.now = new DateTime();
this.possibleTrains = possibleTrains;
}

View File

@ -12,7 +12,6 @@ import com.eleith.calchoochoo.R;
import com.eleith.calchoochoo.StopSearchActivity;
import com.eleith.calchoochoo.utils.KeyboardUtils;
import com.eleith.calchoochoo.utils.RxBus;
import com.eleith.calchoochoo.utils.RxBusMessage.RxMessage;
import com.eleith.calchoochoo.utils.RxBusMessage.RxMessageKeys;
import com.eleith.calchoochoo.utils.RxBusMessage.RxMessageString;

View File

@ -94,6 +94,8 @@ public class SearchResultsFragment extends Fragment {
public void onSaveInstanceState(Bundle outState) {
outState.putStringArrayList(BundleKeys.STOP_IDS, filteredStopIds);
outState.putParcelable(BundleKeys.STOPS, Parcels.wrap(parentStops));
outState.putParcelable(BundleKeys.LOCATION, location);
outState.putInt(BundleKeys.SEARCH_REASON, reason);
super.onSaveInstanceState(outState);
}

View File

@ -80,17 +80,6 @@ public class StopDetailsFragment extends Fragment {
stopDetailsRecyclerViewNorth.setLayoutManager(new LinearLayoutManager(view.getContext()));
stopDetailsRecyclerViewSouth.setLayoutManager(new LinearLayoutManager(view.getContext()));
setAdapterData();
refreshHandler = new Handler();
refreshHandler.postDelayed(new Runnable() {
@Override
public void run() {
setAdapterData();
refreshHandler.postDelayed(this, 60 * 1000);
}
}, 60 * 1000);
return view;
}
@ -153,13 +142,22 @@ public class StopDetailsFragment extends Fragment {
}
@Override
public void onDestroy() {
super.onDestroy();
public void onStart() {
refreshHandler = new Handler();
refreshHandler.postDelayed(new Runnable() {
@Override
public void run() {
setAdapterData();
refreshHandler.postDelayed(this, 60 * 1000);
}
}, 60 * 1000);
setAdapterData();
super.onStart();
}
@Override
public void onDestroyView() {
public void onStop() {
refreshHandler.removeCallbacksAndMessages(null);
super.onDestroyView();
super.onStop();
}
}

View File

@ -7,7 +7,6 @@ import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.eleith.calchoochoo.R;
@ -17,9 +16,6 @@ import com.eleith.calchoochoo.utils.BundleKeys;
import com.eleith.calchoochoo.utils.ColorUtils;
import com.eleith.calchoochoo.utils.DataStringUtils;
import com.eleith.calchoochoo.utils.RxBus;
import com.eleith.calchoochoo.utils.RxBusMessage.RxMessage;
import com.eleith.calchoochoo.utils.RxBusMessage.RxMessageKeys;
import com.eleith.calchoochoo.utils.TripUtils;
import org.joda.time.LocalDateTime;
import org.joda.time.format.DateTimeFormat;
@ -32,8 +28,6 @@ import javax.inject.Inject;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import rx.Subscription;
import rx.functions.Action1;
public class StopSummaryFragment extends Fragment {
private Stop stop;
@ -54,7 +48,7 @@ public class StopSummaryFragment extends Fragment {
super.onCreate(savedInstanceState);
stopActivity = (StopActivity) getActivity();
stopActivity.getComponent().inject(this);
unWrapBundle(savedInstanceState == null ? getArguments() : savedInstanceState);
unWrapBundle(savedInstanceState != null ? savedInstanceState : getArguments());
}
@Override
@ -63,22 +57,15 @@ public class StopSummaryFragment extends Fragment {
ButterKnife.bind(this, view);
unWrapBundle(savedInstanceState);
stopName.setText(DataStringUtils.removeCaltrain(stop.stop_name));
stopZone.setText(String.format(Locale.getDefault(), "%d", stop.zone_id + 1));
stopDateTime.setText(DateTimeFormat.forPattern("E, MMM d").print(new LocalDateTime()));
return view;
}
@Override
public void onDestroyView() {
super.onDestroyView();
}
@Override
public void onStop() {
super.onStop();
public void onStart() {
super.onStart();
stopName.setText(DataStringUtils.removeCaltrain(stop.stop_name));
stopZone.setText(String.format(Locale.getDefault(), "%d", stop.zone_id + 1));
stopDateTime.setText(DateTimeFormat.forPattern("E, MMM d").print(new LocalDateTime()));
}
@Override

View File

@ -44,9 +44,10 @@ public class TripFilterFragment extends Fragment {
private LocalDateTime stopDateTime = new LocalDateTime();
private int stopMethod = RxMessageStopsAndDetails.DETAIL_DEPARTING;
private Subscription subscription;
private ArrayList<PossibleTrip> possibleTrips;
private String sourceStopId;
private String destinationStopId;
private Stop stopSource;
private Stop stopDestination;
@BindView(R.id.trip_filter_destination)
TextView destinationEdit;
@ -69,7 +70,6 @@ public class TripFilterFragment extends Fragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
((TripFilterActivity) getActivity()).getComponent().inject(this);
unWrapBundle(savedInstanceState == null ? getArguments() : savedInstanceState);
}
@ -108,17 +108,25 @@ public class TripFilterFragment extends Fragment {
}
private void updateStops() {
if (sourceStopId != null) {
if (stopSource == null && sourceStopId != null) {
chooChooLoader.loadStopByParentId(sourceStopId);
}
if (destinationStopId != null) {
if (stopDestination == null && destinationStopId != null) {
chooChooLoader.loadStopByParentId(destinationStopId);
}
sourceEdit.setVisibility(View.VISIBLE);
destinationEdit.setVisibility(View.VISIBLE);
if (stopDestination != null) {
destinationEdit.setText(DataStringUtils.removeCaltrain(stopDestination.stop_name));
}
if (stopSource != null) {
sourceEdit.setText(DataStringUtils.removeCaltrain(stopSource.stop_name));
}
updateTimeEdit();
}
@ -172,19 +180,23 @@ public class TripFilterFragment extends Fragment {
@Override
public void onSaveInstanceState(Bundle outState) {
outState.putParcelable(BundleKeys.POSSIBLE_TRIPS, Parcels.wrap(possibleTrips));
outState.putLong(BundleKeys.STOP_DATETIME, stopDateTime.toDate().getTime());
outState.putInt(BundleKeys.STOP_METHOD, stopMethod);
outState.putString(BundleKeys.STOP_SOURCE_ID, sourceStopId);
outState.putString(BundleKeys.STOP_DESTINATION_ID, destinationStopId);
outState.putParcelable(BundleKeys.STOP_SOURCE, Parcels.wrap(stopSource));
outState.putParcelable(BundleKeys.STOP_DESTINATION, Parcels.wrap(stopDestination));
super.onSaveInstanceState(outState);
}
private void unWrapBundle(Bundle bundle) {
if (bundle != null) {
possibleTrips = Parcels.unwrap(bundle.getParcelable(BundleKeys.POSSIBLE_TRIPS));
stopDateTime = new LocalDateTime(bundle.getLong(BundleKeys.STOP_DATETIME));
stopMethod = bundle.getInt(BundleKeys.STOP_METHOD);
sourceStopId = bundle.getString(BundleKeys.STOP_SOURCE);
destinationStopId = bundle.getString(BundleKeys.STOP_DESTINATION);
sourceStopId = bundle.getString(BundleKeys.STOP_SOURCE_ID);
destinationStopId = bundle.getString(BundleKeys.STOP_DESTINATION_ID);
stopSource = Parcels.unwrap(bundle.getParcelable(BundleKeys.STOP_SOURCE));
stopDestination = Parcels.unwrap(bundle.getParcelable(BundleKeys.STOP_DESTINATION));
}
}
@ -194,8 +206,11 @@ public class TripFilterFragment extends Fragment {
public void call(RxMessage rxMessage) {
if (rxMessage.isMessageValidFor(RxMessageKeys.SWITCH_SOURCE_DESTINATION_SELECTED)) {
String tempId = destinationStopId;
Stop tempStop = stopDestination;
destinationStopId = sourceStopId;
stopDestination = stopSource;
sourceStopId = tempId;
stopSource = tempStop;
chooChooLoader.loadPossibleTrips(sourceStopId, destinationStopId, stopDateTime);
} else if (rxMessage.isMessageValidFor(RxMessageKeys.DATE_TIME_SELECTED)) {
Pair<Integer, LocalDateTime> pair = ((RxMessageStopMethodAndDateTime) rxMessage).getMessage();
@ -207,14 +222,15 @@ public class TripFilterFragment extends Fragment {
Stop stop = ((RxMessageStop) rxMessage).getMessage();
if (destinationStopId != null && destinationStopId.equals(stop.stop_id)) {
destinationEdit.setText(DataStringUtils.removeCaltrain(stop.stop_name));
stopDestination = stop;
}
if (sourceStopId != null && sourceStopId.equals(stop.stop_id)) {
sourceEdit.setText(DataStringUtils.removeCaltrain(stop.stop_name));
stopSource = stop;
}
updateStops();
} else if (rxMessage.isMessageValidFor(RxMessageKeys.LOADED_POSSIBLE_TRIPS)) {
possibleTrips = ((RxMessagePossibleTrips) rxMessage).getMessage();
updateStops();
}
}

View File

@ -79,7 +79,6 @@ public class TripFilterSuggestionsFragment extends Fragment {
recyclerView.setAdapter(tripFilterSuggestionAdapter);
subscription = rxBus.observeEvents(RxMessage.class).subscribe(handleRxMessages());
chooChooLoader.loadRoutes();
return view;
}

View File

@ -122,7 +122,7 @@ public class TripSummaryFragment extends Fragment {
tripSummaryPrice.setText(String.format(Locale.getDefault(), "$%.2f", possibleTrip.getPrice()));
if (possibleTrip.getArrivalTime().getHourOfDay() <= possibleTrip.getDepartureTime().getHourOfDay()) {
if (possibleTrip.getArrivalTime().getHourOfDay() >= possibleTrip.getDepartureTime().getHourOfDay()) {
tripSummaryTotalTime.setText(String.format(Locale.getDefault(), "%d min", Minutes.minutesBetween(possibleTrip.getDepartureTime(), possibleTrip.getArrivalTime()).getMinutes()));
} else {
tripSummaryTotalTime.setText(String.format(Locale.getDefault(), "%d min", Minutes.minutesBetween(possibleTrip.getDepartureTime().toDateTimeToday(), possibleTrip.getArrivalTime().toDateTimeToday().plusHours(24)).getMinutes()));

View File

@ -6,6 +6,8 @@ public class BundleKeys {
public static final String STOP_IDS = "stop_ids";
public static final String LOCATION = "location";
public static final String SEARCH_REASON = "search_reason";
public static final String STOP_DESTINATION_ID = "stop_destination_id";
public static final String STOP_SOURCE_ID = "stop_source_id";
public static final String STOP_DESTINATION = "stop_destination";
public static final String STOP_SOURCE = "stop_source";
public static final String STOP_METHOD = "stop_method";

View File

@ -181,12 +181,12 @@ public class PossibleTripUtils {
LocalTime departureTime = possibleTrip.getDepartureTime();
LocalTime arrivalTime = possibleTrip.getArrivalTime();
if (arriving) {
if (departureTime.isBefore(dateTime.toLocalTime()) && departureTime.plusHours(3).isAfter(dateTime.toLocalTime())) {
if (!arriving) {
if (departureTime.isAfter(dateTime.toLocalTime())) {
possibleTripsFiltered.add(possibleTrip);
}
} else {
if (arrivalTime.isAfter(dateTime.toLocalTime())) {
if (arrivalTime.isBefore(dateTime.toLocalTime()) && arrivalTime.isAfter(dateTime.minusHours(3).toLocalTime())) {
possibleTripsFiltered.add(possibleTrip);
}
}

View File

@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files