Search in sources :

Example 6 with ServerSentBus

use of cl.smartcities.isci.transportinspector.model.gson.ServerSentBus in project androidApp by InspectorIncognito.

the class UserReportsDetailsActivity method onResponse.

@Override
public void onResponse(ArrayList<ServerSentBus> buses, ArrayList<ServerSentEvent> events) {
    if (isBusStopEvent) {
        for (ServerSentEvent innerEvent : events) {
            if (event.getId().equals(innerEvent.getId())) {
                this.event = innerEvent;
                changeData(event);
                return;
            }
        }
        Toast.makeText(this, "El evento ya no se encuentra en este paradero", Toast.LENGTH_SHORT).show();
    } else {
        for (ServerSentBus mapBus : buses) {
            if (mapBus.getMachineUUID().equals(machineId)) {
                for (ServerSentEvent innerEvent : mapBus.getEvents()) {
                    if (event.getId().equals(innerEvent.getId())) {
                        this.event = innerEvent;
                        changeData(event);
                        return;
                    }
                }
            }
        }
        Toast.makeText(this, "El bus ya no se dirige a este paradero", Toast.LENGTH_SHORT).show();
    }
    finish();
}
Also used : ServerSentEvent(cl.smartcities.isci.transportinspector.model.gson.ServerSentEvent) ServerSentBus(cl.smartcities.isci.transportinspector.model.gson.ServerSentBus)

Example 7 with ServerSentBus

use of cl.smartcities.isci.transportinspector.model.gson.ServerSentBus in project androidApp by InspectorIncognito.

the class BusStopPlugin method updateBusSource.

private void updateBusSource(List<ServerSentBus> buses) {
    List<Feature> markerCoordinates = new ArrayList<>();
    for (ServerSentBus bus : buses) {
        markerCoordinates.add(new BusMarker(bus, (BusStopMarker) selectedBusStop));
    }
    busesFeatures = FeatureCollection.fromFeatures(markerCoordinates);
    // the camera bearing
    for (Feature busFeature : busesFeatures.getFeatures()) {
        Number bearing = busFeature.getNumberProperty(BusMarker.PROPERTY_BEARING);
        double newBearing = (bearing.doubleValue() + mapboxMap.getCameraPosition().bearing) % 360;
        busFeature.addBooleanProperty(BusMarker.PROPERTY_LOOKING_LEFT, newBearing < 180);
        if (selectedBus != null && selectedBus.getId().equals(busFeature.getId())) {
            busFeature.addBooleanProperty(BusMarker.PROPERTY_MAXIMIZED, true);
            selectedBus = busFeature;
        }
    }
}
Also used : BusMarker(cl.smartcities.isci.transportinspector.map.model.bus.BusMarker) ArrayList(java.util.ArrayList) BusStopMarker(cl.smartcities.isci.transportinspector.map.model.busStop.BusStopMarker) Feature(com.mapbox.services.commons.geojson.Feature) ServerSentBus(cl.smartcities.isci.transportinspector.model.gson.ServerSentBus)

Example 8 with ServerSentBus

use of cl.smartcities.isci.transportinspector.model.gson.ServerSentBus in project androidApp by InspectorIncognito.

the class BusStopPlugin method busFeatureClick.

private void busFeatureClick(Feature selectedBusFeature) {
    Log.d("BusStopPlugin", "busFeatureClick");
    Feature busFeature = getFeatureByStringProperty(selectedBusFeature, busesFeatures, BusMarker.PROPERTY_ID);
    if (busFeature == null) {
        return;
    }
    if (selectedBus != null) {
        if (busFeature.getId().equals(selectedBus.getId())) {
            boolean maximized = selectedBus.getBooleanProperty(BusMarker.PROPERTY_MAXIMIZED);
            selectedBus.addBooleanProperty(BusMarker.PROPERTY_MAXIMIZED, !maximized);
            refreshBusSource();
            return;
        } else {
            deselectSelectedBusFeature();
        }
    }
    busFeature.addBooleanProperty(BusMarker.PROPERTY_MAXIMIZED, true);
    selectedBus = busFeature;
    selectedBusStop.addBooleanProperty(BusStopMarker.PROPERTY_MAXIMIZED, false);
    refreshBusSource();
    refreshBusStopSource();
    RouteHelper helper = new RouteHelper(getContext());
    ServerSentBus bus = ((BusMarker) busFeature).getBus();
    ArrayList<LatLng> points = helper.getRoute(bus.getService(), bus.getDirection());
    busPolyline = addBusRoutePolyline(points, Constants.BUS_COLOR.get(bus.getColorArrayIndex()));
    animateCameraToSelection(busFeature);
}
Also used : BusMarker(cl.smartcities.isci.transportinspector.map.model.bus.BusMarker) RouteHelper(cl.smartcities.isci.transportinspector.database.RouteHelper) LatLng(com.mapbox.mapboxsdk.geometry.LatLng) Feature(com.mapbox.services.commons.geojson.Feature) ServerSentBus(cl.smartcities.isci.transportinspector.model.gson.ServerSentBus)

Example 9 with ServerSentBus

