use of cl.smartcities.isci.transportinspector.backend.Service in project androidApp by InspectorIncognito.
the class SuggestionsSearchTask method doInBackground.
@Override
protected List<Suggestion> doInBackground(Void... params) {
BusStopHelper stopHelper = new BusStopHelper(context);
ServiceHelper serviceHelper = new ServiceHelper(context);
List<Suggestion> suggestions = new ArrayList<>();
if (query.toUpperCase().startsWith("L")) {
return suggestions;
}
for (BusStop busStop : stopHelper.getBusStopsSuggestionsById(query.toUpperCase())) {
suggestions.add(busStop);
}
for (Service service : serviceHelper.getServiceSuggestionsById(query.toLowerCase())) {
suggestions.add(service);
}
return suggestions;
}
use of cl.smartcities.isci.transportinspector.backend.Service in project androidApp by InspectorIncognito.
the class ServerSentBus method getRoute.
public String getRoute() {
ServiceHelper serviceHelper = new ServiceHelper(TranSappApplication.getAppContext());
Service inner = serviceHelper.getServiceById(service);
if (inner == null) {
return "";
}
if (routeDirection.equals("I")) {
return inner.getDestination();
}
return inner.getOrigin();
}
use of cl.smartcities.isci.transportinspector.backend.Service in project androidApp by InspectorIncognito.
the class ServiceHelper method getServicesFromCursor.
private List<Service> getServicesFromCursor(Cursor cursor) {
List<Service> busList = new ArrayList<>();
while (cursor.moveToNext()) {
String code = cursor.getString(1);
String origin = cursor.getString(2);
String destination = cursor.getString(3);
Integer colorId = cursor.getInt(4);
busList.add(new Service(code, colorId, origin, destination));
}
return busList;
}
use of cl.smartcities.isci.transportinspector.backend.Service in project androidApp by InspectorIncognito.
the class ServiceHelper method getServiceById.
public Service getServiceById(String service) {
String query = "SELECT * FROM " + DataBaseContract.Service.TABLE_NAME + " WHERE " + DataBaseContract.Service.CODE + " = ?";
String[] params = new String[] { service };
Cursor cursor = this.getReadableDatabase().rawQuery(query, params);
List<Service> serviceList = getServicesFromCursor(cursor);
cursor.close();
if (serviceList.isEmpty()) {
return null;
}
return serviceList.get(0);
}
use of cl.smartcities.isci.transportinspector.backend.Service in project androidApp by InspectorIncognito.
the class ServiceHelper method getAllServicesIn.
List<Service> getAllServicesIn(String[] serviceCodes) {
String query = "SELECT * FROM " + DataBaseContract.Service.TABLE_NAME + " WHERE " + DataBaseContract.Service.CODE + " IN (" + makePlaceholders(serviceCodes.length) + ")";
Cursor cursor = this.getReadableDatabase().rawQuery(query, serviceCodes);
List<Service> busList = getServicesFromCursor(cursor);
cursor.close();
return busList;
}
Aggregations