use of cl.smartcities.isci.transportinspector.database.ServiceHelper 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.database.ServiceHelper in project androidApp by InspectorIncognito.
the class OnBusEngine method getRouteBusStop.
private void getRouteBusStop() {
ServiceHelper serviceHelper = new ServiceHelper(TranSappApplication.getAppContext());
serviceBusStops = serviceHelper.getBusStopByService(bus.getService(), bus.getDirection()).split("-");
if (this.busStops != null) {
setBusStops(busStops);
}
}
use of cl.smartcities.isci.transportinspector.database.ServiceHelper 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.database.ServiceHelper in project androidApp by InspectorIncognito.
the class ServerSentBus method createBus.
public static void createBus(final String licensePlate, final String service, final ConstructorListener listener) {
Request.RequestListener<String> requestListener = new Request.RequestListener<String>() {
@Override
public void onRequestError() {
}
@Override
public void onRequestResult(@NonNull String machineUUID) {
int color = new ServiceHelper(TranSappApplication.getAppContext()).getColorId(service);
listener.busConstructed(new ServerSentBus("left", service, "", machineUUID, "", licensePlate, 0, 0, 0, color, 0, "", new ArrayList<ServerSentEvent>()));
}
};
Request<String> request = new GetUUIDRequest(requestListener, licensePlate);
ServerController.sendRequest(request, null);
}
use of cl.smartcities.isci.transportinspector.database.ServiceHelper in project androidApp by InspectorIncognito.
the class ServiceSelectionAdapter method getView.
@NonNull
public View getView(final int position, View convertView, @NonNull final ViewGroup parent) {
final ServiceSelectionAdapter.ViewHolder holder;
/* set view */
if (convertView == null) {
convertView = inflater.inflate(R.layout.row_service_selection, parent, false);
holder = new ServiceSelectionAdapter.ViewHolder();
holder.title = convertView.findViewById(R.id.service_selection_dialog_bus_service);
holder.image = convertView.findViewById(R.id.service_selection_dialog_bus_image);
convertView.setTag(holder);
} else {
holder = (ServiceSelectionAdapter.ViewHolder) convertView.getTag();
}
final String service = items.get(position);
holder.title.setText(service);
ServiceHelper helper = new ServiceHelper(getContext());
helper.getColorId(service);
int id = Constants.BUS_LIST.get(helper.getColorId(service));
holder.image.setImageDrawable(ContextCompat.getDrawable(getContext(), id));
convertView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
listener.onItemClick(service);
}
});
return convertView;
}
Aggregations