<commit_before>package ca.ualberta.cs.drivr;

import android.content.Context;
import android.net.ConnectivityManager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.RatingBar;
import android.widget.TextView;

public class RequestCompletedActivity extends AppCompatActivity {

    public static final String REQUEST_ID_EXTRA = "ca.ualberta.cs.driver.RequestCompletedActivity.REQUEST_ID_EXTRA";

    private class RatingHolder {
        private float rating;
        public RatingHolder() {
            rating = 0;
        }
        public float getRating() { return rating; }
        public void setRating(float rating) { this.rating = rating; }
    }

    private UserManager userManager = UserManager.getInstance();
    private TextView username;
    private final RatingHolder ratingHolder = new RatingHolder();
    private TextView profileTextView;
    private Button finishButton;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_request_completed);

        final String requestId = getIntent().getStringExtra(REQUEST_ID_EXTRA);

        // Todo Fetch Driver info including Username
        final RatingBar ratingBar = (RatingBar) findViewById(R.id.ratingBar);
        profileTextView = (TextView) findViewById(R.id.completed_driver_username_text_view);
        finishButton = (Button) findViewById(R.id.finish_button);

        ratingBar.setOnClickListener(new View.OnClickListener() {

            // Todo Update Rating
            @Override
            public void onClick(View v) {
                ratingHolder.setRating(ratingBar.getRating());
            }
        });

        finishButton.setOnClickListener(new View.OnClickListener() {

            // Todo Go Back to Request Activity, Move Request to History, Save Ratings
            @Override
            public void onClick(View v) {
                Request request = userManager.getRequestsList().getById(requestId);
                Driver driver = request.getDrivers().size() > 0 ? request.getDrivers().get(0) : null;
                if (driver != null) {
                    Log.i("RequestCompletedActivty", "Completing request");
                    driver.changeRating(ratingHolder.getRating());
                    request.setRequestState(RequestState.COMPLETED);
                    userManager.getRequestsList().removeById(request);
                    userManager.getRequestsList().add(request);
                    ElasticSearch elasticSearch = new ElasticSearch(userManager.getConnectivityManager());
                    elasticSearch.updateUser(driver);
                    elasticSearch.updateRequest(request);
                    userManager.notifyObservers();
                }
                finish();
            }
        });<commit_msg>Completed Activity Displays Driver name now<commit_after>package ca.ualberta.cs.drivr;

import android.content.Context;
import android.net.ConnectivityManager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.RatingBar;
import android.widget.TextView;

public class RequestCompletedActivity extends AppCompatActivity {

    public static final String REQUEST_ID_EXTRA = "ca.ualberta.cs.driver.RequestCompletedActivity.REQUEST_ID_EXTRA";

    private class RatingHolder {
        private float rating;
        public RatingHolder() {
            rating = 0;
        }
        public float getRating() { return rating; }
        public void setRating(float rating) { this.rating = rating; }
    }

    private UserManager userManager = UserManager.getInstance();
    private TextView username;
    private final RatingHolder ratingHolder = new RatingHolder();
    private TextView profileTextView;
    private Button finishButton;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_request_completed);

        final String requestId = getIntent().getStringExtra(REQUEST_ID_EXTRA);

        // Todo Fetch Driver info including Username
        final RatingBar ratingBar = (RatingBar) findViewById(R.id.ratingBar);
        profileTextView = (TextView) findViewById(R.id.completed_driver_username_text_view);
        finishButton = (Button) findViewById(R.id.finish_button);

        Request request = userManager.getRequestsList().getById(requestId);
        Driver driver = request.getDrivers().size() > 0 ? request.getDrivers().get(0) : null;

        profileTextView.setText(driver.getUsername());

        ratingBar.setOnClickListener(new View.OnClickListener() {

            // Todo Update Rating
            @Override
            public void onClick(View v) {
                ratingHolder.setRating(ratingBar.getRating());
            }
        });

        finishButton.setOnClickListener(new View.OnClickListener() {

            // Todo Go Back to Request Activity, Move Request to History, Save Ratings
            @Override
            public void onClick(View v) {
                Request request = userManager.getRequestsList().getById(requestId);
                Driver driver = request.getDrivers().size() > 0 ? request.getDrivers().get(0) : null;
                if (driver != null) {
                    Log.i("RequestCompletedActivty", "Completing request");
                    driver.changeRating(ratingHolder.getRating());
                    request.setRequestState(RequestState.COMPLETED);
                    userManager.getRequestsList().removeById(request);
                    userManager.getRequestsList().add(request);
                    ElasticSearch elasticSearch = new ElasticSearch(userManager.getConnectivityManager());
                    elasticSearch.updateUser(driver);
                    elasticSearch.updateRequest(request);
                    userManager.notifyObservers();
                }
                finish();
            }
        });
{'fraction_non_alphanumeric': 0.08733624454148471, 'fraction_numerical': 0.0016173378618793467, 'mean_word_length': 2.6100408639813195, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4741023', 'n_tokens_mistral': 1558, 'n_tokens_neox': 1456, 'n_words': 327}