use of cl.smartcities.isci.transportinspector.model.gson.ServerSentEvent in project androidApp by InspectorIncognito.
the class GetBusEventRequest method processResult.
@NonNull
@Override
public ArrayList<ServerSentEvent> processResult(@NonNull String result) {
ArrayList<ServerSentEvent> eventResponse = new ArrayList<>();
try {
JSONObject data = new JSONObject(result);
JSONArray events = data.getJSONArray("events");
for (int i = 0; i < events.length(); i++) {
ServerSentEvent event = new ServerSentEvent(events.getJSONObject(i));
eventResponse.add(event);
}
return eventResponse;
} catch (JSONException e) {
e.printStackTrace();
}
return eventResponse;
}
use of cl.smartcities.isci.transportinspector.model.gson.ServerSentEvent in project androidApp by InspectorIncognito.
the class BusStopEventBuilder method buildIncompleteReport.
@Override
public void buildIncompleteReport(IncompleteReportEventDrawableItem incompleteReportPanelItem) {
final ServerSentEvent event = new ServerSentEvent(incompleteReportPanelItem);
ReportBusListDialog dialog = new ReportBusListDialog();
dialog.setServices(busStop.getServices());
dialog.setListener(new CustomArrayAdapter.ItemClickListener<String>() {
@Override
public void onItemClick(String service) {
Log.d("BusStopEventBuilder", service + ", " + event);
listener.onRequestReady(new BusStopEventRequest(listener, event, busStop, service), busStop.getId());
}
});
dialog.show(context.getSupportFragmentManager(), "services");
}
use of cl.smartcities.isci.transportinspector.model.gson.ServerSentEvent in project androidApp by InspectorIncognito.
the class BusReportDetailsActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.detail_fragment_reports_layout);
Bundle bundle = this.getIntent().getExtras();
ArrayList<ServerSentEvent> events = bundle.getParcelableArrayList(EVENTS);
RecyclerView incomingBusesRecyclerView = findViewById(R.id.reports_recycler_view);
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
incomingBusesRecyclerView.setLayoutManager(layoutManager);
incomingBusesRecyclerView.addItemDecoration(new InsetDecoration(this));
ReportAdapter.ReportClickedListener reportClickedListener = new ReportAdapter.ReportClickedListener() {
@Override
public void onApprovalClicked(ServerSentEvent event) {
EventRequest request = getRequest(event, true);
request.setRequestToConfirm();
ServerController.sendRequest(request, null);
}
@Override
public void onDeclinedClicked(ServerSentEvent event) {
EventRequest request = getRequest(event, false);
request.setRequestToDecline();
ServerController.sendRequest(request, null);
}
};
bus = bundle.getParcelable(BUSES);
/*if (bundle.keySet().contains(IS_USER_BUS)) {
adapter = new ReportAdapter(events, bus, reportClickedListener, validationClickedListener);
} else {
adapter = new ReportAdapter(events, bus, reportClickedListener, validationClickedListener);
}*/
adapter = new ReportAdapter(events, bus, reportClickedListener, validationClickedListener);
incomingBusesRecyclerView.setAdapter(adapter);
}
use of cl.smartcities.isci.transportinspector.model.gson.ServerSentEvent in project androidApp by InspectorIncognito.
the class BusStopReportFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.detail_fragment_reports_layout, container, false);
RecyclerView incomingBusesRecyclerView = view.findViewById(R.id.reports_recycler_view);
LinearLayoutManager layoutManager = new LinearLayoutManager(this.getContext());
incomingBusesRecyclerView.setLayoutManager(layoutManager);
incomingBusesRecyclerView.addItemDecoration(new InsetDecoration(getContext()));
adapter = new ReportAdapter(events, busStop, new ReportAdapter.ReportClickedListener() {
@Override
public void onApprovalClicked(ServerSentEvent event) {
EventRequest request = getRequest(event, true);
request.setRequestToConfirm();
ServerController.sendRequest(request, null);
}
@Override
public void onDeclinedClicked(ServerSentEvent event) {
EventRequest request = getRequest(event, false);
request.setRequestToDecline();
ServerController.sendRequest(request, null);
}
}, validationClickedListener);
incomingBusesRecyclerView.setAdapter(adapter);
return view;
}
use of cl.smartcities.isci.transportinspector.model.gson.ServerSentEvent 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();
}
Aggregations