Search in sources :

Example 1 with ReviewCustomAdapter

use of com.cmput301w18t05.taskzilla.ReviewCustomAdapter 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 2 with ReviewCustomAdapter

use of com.cmput301w18t05.taskzilla.ReviewCustomAdapter 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 3 with ReviewCustomAdapter

use of com.cmput301w18t05.taskzilla.ReviewCustomAdapter 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)

Example 4 with ReviewCustomAdapter

use of com.cmput301w18t05.taskzilla.ReviewCustomAdapter 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();
}
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

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 Review (com.cmput301w18t05.taskzilla.Review)4 ReviewCustomAdapter (com.cmput301w18t05.taskzilla.ReviewCustomAdapter)4 GetReviewsByUserIdRequest (com.cmput301w18t05.taskzilla.request.command.GetReviewsByUserIdRequest)4 ArrayList (java.util.ArrayList)4