Search in sources :

Example 1 with RetrofitInterface

use of app.insti.api.RetrofitInterface in project IITB-App by wncc.

the class FileComplaintFragment method sendImage.

private void sendImage() {
    progressDialog.setMessage("Uploading Image");
    ImageUploadRequest imageUploadRequest = new ImageUploadRequest(base64Image);
    RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
    retrofitInterface.uploadImage("sessionid=" + getArguments().getString(Constants.SESSION_ID), imageUploadRequest).enqueue(new Callback<ImageUploadResponse>() {

        @Override
        public void onResponse(Call<ImageUploadResponse> call, Response<ImageUploadResponse> response) {
            if (response.isSuccessful()) {
                ImageUploadResponse imageUploadResponse = response.body();
                uploadedImagesUrl.add(imageUploadResponse.getPictureURL());
                showImage(uploadedImagesUrl);
                Log.i(TAG, "ImageURL: " + uploadedImagesUrl.toString());
            } else {
                progressDialog.dismiss();
                Toast.makeText(getContext(), getString(R.string.error_message), Toast.LENGTH_LONG).show();
            }
        }

        @Override
        public void onFailure(Call<ImageUploadResponse> call, Throwable t) {
            Log.i(TAG, "failure in sendImage: " + t.toString());
            progressDialog.dismiss();
            Toast.makeText(getContext(), getString(R.string.error_message), Toast.LENGTH_LONG).show();
        }
    });
}
Also used : ImageUploadRequest(app.insti.api.request.ImageUploadRequest) ImageUploadResponse(app.insti.api.response.ImageUploadResponse) RetrofitInterface(app.insti.api.RetrofitInterface)

Example 2 with RetrofitInterface

use of app.insti.api.RetrofitInterface in project IITB-App by wncc.

the class ComplaintsMeFragment method callServerToGetMyComplaints.

private void callServerToGetMyComplaints() {
    try {
        RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
        retrofitInterface.getUserComplaints(Utils.getSessionIDHeader()).enqueue(new Callback<List<Venter.Complaint>>() {

            @Override
            public void onResponse(@NonNull Call<List<Venter.Complaint>> call, @NonNull Response<List<Venter.Complaint>> response) {
                if (response.body() != null && !(response.body().isEmpty())) {
                    Log.i(TAG, "response.body != null");
                    Log.i(TAG, "response: " + response.body());
                    initialiseRecyclerView(response.body());
                    swipeContainer.setRefreshing(false);
                } else {
                    error_message_me.setVisibility(View.VISIBLE);
                    error_message_me.setText(getString(R.string.no_complaints));
                    swipeContainer.setRefreshing(false);
                }
            }

            @Override
            public void onFailure(@NonNull Call<List<Venter.Complaint>> call, @NonNull Throwable t) {
                Log.i(TAG, "failure" + t.toString());
                swipeContainer.setRefreshing(false);
                error_message_me.setVisibility(View.VISIBLE);
            }
        });
    } catch (Exception e) {
        e.printStackTrace();
        swipeContainer.setRefreshing(false);
    }
}
Also used : Venter(app.insti.api.model.Venter) List(java.util.List) RetrofitInterface(app.insti.api.RetrofitInterface)

Example 3 with RetrofitInterface

use of app.insti.api.RetrofitInterface in project IITB-App by wncc.

the class EventFragment method refreshEvent.

private void refreshEvent(Event min_event) {
    if (getView() == null || getActivity() == null)
        return;
    RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
    retrofitInterface.getEvent(Utils.getSessionIDHeader(), min_event.getEventID()).enqueue(new EmptyCallback<Event>() {

        @Override
        public void onResponse(Call<Event> call, Response<Event> response) {
            if (response.isSuccessful()) {
                event = response.body();
                inflateViews(event);
            }
        }
    });
}
Also used : Event(app.insti.api.model.Event) RetrofitInterface(app.insti.api.RetrofitInterface)

Example 4 with RetrofitInterface

use of app.insti.api.RetrofitInterface in project IITB-App by wncc.

the class ExploreFragment method doSearch.

public void doSearch(final String query) {
    if (getActivity() == null || getView() == null)
        return;
    // Set the lastest query
    currentQuery = query;
    // Make request
    RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
    retrofitInterface.search(sessionId, query).enqueue(new EmptyCallback<ExploreResponse>() {

        @Override
        public void onResponse(Call<ExploreResponse> call, Response<ExploreResponse> response) {
            // Check if we already have a new query pending
            if (!currentQuery.equals(query)) {
                return;
            }
            // Get data
            bodies = response.body().getBodies();
            events = response.body().getEvents();
            users = response.body().getUsers();
            updateAdapter(bodies, events, users);
        }
    });
}
Also used : ExploreResponse(app.insti.api.response.ExploreResponse) RetrofitInterface(app.insti.api.RetrofitInterface)

Example 5 with RetrofitInterface

use of app.insti.api.RetrofitInterface in project IITB-App by wncc.

the class ComplaintFragment method callServerToGetDetailedComplaint.

private void callServerToGetDetailedComplaint() {
    RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
    retrofitInterface.getComplaint(Utils.getSessionIDHeader(), complaintId).enqueue(new EmptyCallback<Venter.Complaint>() {

        @Override
        public void onResponse(Call<Venter.Complaint> call, Response<Venter.Complaint> response) {
            if (getActivity() == null || getView() == null)
                return;
            if (response.body() != null) {
                Venter.Complaint complaint = response.body();
                initTabViews(complaint);
                // Make progress circle gone After loading
                getActivity().findViewById(R.id.loadingPanel).setVisibility(View.GONE);
            }
        }
    });
}
Also used : RetrofitInterface(app.insti.api.RetrofitInterface)

Aggregations

RetrofitInterface (app.insti.api.RetrofitInterface)35 List (java.util.List)12 Venter (app.insti.api.model.Venter)6 Call (retrofit2.Call)6 Response (retrofit2.Response)6 Event (app.insti.api.model.Event)5 ArrayList (java.util.ArrayList)5 Callback (retrofit2.Callback)5 User (app.insti.api.model.User)4 DialogInterface (android.content.DialogInterface)3 TextView (android.widget.TextView)3 RecyclerView (androidx.recyclerview.widget.RecyclerView)3 Intent (android.content.Intent)2 Bundle (android.os.Bundle)2 View (android.view.View)2 AlertDialog (androidx.appcompat.app.AlertDialog)2 Toolbar (androidx.appcompat.widget.Toolbar)2 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)2 SessionManager (app.insti.SessionManager)2 UpdatableList (app.insti.UpdatableList)2