use of app.insti.api.RetrofitInterface in project IITB-App by wncc.
the class FileComplaintFragment method prepareTags.
private void prepareTags() {
try {
RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
retrofitInterface.getTags("sessionid=" + getArguments().getString(Constants.SESSION_ID)).enqueue(new Callback<List<Venter.TagUri>>() {
@Override
public void onResponse(Call<List<Venter.TagUri>> call, Response<List<Venter.TagUri>> response) {
if (response != null && response.isSuccessful()) {
List<Venter.TagUri> tagsApiList = response.body();
tagList = new ArrayList<>();
for (int i = 0; i < tagsApiList.size(); i++) {
Venter.TagUri tagUri = tagsApiList.get(i);
ComplaintTag complaintTag = new ComplaintTag(tagUri.getTagUri());
tagList.add(complaintTag);
}
swipeContainer.setRefreshing(false);
linearLayoutAll.setVisibility(View.VISIBLE);
error_message_me.setVisibility(View.GONE);
getMapReady();
} else {
error_message_me.setVisibility(View.VISIBLE);
error_message_me.setText(getString(R.string.no_complaints));
swipeContainer.setRefreshing(false);
linearLayoutAll.setVisibility(View.GONE);
}
}
@Override
public void onFailure(Call<List<Venter.TagUri>> call, Throwable t) {
Log.i(TAG, "failure in getting Tags: " + t.toString());
swipeContainer.setRefreshing(false);
error_message_me.setVisibility(View.VISIBLE);
linearLayoutAll.setVisibility(View.GONE);
}
});
} catch (Exception e) {
e.printStackTrace();
swipeContainer.setRefreshing(false);
linearLayoutAll.setVisibility(View.GONE);
}
}
use of app.insti.api.RetrofitInterface in project IITB-App by wncc.
the class MessMenuFragment method updateMessMenu.
private void updateMessMenu(final String hostel) {
RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
retrofitInterface.getInstituteMessMenu(Utils.getSessionIDHeader()).enqueue(new Callback<List<HostelMessMenu>>() {
@Override
public void onResponse(Call<List<HostelMessMenu>> call, Response<List<HostelMessMenu>> response) {
if (response.isSuccessful()) {
if (getActivity() == null || getView() == null || response.body() == null)
return;
instituteMessMenu = response.body();
if (!initialized) {
initialize();
} else {
displayMenu(hostel);
}
}
// Server Error
messMenuSwipeRefreshLayout.setRefreshing(false);
}
@Override
public void onFailure(Call<List<HostelMessMenu>> call, Throwable t) {
// Network Error
messMenuSwipeRefreshLayout.setRefreshing(false);
}
});
}
use of app.insti.api.RetrofitInterface in project IITB-App by wncc.
the class NotificationsFragment method onStart.
@Override
public void onStart() {
super.onStart();
/* Show cached notifications */
if (Utils.notificationCache != null) {
showNotifications(Utils.notificationCache);
} else {
Utils.notificationCache = new UpdatableList<>();
}
/* Update notifications */
RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
retrofitInterface.getNotifications(Utils.getSessionIDHeader()).enqueue(new EmptyCallback<List<Notification>>() {
@Override
public void onResponse(Call<List<Notification>> call, Response<List<Notification>> response) {
if (response.isSuccessful()) {
Utils.notificationCache.setList(response.body());
showNotifications(Utils.notificationCache);
NotificationId.setCurrentCount(Utils.notificationCache.size());
ShortcutBadger.applyCount(getContext(), NotificationId.getCurrentCount());
}
}
});
}
use of app.insti.api.RetrofitInterface in project IITB-App by wncc.
the class ComplaintsAdapter method subscribeToComplaint.
private void subscribeToComplaint(final Venter.Complaint detailedComplaint, final ImageButton notificationsoff, final ImageButton notificationson) {
final RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
if (detailedComplaint.isComplaintSubscribed()) {
AlertDialog.Builder unsubscribe = new AlertDialog.Builder(context);
unsubscribe.setMessage("Are you sure you want to unsubscribe to this complaint?");
unsubscribe.setCancelable(true);
unsubscribe.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
retrofitInterface.subscribetoComplaint(Utils.getSessionIDHeader(), detailedComplaint.getComplaintID(), 0).enqueue(new Callback<Venter.Complaint>() {
@Override
public void onResponse(Call<Venter.Complaint> call, Response<Venter.Complaint> response) {
if (response.isSuccessful()) {
notificationson.setVisibility(View.GONE);
notificationsoff.setVisibility(View.VISIBLE);
detailedComplaint.setComplaintSubscribed(false);
Toast.makeText(context, "You have been unsubscribed from this complaint!", Toast.LENGTH_SHORT).show();
}
}
@Override
public void onFailure(Call<Venter.Complaint> call, Throwable t) {
Log.i(TAG, "failure in subscribe: " + t.toString());
}
});
}
});
unsubscribe.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert11 = unsubscribe.create();
alert11.show();
} else if (!detailedComplaint.isComplaintSubscribed()) {
retrofitInterface.subscribetoComplaint(Utils.getSessionIDHeader(), detailedComplaint.getComplaintID(), 1).enqueue(new EmptyCallback<Venter.Complaint>() {
@Override
public void onResponse(Call<Venter.Complaint> call, Response<Venter.Complaint> response) {
if (response.isSuccessful()) {
notificationson.setVisibility(View.VISIBLE);
notificationsoff.setVisibility(View.GONE);
detailedComplaint.setComplaintSubscribed(true);
Toast.makeText(context, "You have been subscribed to this complaint!", Toast.LENGTH_SHORT).show();
}
}
});
}
}
use of app.insti.api.RetrofitInterface in project IITB-App by wncc.
the class ComplaintDetailsFragment method subscribeToComplaint.
private void subscribeToComplaint(final Venter.Complaint detailedComplaint) {
final RetrofitInterface retrofitInterface = Utils.getRetrofitInterface();
if (detailedComplaint.isComplaintSubscribed()) {
AlertDialog.Builder unsubscribe = new AlertDialog.Builder(getActivity());
unsubscribe.setMessage("Are you sure you want to unsubscribe to this complaint?");
unsubscribe.setCancelable(true);
unsubscribe.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
retrofitInterface.subscribetoComplaint(Utils.getSessionIDHeader(), detailedComplaint.getComplaintID(), 0).enqueue(new Callback<Venter.Complaint>() {
@Override
public void onResponse(Call<Venter.Complaint> call, Response<Venter.Complaint> response) {
if (response.isSuccessful()) {
detailedComplaint.setComplaintSubscribed(false);
notificationson.setVisibility(View.GONE);
notificationsoff.setVisibility(View.VISIBLE);
}
}
@Override
public void onFailure(Call<Venter.Complaint> call, Throwable t) {
Log.i(TAG, "failure in subscribe: " + t.toString());
}
});
}
});
unsubscribe.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert11 = unsubscribe.create();
alert11.show();
} else if (!detailedComplaint.isComplaintSubscribed()) {
retrofitInterface.subscribetoComplaint(Utils.getSessionIDHeader(), detailedComplaint.getComplaintID(), 1).enqueue(new Callback<Venter.Complaint>() {
@Override
public void onResponse(Call<Venter.Complaint> call, Response<Venter.Complaint> response) {
if (response.isSuccessful()) {
detailedComplaint.setComplaintSubscribed(true);
notificationsoff.setVisibility(View.GONE);
notificationson.setVisibility(View.VISIBLE);
Toast.makeText(getActivity(), "You are subscribed to this complaint!", Toast.LENGTH_SHORT).show();
}
}
@Override
public void onFailure(Call<Venter.Complaint> call, Throwable t) {
Log.i(TAG, "failure in subscribe: " + t.toString());
}
});
}
}
Aggregations