Search in sources :

Example 1 with EventRequest

use of cl.smartcities.isci.transportinspector.serverConnection.requests.pushRequests.EventRequest 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);
}
Also used : ReportAdapter(cl.smartcities.isci.transportinspector.adapters.ReportAdapter) Bundle(android.os.Bundle) ServerSentEvent(cl.smartcities.isci.transportinspector.model.gson.ServerSentEvent) BusEventRequest(cl.smartcities.isci.transportinspector.serverConnection.requests.pushRequests.BusEventRequest) EventRequest(cl.smartcities.isci.transportinspector.serverConnection.requests.pushRequests.EventRequest) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager)

Example 2 with EventRequest

use of cl.smartcities.isci.transportinspector.serverConnection.requests.pushRequests.EventRequest 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;
}
Also used : ReportAdapter(cl.smartcities.isci.transportinspector.adapters.ReportAdapter) ServerSentEvent(cl.smartcities.isci.transportinspector.model.gson.ServerSentEvent) BusStopEventRequest(cl.smartcities.isci.transportinspector.serverConnection.requests.pushRequests.BusStopEventRequest) EventRequest(cl.smartcities.isci.transportinspector.serverConnection.requests.pushRequests.EventRequest) RecyclerView(android.support.v7.widget.RecyclerView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

Aggregations

LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)2 RecyclerView (android.support.v7.widget.RecyclerView)2 ReportAdapter (cl.smartcities.isci.transportinspector.adapters.ReportAdapter)2 ServerSentEvent (cl.smartcities.isci.transportinspector.model.gson.ServerSentEvent)2 EventRequest (cl.smartcities.isci.transportinspector.serverConnection.requests.pushRequests.EventRequest)2 Bundle (android.os.Bundle)1 View (android.view.View)1 BusEventRequest (cl.smartcities.isci.transportinspector.serverConnection.requests.pushRequests.BusEventRequest)1 BusStopEventRequest (cl.smartcities.isci.transportinspector.serverConnection.requests.pushRequests.BusStopEventRequest)1