use of com.cmput301w18t05.taskzilla.request.command.GetReviewsByUserIdRequest in project Taskzilla by CMPUT301W18T05.
the class ProfileActivity method providerRatingOnClick.
/**
* when the provider rating is clicked (number), open a dialog showing all the provider reviews
* and ratings on the user of the profile
*/
public void providerRatingOnClick() {
final AlertDialog mBuilder = new AlertDialog.Builder(this).create();
final View mView = getLayoutInflater().inflate(R.layout.dialog_review_list, null);
final ListView ReviewsListView = mView.findViewById(R.id.ReviewsListView);
final TextView ReviewBannerTextView = mView.findViewById(R.id.ReviewsBannerTextView);
GetReviewsByUserIdRequest request = new GetReviewsByUserIdRequest(user.getId());
RequestManager.getInstance().invokeRequest(request);
ArrayList<Review> ReviewsList = request.getResult();
for (Review review : ReviewsList) {
if (review.getReviewType().equals("r")) {
ReviewsList.remove(review);
}
}
if (ReviewsList.isEmpty()) {
ArrayList<String> tempList = new ArrayList<>();
tempList.add("No reviews yet :/");
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, tempList);
ReviewsListView.setAdapter(adapter);
} else {
ArrayAdapter<Review> adapter = new ReviewCustomAdapter(this, R.layout.list_view_review, ReviewsList);
ReviewsListView.setAdapter(adapter);
}
String text = "Reviews for " + currentUser.getInstance().getName() + " as a provider";
ReviewBannerTextView.setText(text);
mBuilder.setView(mView);
mBuilder.show();
}
use of com.cmput301w18t05.taskzilla.request.command.GetReviewsByUserIdRequest in project Taskzilla by CMPUT301W18T05.
the class ProfileActivity method requesterRatingOnClick.
/**
* when the requester rating is clicked (number), open a dialog showing all the requester
* reviews and ratings on the user of the profile
*/
public void requesterRatingOnClick() {
final AlertDialog mBuilder = new AlertDialog.Builder(this).create();
final View mView = getLayoutInflater().inflate(R.layout.dialog_review_list, null);
final ListView ReviewsListView = mView.findViewById(R.id.ReviewsListView);
final TextView ReviewBannerTextView = mView.findViewById(R.id.ReviewsBannerTextView);
GetReviewsByUserIdRequest request = new GetReviewsByUserIdRequest(user.getId());
RequestManager.getInstance().invokeRequest(request);
ArrayList<Review> ReviewsList = request.getResult();
for (Review review : ReviewsList) {
if (review.getReviewType().equals("p")) {
ReviewsList.remove(review);
}
}
if (ReviewsList.isEmpty()) {
ArrayList<String> tempList = new ArrayList<>();
tempList.add("No reviews yet :/");
ArrayAdapter<String> adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, tempList);
ReviewsListView.setAdapter(adapter);
} else {
ArrayAdapter<Review> adapter = new ReviewCustomAdapter(this, R.layout.list_view_review, ReviewsList);
ReviewsListView.setAdapter(adapter);
}
String text = "Reviews for " + currentUser.getInstance().getName() + " as a requester";
ReviewBannerTextView.setText(text);
mBuilder.setView(mView);
mBuilder.show();
}
use of com.cmput301w18t05.taskzilla.request.command.GetReviewsByUserIdRequest in project Taskzilla by CMPUT301W18T05.
the class ProfileFragment method requesterRatingOnClick.
/**
* requesterRatingOnClick
* upon clicking the provider rating field
* shows dialog with a list of the user's reviews as the requester
* @author myapplestory
*/
public void requesterRatingOnClick() {
final AlertDialog mBuilder = new AlertDialog.Builder(this.getContext()).create();
final View mView = getLayoutInflater().inflate(R.layout.dialog_review_list, null);
final ListView ReviewsListView = mView.findViewById(R.id.ReviewsListView);
final TextView ReviewBannerTextView = mView.findViewById(R.id.ReviewsBannerTextView);
GetReviewsByUserIdRequest request = new GetReviewsByUserIdRequest(user.getId());
RequestManager.getInstance().invokeRequest(request);
ArrayList<Review> ReviewsListTemp = request.getResult();
Iterator<Review> iter = ReviewsListTemp.iterator();
while (iter.hasNext()) {
Review review = iter.next();
if (review.getReviewType().equals("p")) {
iter.remove();
}
}
ArrayList<Review> ReviewsList = new ArrayList<>();
ReviewsList.addAll(ReviewsListTemp);
while (ReviewsListTemp.size() > 0) {
RequestManager.getInstance().invokeRequest(request);
ReviewsListTemp = request.getResult();
iter = ReviewsListTemp.iterator();
while (iter.hasNext()) {
Review review = iter.next();
if (review.getReviewType().equals("p")) {
iter.remove();
}
}
ReviewsList.addAll(ReviewsListTemp);
}
if (ReviewsList.isEmpty()) {
ArrayList<String> tempList = new ArrayList<>();
tempList.add("No reviews yet :/");
ArrayAdapter<String> adapter = new ArrayAdapter<>(this.getContext(), android.R.layout.simple_list_item_1, tempList);
ReviewsListView.setAdapter(adapter);
} else {
ArrayAdapter<Review> adapter = new ReviewCustomAdapter(this.getContext(), R.layout.list_view_review, ReviewsList);
ReviewsListView.setAdapter(adapter);
}
String text = "Reviews for " + currentUser.getInstance().getName() + " as a requester";
ReviewBannerTextView.setText(text);
mBuilder.setView(mView);
mBuilder.show();
}
use of com.cmput301w18t05.taskzilla.request.command.GetReviewsByUserIdRequest in project Taskzilla by CMPUT301W18T05.
the class ProfileFragment method providerRatingOnClick.
/**
* providerRatingOnClick
* upon clicking the provider rating field
* shows dialog with a list of the user's reviews as the provider
* @author myapplestory
*/
public void providerRatingOnClick() {
final AlertDialog mBuilder = new AlertDialog.Builder(this.getContext()).create();
final View mView = getLayoutInflater().inflate(R.layout.dialog_review_list, null);
final ListView ReviewsListView = mView.findViewById(R.id.ReviewsListView);
final TextView ReviewBannerTextView = mView.findViewById(R.id.ReviewsBannerTextView);
GetReviewsByUserIdRequest request = new GetReviewsByUserIdRequest(user.getId());
RequestManager.getInstance().invokeRequest(request);
ArrayList<Review> ReviewsList = new ArrayList<>();
// taken from https://stackoverflow.com/questions/18448671/how-to-avoid-concurrentmodificationexception-while-removing-elements-from-arr
// 2018-04-08
ArrayList<Review> ReviewListTemp = request.getResult();
while (ReviewListTemp.size() > 0) {
Iterator<Review> iter = ReviewListTemp.iterator();
while (iter.hasNext()) {
Review review = iter.next();
System.out.println(review.getTitle());
if (review.getReviewType().equals("r")) {
iter.remove();
}
}
ReviewsList.addAll(ReviewListTemp);
RequestManager.getInstance().invokeRequest(request);
ReviewListTemp = request.getResult();
}
if (ReviewsList.isEmpty()) {
ArrayList<String> tempList = new ArrayList<>();
tempList.add("No reviews yet :/");
ArrayAdapter<String> adapter = new ArrayAdapter<>(this.getContext(), android.R.layout.simple_list_item_1, tempList);
ReviewsListView.setAdapter(adapter);
} else {
ArrayAdapter<Review> adapter = new ReviewCustomAdapter(this.getContext(), R.layout.list_view_review, ReviewsList);
ReviewsListView.setAdapter(adapter);
}
String text = "Reviews for " + currentUser.getInstance().getName() + " as a provider";
ReviewBannerTextView.setText(text);
mBuilder.setView(mView);
mBuilder.show();
}
Aggregations