use of cl.smartcities.isci.transportinspector.model.gson.ServerSentBus in project androidApp by InspectorIncognito.

the class BusStopIconsBuilder method setIconsAndViews.

public void setIconsAndViews(LayoutInflater inflater, HashMap<String, Bitmap> imagesMap, HashMap<String, View> viewMap) {
    for (Feature feature : featureCollection.getFeatures()) {
        String id = feature.getStringProperty(Marker.PROPERTY_ID);
        BusStopMarker marker = (BusStopMarker) feature;
        BusStop busStop = marker.getBusStop();
        View view = inflater.inflate(R.layout.bus_stop_bubble, null);
        TextView code = view.findViewById(R.id.bubble_bus_stop_code);
        TextView name = view.findViewById(R.id.bubble_bus_stop_name);
        code.setText(id);
        name.setText(busStop.getName());
        AppCompatImageView favIcon = view.findViewById(R.id.fav_icon);
        final FavoriteHelper helper = new FavoriteHelper(view.getContext());
        boolean isFavorite = helper.isFavorite(busStop.getId());
        if (isFavorite) {
            favIcon.setColorFilter(ContextCompat.getColor(view.getContext(), R.color.yellow_fav));
        }
        List<ServerSentBus> buses = Bus.filterDummyPlates(busStop.getIncomingBuses());
        buses = ServerSentBus.orderBusesByDistance(buses);
        if (!buses.isEmpty()) {
            view.findViewById(R.id.bus_layout).setVisibility(View.VISIBLE);
            view.findViewById(R.id.bus_empty_layout).setVisibility(View.GONE);
            setupNearBusLayout(view, getNearestVisibleBus(buses, busStop));
        } else {
            view.findViewById(R.id.bus_layout).setVisibility(View.GONE);
            view.findViewById(R.id.bus_empty_layout).setVisibility(View.VISIBLE);
        }
        setEventLayout(view, marker.getEvents());
        Bitmap bitmap = GenerateViewIconTask.SymbolGenerator.generate(view);
        imagesMap.put(id + "-max", bitmap);
        viewMap.put("busStop-max", view);
        View viewMin = inflater.inflate(R.layout.bus_stop_minimize_bubble, null);
        TextView nameMin = viewMin.findViewById(R.id.bubble_bus_stop_code);
        nameMin.setText(id);
        ((ImageView) viewMin.findViewById(R.id.maximize)).setImageDrawable(new GreenButtonUp(viewMin.getContext()));
        imagesMap.put(id + "-min", GenerateViewIconTask.SymbolGenerator.generate(viewMin));
        viewMap.put("busStop-min", viewMin);
    }
}
Also used : Feature(com.mapbox.services.commons.geojson.Feature) AppCompatImageView(android.support.v7.widget.AppCompatImageView) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) AppCompatImageView(android.support.v7.widget.AppCompatImageView) GreenButtonUp(cl.smartcities.isci.transportinspector.drawables.greenButton.GreenButtonUp) ServerSentBus(cl.smartcities.isci.transportinspector.model.gson.ServerSentBus) FavoriteHelper(cl.smartcities.isci.transportinspector.database.FavoriteHelper) Bitmap(android.graphics.Bitmap) TextView(android.widget.TextView) AppCompatImageView(android.support.v7.widget.AppCompatImageView) ImageView(android.widget.ImageView) BusStop(cl.smartcities.isci.transportinspector.backend.BusStop)

Example 10 with ServerSentBus

use of cl.smartcities.isci.transportinspector.model.gson.ServerSentBus in project androidApp by InspectorIncognito.

the class OnBusService method innerStopForeground.

private void innerStopForeground() {
    stopForeground(true);
    ServerSentBus bus = selectedBus;
    this.selectedBus = null;
    if (listener != null) {
        listener.onBusServiceStateChanged();
        listener.outOfBus(bus);
    } else {
        sendEvaluationNotification(bus);
    }
    stopSelf();
}
Also used : ServerSentBus(cl.smartcities.isci.transportinspector.model.gson.ServerSentBus)

Aggregations

ServerSentBus (cl.smartcities.isci.transportinspector.model.gson.ServerSentBus)11 Feature (com.mapbox.services.commons.geojson.Feature)4 ArrayList (java.util.ArrayList)4 View (android.view.View)3 TextView (android.widget.TextView)3 ImageView (android.widget.ImageView)2 BusMarker (cl.smartcities.isci.transportinspector.map.model.bus.BusMarker)2 AlertDialog (android.app.AlertDialog)1 Bitmap (android.graphics.Bitmap)1 Typeface (android.graphics.Typeface)1 Drawable (android.graphics.drawable.Drawable)1 Bundle (android.os.Bundle)1 NonNull (android.support.annotation.NonNull)1 AppCompatImageView (android.support.v7.widget.AppCompatImageView)1 LayoutInflater (android.view.LayoutInflater)1 InputMethodManager (android.view.inputmethod.InputMethodManager)1 Button (android.widget.Button)1 EditText (android.widget.EditText)1 LinearLayout (android.widget.LinearLayout)1 ListView (android.widget.ListView)1