Search in sources :

Example 1 with Service

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;
}
Also used : BusStopHelper(cl.smartcities.isci.transportinspector.database.BusStopHelper) ArrayList(java.util.ArrayList) Service(cl.smartcities.isci.transportinspector.backend.Service) BusStop(cl.smartcities.isci.transportinspector.backend.BusStop) ServiceHelper(cl.smartcities.isci.transportinspector.database.ServiceHelper)

Example 2 with Service

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();
}
Also used : Service(cl.smartcities.isci.transportinspector.backend.Service) OnBusService(cl.smartcities.isci.transportinspector.onBusService.OnBusService) ServiceHelper(cl.smartcities.isci.transportinspector.database.ServiceHelper)

Example 3 with Service

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;
}
Also used : ArrayList(java.util.ArrayList) Service(cl.smartcities.isci.transportinspector.backend.Service)

Example 4 with Service

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);
}
Also used : Service(cl.smartcities.isci.transportinspector.backend.Service) Cursor(android.database.Cursor)

Example 5 with Service

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;
}
Also used : Service(cl.smartcities.isci.transportinspector.backend.Service) Cursor(android.database.Cursor)

Aggregations

Service (cl.smartcities.isci.transportinspector.backend.Service)6 Cursor (android.database.Cursor)3 ServiceHelper (cl.smartcities.isci.transportinspector.database.ServiceHelper)2 ArrayList (java.util.ArrayList)2 BusStop (cl.smartcities.isci.transportinspector.backend.BusStop)1 BusStopHelper (cl.smartcities.isci.transportinspector.database.BusStopHelper)1 OnBusService (cl.smartcities.isci.transportinspector.onBusService.OnBusService)1