// Path: app/src/main/java/com/ae/apps/tripmeter/managers/FuelCalcManager.java
// public class FuelCalcManager {
// 
//     private Context mContext;
// 
//     /**
//      * Creates and initialises an instance of the FuelCalcManager class
//      *
//      * @param context
//      */
//     public FuelCalcManager(Context context) {
//         this.mContext = context;
//     }
// 
//     /**
//      * Calculates the Fuel and Price needed for a trip
//      *
//      * @param distance
//      * @param fuelPrice
//      * @param mileage
//      * @return
//      */
//     public FuelCalcResult calculateFuelAndPrice(float distance, float fuelPrice, float mileage) {
//         FuelCalcResult calcResult = new FuelCalcResult();
//         if (mileage > 0) {
//             float fuelNeeded = distance / mileage;
//             float totalFuelPrice = fuelPrice * fuelNeeded;
//             calcResult.setFuelPriceTotal(totalFuelPrice);
//             calcResult.setFuelQuantityNeeded(fuelNeeded);
// 
//             // Store Mileage and Current Fuel Price
//             SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(mContext);
//             preferences.edit().putString(AppConstants.PREF_KEY_FUEL_PRICE, String.valueOf(fuelPrice)).commit();
//             preferences.edit().putString(AppConstants.PREF_KEY_MILEAGE, String.valueOf(mileage)).commit();
//         } else {
//             calcResult.setDataError(true);
//         }
//         return calcResult;
//     }
// 
// }
// 
// Path: app/src/main/java/com/ae/apps/tripmeter/models/FuelCalcResult.java
// public class FuelCalcResult {
// 
//     private float fuelQuantityNeeded;
// 
//     private float fuelPriceTotal;
// 
//     private boolean dataError;
// 
//     public float getFuelPriceTotal() {
//         return fuelPriceTotal;
//     }
// 
//     public void setFuelPriceTotal(float fuelPriceTotal) {
//         this.fuelPriceTotal = fuelPriceTotal;
//     }
// 
//     public float getFuelQuantityNeeded() {
//         return fuelQuantityNeeded;
//     }
// 
//     public void setFuelQuantityNeeded(float fuelQuantityNeeded) {
//         this.fuelQuantityNeeded = fuelQuantityNeeded;
//     }
// 
//     public void setDataError(boolean dataError) {
//         this.dataError = dataError;
//     }
// 
//     public boolean isDataError() {
//         return dataError;
//     }
// }
// 
// Path: app/src/main/java/com/ae/apps/tripmeter/utils/AppConstants.java
// public interface AppConstants {
// 
//     String RESULT_FORMAT = "%.02f";
//     String PREF_KEY_FUEL_PRICE = "pref_key_fuel_price";
//     String PREF_KEY_MILEAGE = "pref_key_mileage";
//     String PREF_KEY_LAST_FEATURE = "pref_key_last_feature";
//     String PREF_KEY_CURRENT_PROFILE = "pref_key_profile_contact_id";
// 
//     String KEY_TRIP_ID = "key_trip_id";
//     String TRIP_DATE_FORMAT = "EEE, dd MMM yyyy";
// 
//     String CONTACT_ID_SEPARATOR = ",";
// }


import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.ae.apps.tripmeter.R;
import com.ae.apps.tripmeter.managers.FuelCalcManager;
import com.ae.apps.tripmeter.models.FuelCalcResult;
import com.ae.apps.tripmeter.utils.AppConstants;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.text.TextUtils;
/**
 * MIT License

 Copyright (c) 2016 Midhun Harikumar

 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
 in the Software without restriction, including without limitation the rights
 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the Software is
 furnished to do so, subject to the following conditions:

 The above copyright notice and this permission notice shall be included in all
 copies or substantial portions of the Software.

 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 SOFTWARE.
 */
package com.ae.apps.tripmeter.fragments.fuelcalc;



/**
 * A placeholder fragment containing a simple view.
 */
public class FuelCalcFragment extends Fragment {

    private static final String KEY_TRIP_DISTANCE = "key_trip_distance";

    private EditText txtTripDistance;
    private EditText txtFuelPrice;
    private EditText txtMileage;
    private TextView lblTotalCost;
    private TextView lblFuelNeeded;

    private Context mContext;
    private FuelCalcManager fuelCalcManager;

    public FuelCalcFragment() {
    }

