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();
}
});
}
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);
}
}
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);
}
}
});
}
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);
}
});
}
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);
}
}
});
}
Aggregations