// Path: app/src/main/java/comcmput301f16t01/github/carrier/FareCalculator.java
// public class FareCalculator {
// 
//     // Constants for calculating the fare.
//     static final double COST_PER_MIN = 0.15;
//     static final double COST_PER_KM = 0.56;
//     static final double BOOKING_FEE = 1.65;
//     static final int MIN_FARE = (int) 5.00 * 100;
// 
//     /**
//      * Static method takes in distance and duration and returns an estimate of a fare to post with.
//      *
//      * Formula from http://www.ridesharingdriver.com/how-much-does-uber-cost-uber-fare-estimator/
//      * fare = base fare + (cost per minute * time in ride) + (cost per km * ride distance) + booking fee
//      *
//      * @param distance The distance of the ride in kilometers
//      * @param duration The duration of the ride in seconds
//      * @return Returns whatever is greater: the calculated far or the minimum fare.
//      */
//     // see code attribution
//     public static int getEstimate(double distance, double duration) {
//         // Calculate fare and the the larger of fare vs minimum fare, we multiply by 100 to get an integer
//         int calculatedFare = (int) Math.round(((BOOKING_FEE + (COST_PER_MIN * duration) +
//                 (COST_PER_KM * distance)) * 100) * 100) / 1000;  // We divide by 1000 to round to two decimal places
// 
//         return Math.max(calculatedFare, MIN_FARE);
//     }
// 
//     /**
//      * Converts integer fare into a readable string (price format).
//      * @param intFare the fare as an integer (the dollar value * 100)
//      * @return A string representing the dollar amount with decimal.
//      */
//     public static String toString(int intFare) {
//         double fare = ((double) intFare)/100;
//         String str = String.format(Locale.getDefault(), "%d",(long)fare) + ".";
//         String dec = String.format(Locale.getDefault(), "0%.0f",(fare%1)*100);
//         // format the fare as a string with 2 decimal points
//         str +=  dec.substring(dec.length()-2, dec.length());
//         return str;
//     }
// }


import android.content.Context;
import android.support.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.Currency;
import java.util.Locale;
import comcmput301f16t01.github.carrier.FareCalculator;
import comcmput301f16t01.github.carrier.R;
                if (request.getStart().getShortAddress() != null) {
                    if(!request.getStart().getShortAddress().equals("")) {
                        startLoc = "Start: " + request.getStart().getShortAddress();
                    } else {
                        startLoc = "Start: " + request.getStart().getLatLong();
                    }
                } else {
                    startLoc = "Start: " + request.getStart().getLatLong();
                }
                startLocTextView.setText(startLoc);
            }

            // Set the end location in the item's view
            if (endLocTextView != null) {
                String endLoc;
                if (request.getEnd().getShortAddress() != null) {
                    if(!request.getEnd().getShortAddress().equals("")) {
                        endLoc = "End: " + request.getEnd().getShortAddress();
                    } else {
                        endLoc = "End: " + request.getEnd().getLatLong();
                    }
                } else {
                    endLoc = "End: " + request.getEnd().getLatLong();
                }
                endLocTextView.setText(endLoc);
            }

            // Set the price in the item's view
            if (priceTextView != null) {
                Currency localCurrency = Currency.getInstance( Locale.getDefault() );
// Path: app/src/main/java/comcmput301f16t01/github/carrier/FareCalculator.java
// public class FareCalculator {
// 
//     // Constants for calculating the fare.
//     static final double COST_PER_MIN = 0.15;
//     static final double COST_PER_KM = 0.56;
//     static final double BOOKING_FEE = 1.65;
//     static final int MIN_FARE = (int) 5.00 * 100;
// 
//     /**
//      * Static method takes in distance and duration and returns an estimate of a fare to post with.
//      *
//      * Formula from http://www.ridesharingdriver.com/how-much-does-uber-cost-uber-fare-estimator/
//      * fare = base fare + (cost per minute * time in ride) + (cost per km * ride distance) + booking fee
//      *
//      * @param distance The distance of the ride in kilometers
//      * @param duration The duration of the ride in seconds
//      * @return Returns whatever is greater: the calculated far or the minimum fare.
//      */
//     // see code attribution
//     public static int getEstimate(double distance, double duration) {
//         // Calculate fare and the the larger of fare vs minimum fare, we multiply by 100 to get an integer
//         int calculatedFare = (int) Math.round(((BOOKING_FEE + (COST_PER_MIN * duration) +
//                 (COST_PER_KM * distance)) * 100) * 100) / 1000;  // We divide by 1000 to round to two decimal places
// 
//         return Math.max(calculatedFare, MIN_FARE);
//     }
// 
//     /**
//      * Converts integer fare into a readable string (price format).
//      * @param intFare the fare as an integer (the dollar value * 100)
//      * @return A string representing the dollar amount with decimal.
//      */
//     public static String toString(int intFare) {
//         double fare = ((double) intFare)/100;
//         String str = String.format(Locale.getDefault(), "%d",(long)fare) + ".";
//         String dec = String.format(Locale.getDefault(), "0%.0f",(fare%1)*100);
//         // format the fare as a string with 2 decimal points
//         str +=  dec.substring(dec.length()-2, dec.length());
//         return str;
//     }
// }


// Path: app/src/main/java/comcmput301f16t01/github/carrier/Requests/RequestAdapter.java
import android.content.Context;
import android.support.annotation.NonNull;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.Currency;
import java.util.Locale;
import comcmput301f16t01.github.carrier.FareCalculator;
import comcmput301f16t01.github.carrier.R;

                if (request.getStart().getShortAddress() != null) {
                    if(!request.getStart().getShortAddress().equals("")) {
                        startLoc = "Start: " + request.getStart().getShortAddress();
                    } else {
                        startLoc = "Start: " + request.getStart().getLatLong();
                    }
                } else {
                    startLoc = "Start: " + request.getStart().getLatLong();
                }
                startLocTextView.setText(startLoc);
            }

            // Set the end location in the item's view
            if (endLocTextView != null) {
                String endLoc;
                if (request.getEnd().getShortAddress() != null) {
                    if(!request.getEnd().getShortAddress().equals("")) {
                        endLoc = "End: " + request.getEnd().getShortAddress();
                    } else {
                        endLoc = "End: " + request.getEnd().getLatLong();
                    }
                } else {
                    endLoc = "End: " + request.getEnd().getLatLong();
                }
                endLocTextView.setText(endLoc);
            }

            // Set the price in the item's view
            if (priceTextView != null) {
                Currency localCurrency = Currency.getInstance( Locale.getDefault() );
                String price = localCurrency.getSymbol() + FareCalculator.toString(request.getFare());