Skip to content

Commit

Permalink
client: load super trip directly from the server and dont download jo…
Browse files Browse the repository at this point in the history
…in trip requests because this could cause problems
  • Loading branch information
FredFS committed Jun 23, 2015
1 parent 4d567b2 commit 7dd7622
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import org.croudtrip.api.trips.JoinTripRequest;
import org.croudtrip.api.trips.JoinTripRequestUpdate;
import org.croudtrip.api.trips.JoinTripRequestUpdateType;
import org.croudtrip.api.trips.SuperTrip;
import org.croudtrip.fragments.SubscriptionFragment;
import org.croudtrip.location.LocationUpdater;
import org.croudtrip.trip.MyTripPassengerDriversAdapter;
Expand Down Expand Up @@ -358,8 +359,8 @@ public void call(Throwable throwable) {
* Downloads the current(super-)trip from the server
*/
private void loadRequest(){
subscriptions.add(tripsResource.getJoinRequests(false)
.compose(new DefaultTransformer<List<JoinTripRequest>>())
subscriptions.add(tripsResource.getAllActiveTrips()
.compose(new DefaultTransformer<List<SuperTrip>>())
.subscribe(new LoadRequestSubscriber()));
}

Expand Down Expand Up @@ -683,18 +684,18 @@ public void onReceive(Context context, Intent intent) {
/**
* This Subscriber loads the current JoinTripRequest (SuperTripRequest)
*/
private class LoadRequestSubscriber extends Subscriber<List<JoinTripRequest>> {
private class LoadRequestSubscriber extends Subscriber<List<SuperTrip>> {

@Override
public void onNext(final List<JoinTripRequest> requests) {
public void onNext(final List<SuperTrip> trips) {

if (requests == null || requests.isEmpty()) {
if (trips == null || trips.isEmpty()) {
Timber.d("Currently there are no trips running.");
return;
}

subscriptions.add(tripsResource
.getJoinTripRequestsForSuperTrip(requests.get(0).getSuperTrip().getId())
.getJoinTripRequestsForSuperTrip(trips.get(0).getId())
.subscribe(new Action1<List<JoinTripRequest>>() {
@Override
public void call(final List<JoinTripRequest> joinTripRequests) {
Expand Down

0 comments on commit 7dd7622

Please sign in to comment.