Search in sources :

Example 1 with ServiceHelper

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;
}
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 ServiceHelper

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

Example 3 with ServiceHelper

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

Example 4 with ServiceHelper

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);
}
Also used : NonNull(android.support.annotation.NonNull) Request(cl.smartcities.isci.transportinspector.serverConnection.requests.Request) GetUUIDRequest(cl.smartcities.isci.transportinspector.serverConnection.requests.pullRequests.GetUUIDRequest) ArrayList(java.util.ArrayList) ServiceHelper(cl.smartcities.isci.transportinspector.database.ServiceHelper) GetUUIDRequest(cl.smartcities.isci.transportinspector.serverConnection.requests.pullRequests.GetUUIDRequest)

Example 5 with ServiceHelper

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;
}
Also used : TextView(android.widget.TextView) ImageView(android.widget.ImageView) View(android.view.View) ServiceHelper(cl.smartcities.isci.transportinspector.database.ServiceHelper) NonNull(android.support.annotation.NonNull)

Aggregations

ServiceHelper (cl.smartcities.isci.transportinspector.database.ServiceHelper)7 NonNull (android.support.annotation.NonNull)2 Service (cl.smartcities.isci.transportinspector.backend.Service)2 BusStopHelper (cl.smartcities.isci.transportinspector.database.BusStopHelper)2 ArrayList (java.util.ArrayList)2 Bitmap (android.graphics.Bitmap)1 Canvas (android.graphics.Canvas)1 ColorFilter (android.graphics.ColorFilter)1 Paint (android.graphics.Paint)1 PorterDuffColorFilter (android.graphics.PorterDuffColorFilter)1 Drawable (android.graphics.drawable.Drawable)1 View (android.view.View)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 BusStop (cl.smartcities.isci.transportinspector.backend.BusStop)1 RouteHelper (cl.smartcities.isci.transportinspector.database.RouteHelper)1 OnBusService (cl.smartcities.isci.transportinspector.onBusService.OnBusService)1 Request (cl.smartcities.isci.transportinspector.serverConnection.requests.Request)1 GetUUIDRequest (cl.smartcities.isci.transportinspector.serverConnection.requests.pullRequests.GetUUIDRequest)1