    public static FuelCalcFragment newInstance(){
        return new FuelCalcFragment();
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
// Path: app/src/main/java/com/ae/apps/tripmeter/managers/FuelCalcManager.java
// public class FuelCalcManager {
// 
//     private Context mContext;
// 
//     /**
//      * Creates and initialises an instance of the FuelCalcManager class
//      *
//      * @param context
//      */
//     public FuelCalcManager(Context context) {
//         this.mContext = context;
//     }
// 
//     /**
//      * Calculates the Fuel and Price needed for a trip
//      *
//      * @param distance
//      * @param fuelPrice
//      * @param mileage
//      * @return
//      */
//     public FuelCalcResult calculateFuelAndPrice(float distance, float fuelPrice, float mileage) {
//         FuelCalcResult calcResult = new FuelCalcResult();
//         if (mileage > 0) {
//             float fuelNeeded = distance / mileage;
//             float totalFuelPrice = fuelPrice * fuelNeeded;
//             calcResult.setFuelPriceTotal(totalFuelPrice);
//             calcResult.setFuelQuantityNeeded(fuelNeeded);
// 
//             // Store Mileage and Current Fuel Price
//             SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(mContext);
//             preferences.edit().putString(AppConstants.PREF_KEY_FUEL_PRICE, String.valueOf(fuelPrice)).commit();
//             preferences.edit().putString(AppConstants.PREF_KEY_MILEAGE, String.valueOf(mileage)).commit();
//         } else {
//             calcResult.setDataError(true);
//         }
//         return calcResult;
//     }
// 
// }
// 
// Path: app/src/main/java/com/ae/apps/tripmeter/models/FuelCalcResult.java
// public class FuelCalcResult {
// 
//     private float fuelQuantityNeeded;
// 
//     private float fuelPriceTotal;
// 
//     private boolean dataError;
// 
//     public float getFuelPriceTotal() {
//         return fuelPriceTotal;
//     }
// 
//     public void setFuelPriceTotal(float fuelPriceTotal) {
//         this.fuelPriceTotal = fuelPriceTotal;
//     }
// 
//     public float getFuelQuantityNeeded() {
//         return fuelQuantityNeeded;
//     }
// 
//     public void setFuelQuantityNeeded(float fuelQuantityNeeded) {
//         this.fuelQuantityNeeded = fuelQuantityNeeded;
//     }
// 
//     public void setDataError(boolean dataError) {
//         this.dataError = dataError;
//     }
// 
//     public boolean isDataError() {
//         return dataError;
//     }
// }
// 
// Path: app/src/main/java/com/ae/apps/tripmeter/utils/AppConstants.java
// public interface AppConstants {
// 
//     String RESULT_FORMAT = "%.02f";
//     String PREF_KEY_FUEL_PRICE = "pref_key_fuel_price";
//     String PREF_KEY_MILEAGE = "pref_key_mileage";
//     String PREF_KEY_LAST_FEATURE = "pref_key_last_feature";
//     String PREF_KEY_CURRENT_PROFILE = "pref_key_profile_contact_id";
// 
//     String KEY_TRIP_ID = "key_trip_id";
//     String TRIP_DATE_FORMAT = "EEE, dd MMM yyyy";
// 
//     String CONTACT_ID_SEPARATOR = ",";
// }


// Path: app/src/main/java/com/ae/apps/tripmeter/fragments/fuelcalc/FuelCalcFragment.java
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.ae.apps.tripmeter.R;
import com.ae.apps.tripmeter.managers.FuelCalcManager;
import com.ae.apps.tripmeter.models.FuelCalcResult;
import com.ae.apps.tripmeter.utils.AppConstants;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.text.TextUtils;

/**
 * MIT License

 Copyright (c) 2016 Midhun Harikumar

 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
 in the Software without restriction, including without limitation the rights
 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the Software is
 furnished to do so, subject to the following conditions:

 The above copyright notice and this permission notice shall be included in all
 copies or substantial portions of the Software.

 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 SOFTWARE.
 */
package com.ae.apps.tripmeter.fragments.fuelcalc;



/**
 * A placeholder fragment containing a simple view.
 */
public class FuelCalcFragment extends Fragment {

    private static final String KEY_TRIP_DISTANCE = "key_trip_distance";

    private EditText txtTripDistance;
    private EditText txtFuelPrice;
    private EditText txtMileage;
    private TextView lblTotalCost;
    private TextView lblFuelNeeded;

    private Context mContext;
    private FuelCalcManager fuelCalcManager;

    public FuelCalcFragment() {
    }

    public static FuelCalcFragment newInstance(){
        return new FuelCalcFragment();
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        mContext = getActivity().getBaseContext();