use of cl.smartcities.isci.transportinspector.model.gson.ServerSentBusStopInfo in project androidApp by InspectorIncognito.
the class BusStopPlugin method busStopFeatureClick.
private void busStopFeatureClick(Feature busStopFeature, BusStopClickHandler handler) {
if (selectedBus != null) {
Log.d(BusStopPlugin.class.getSimpleName(), "selectedBus != null");
deselectSelectedBusFeature();
}
final Feature newSelectedFeature = handler.handleMarkerClick(busStopFeature, busStopFeatures);
if (newSelectedFeature != null) {
Log.d(BusStopPlugin.class.getSimpleName(), "newSelectedFeature != null");
if (busStopServiceCall != null && !busStopServiceCall.isCanceled()) {
busStopServiceCall.cancel();
}
busesFeatures = FeatureCollection.fromFeatures(new Feature[] {});
if (periodicRequestHandler != null) {
periodicRequestHandler.stopPeriodicRequest();
periodicRequestHandler = null;
}
refreshBusSource();
Log.d(BusStopPlugin.class.getSimpleName(), "selectedBusStop assign");
if (selectedBusStop != null) {
deselectSelectedBusStop();
}
selectedBusStop = newSelectedFeature;
final BusStop busStop = ((BusStopMarker) newSelectedFeature).getBusStop();
final BusStopLoadingLayerTask loaderTask = new BusStopLoadingLayerTask(newSelectedFeature, new BusStopLoadingLayerTask.LoadingListener() {
@Override
public void refresh() {
refreshBusStopSource();
}
});
final Thread thread = new Thread(loaderTask);
thread.start();
busStopServiceCall = busStopInfoService.getBusStopData(Installation.getPhoneId(), newSelectedFeature.getStringProperty(BusStopMarker.PROPERTY_ID));
/*Log the URL called*/
Log.d(BusStopPlugin.class.getSimpleName(), busStopServiceCall.request().url().toString());
busStopServiceCall.enqueue(new Callback<ServerSentBusStopInfo>() {
@Override
public void onResponse(Call<ServerSentBusStopInfo> call, Response<ServerSentBusStopInfo> response) {
Log.d(BusStopPlugin.class.getSimpleName(), "onResponse");
if (response == null || response.body() == null) {
if (response != null)
Log.e("BusStopPlugin", response.toString());
return;
}
periodicRequestHandler = new PeriodicRequestHandler(getContext(), BusStopPlugin.this, busStop, response.body().getEventsList());
BusStopPlugin.this.onResponse(response.body().getBusList(), response.body().getEventsList(), loaderTask, thread);
}
@Override
public void onFailure(Call<ServerSentBusStopInfo> call, Throwable t) {
Log.d(BusStopPlugin.class.getSimpleName(), "onFailure");
if (!call.isCanceled()) {
Toast.makeText(getContext(), "Error de conexión", Toast.LENGTH_SHORT).show();
}
loaderTask.stop();
thread.interrupt();
deselectSelectedBusStop(newSelectedFeature);
}
});
listener.onBusStopFocusGained();
animateCameraToSelection(newSelectedFeature);
} else {
refreshBusSource();
centerCameraInSelection(busStopFeature);
}
refreshBusStopSource();
}
use of cl.smartcities.isci.transportinspector.model.gson.ServerSentBusStopInfo in project androidApp by InspectorIncognito.
the class PeriodicRequestService method onStartCommand.
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.d(TAG, "onStartCommand");
Bundle bundle = intent.getExtras();
buses = bundle.getParcelableArrayList(BUSES);
events = bundle.getParcelableArrayList(EVENTS);
busStop = bundle.getParcelable(BUS_STOP);
assert busStop != null;
periodicRequestScheduler = new PeriodicRequestScheduler<>();
Call<ServerSentBusStopInfo> busStopServiceCall = busStopInfoService.getBusStopData(Installation.getPhoneId(), busStop.getId());
periodicRequestScheduler.startPeriodicRequest(getDelayFromPreferencesForBusStop(), busStopServiceCall, this);
return START_REDELIVER_INTENT;
}
Aggregations