Search in sources :

Example 1 with Review

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);
}
Also used : GetUserRequest(com.cmput301w18t05.taskzilla.request.command.GetUserRequest)

Example 2 with Review

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();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) ArrayList(java.util.ArrayList) Review(com.cmput301w18t05.taskzilla.Review) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) ListView(android.widget.ListView) ListView(android.widget.ListView) GetReviewsByUserIdRequest(com.cmput301w18t05.taskzilla.request.command.GetReviewsByUserIdRequest) TextView(android.widget.TextView) ReviewCustomAdapter(com.cmput301w18t05.taskzilla.ReviewCustomAdapter) ArrayAdapter(android.widget.ArrayAdapter)

Example 3 with Review

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();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) ArrayList(java.util.ArrayList) Review(com.cmput301w18t05.taskzilla.Review) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) ListView(android.widget.ListView) ListView(android.widget.ListView) GetReviewsByUserIdRequest(com.cmput301w18t05.taskzilla.request.command.GetReviewsByUserIdRequest) TextView(android.widget.TextView) ReviewCustomAdapter(com.cmput301w18t05.taskzilla.ReviewCustomAdapter) ArrayAdapter(android.widget.ArrayAdapter)

Example 4 with Review

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();
}
Also used : Review(com.cmput301w18t05.taskzilla.Review) AddUserRequest(com.cmput301w18t05.taskzilla.request.command.AddUserRequest)

Example 5 with Review

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();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) ArrayList(java.util.ArrayList) Review(com.cmput301w18t05.taskzilla.Review) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) ListView(android.widget.ListView) ListView(android.widget.ListView) GetReviewsByUserIdRequest(com.cmput301w18t05.taskzilla.request.command.GetReviewsByUserIdRequest) TextView(android.widget.TextView) ReviewCustomAdapter(com.cmput301w18t05.taskzilla.ReviewCustomAdapter) ArrayAdapter(android.widget.ArrayAdapter)

Aggregations

Review (com.cmput301w18t05.taskzilla.Review)5 AlertDialog (android.support.v7.app.AlertDialog)4 View (android.view.View)4 ArrayAdapter (android.widget.ArrayAdapter)4 ImageView (android.widget.ImageView)4 ListView (android.widget.ListView)4 TextView (android.widget.TextView)4 ReviewCustomAdapter (com.cmput301w18t05.taskzilla.ReviewCustomAdapter)4 GetReviewsByUserIdRequest (com.cmput301w18t05.taskzilla.request.command.GetReviewsByUserIdRequest)4 ArrayList (java.util.ArrayList)4 AddUserRequest (com.cmput301w18t05.taskzilla.request.command.AddUserRequest)1 GetUserRequest (com.cmput301w18t05.taskzilla.request.command.GetUserRequest)1