use of com.cmput301w18t05.taskzilla.Review in project Taskzilla by CMPUT301W18T05.
the class NewReviewActivity method setValues.
public void setValues() {
revieweeType = getIntent().getStringExtra("who");
targetUserId = getIntent().getStringExtra("id");
currentUserId = currentUser.getInstance().getId();
GetUserRequest request = new GetUserRequest(targetUserId);
request.execute();
targetUser = request.getResult();
targetUserName = targetUser.getName();
nameTextView.setText("Review for " + targetUserName);
}
use of com.cmput301w18t05.taskzilla.Review 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.Review 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.Review in project Taskzilla by CMPUT301W18T05.
the class NewReviewActivity method reviewSaveButton.
/**
* when save button clicked, save the review and the rating to the
* elastic search
* @param view
*/
public void reviewSaveButton(android.view.View view) {
String reviewTitle = TitleText.getText().toString();
String reviewDescription = DescriptionText.getText().toString();
Float reviewRating = RatingBar.getRating();
if (reviewTitle.equals("") || reviewRating == 0.0f) {
Toast.makeText(this, "Please fill out the required fields", Toast.LENGTH_SHORT).show();
return;
}
Review review = new Review(reviewTitle, reviewRating, reviewDescription, targetUserId, currentUserId, revieweeType);
Float newRating;
if (revieweeType.equals("r")) {
newRating = ((float) (targetUser.getNumReviewsAsRequester()) * targetUser.getRequesterRating() + reviewRating) / (targetUser.getNumReviewsAsRequester() + 1);
targetUser.setRequesterRating(newRating);
targetUser.addNumRequesterReviews();
} else {
newRating = ((float) targetUser.getNumReviewsAsProvider() * targetUser.getProviderRating() + reviewRating) / (targetUser.getNumReviewsAsProvider() + 1);
targetUser.setProviderRating(newRating);
targetUser.addNumProviderReviews();
}
AddUserRequest request = new AddUserRequest(targetUser);
RequestManager.getInstance().invokeRequest(this, request);
// send to ES
review.updateThis();
Toast.makeText(this, "Review created for " + targetUserName, Toast.LENGTH_SHORT).show();
finish();
}
use of com.cmput301w18t05.taskzilla.Review 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();
}
Aggregations