// Path: src/com/openxc/openxcdiagnostic/util/ActivityLauncher.java
// public class ActivityLauncher {
// 
//     public static Map<Integer, Class<?>> sActivityMap = new HashMap<>();
// 
//     static {
//         sActivityMap.put(R.id.Diagnostic, DiagnosticActivity.class);
//         sActivityMap.put(R.id.Menu, MenuActivity.class);
//         sActivityMap.put(R.id.Dashboard, DashboardActivity.class);
//         sActivityMap.put(R.id.Dump, DumpActivity.class);
//     }
// 
//     public static void launchActivity(Activity activity, int itemId) {
// 
//         Class<?> newActivityClass = sActivityMap.get(Integer.valueOf(itemId));
//         if (!activity.getClass().equals(newActivityClass)) {
//             activity.startActivity(new Intent(activity, newActivityClass));
//         }
//     }
// 
// }


import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;
import com.openxc.VehicleManager;
import com.openxc.measurements.AcceleratorPedalPosition;
import com.openxc.measurements.BrakePedalStatus;
import com.openxc.measurements.EngineSpeed;
import com.openxc.measurements.FuelConsumed;
import com.openxc.measurements.FuelLevel;
import com.openxc.measurements.HeadlampStatus;
import com.openxc.measurements.IgnitionStatus;
import com.openxc.measurements.Latitude;
import com.openxc.measurements.Longitude;
import com.openxc.measurements.Measurement;
import com.openxc.measurements.Odometer;
import com.openxc.measurements.ParkingBrakeStatus;
import com.openxc.measurements.SteeringWheelAngle;
import com.openxc.measurements.TorqueAtTransmission;
import com.openxc.measurements.TransmissionGearPosition;
import com.openxc.measurements.UnrecognizedMeasurementTypeException;
import com.openxc.measurements.VehicleSpeed;
import com.openxc.measurements.WindshieldWiperStatus;
import com.openxc.openxcdiagnostic.R;
import com.openxc.openxcdiagnostic.util.ActivityLauncher;
import com.openxc.remote.VehicleServiceException;

    @Override
    public void onResume() {
        super.onResume();
        bindService(new Intent(this, VehicleManager.class),
                mConnection, Context.BIND_AUTO_CREATE);

        try {
            mLocationManager.requestLocationUpdates(
                    LocationManager.GPS_PROVIDER, 0, 0,
                    mAndroidLocationListener);
        } catch(IllegalArgumentException e) {
            Log.w(TAG, "Vehicle location provider is unavailable");
        }
    }

    @Override
    public void onPause() {
        super.onPause();
        if(mIsBound) {
            Log.i(TAG, "Unbinding from vehicle service");
            unbindService(mConnection);
            mIsBound = false;
        }

        mLocationManager.removeUpdates(mAndroidLocationListener);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
// Path: src/com/openxc/openxcdiagnostic/util/ActivityLauncher.java
// public class ActivityLauncher {
// 
//     public static Map<Integer, Class<?>> sActivityMap = new HashMap<>();
// 
//     static {
//         sActivityMap.put(R.id.Diagnostic, DiagnosticActivity.class);
//         sActivityMap.put(R.id.Menu, MenuActivity.class);
//         sActivityMap.put(R.id.Dashboard, DashboardActivity.class);
//         sActivityMap.put(R.id.Dump, DumpActivity.class);
//     }
// 
//     public static void launchActivity(Activity activity, int itemId) {
// 
//         Class<?> newActivityClass = sActivityMap.get(Integer.valueOf(itemId));
//         if (!activity.getClass().equals(newActivityClass)) {
//             activity.startActivity(new Intent(activity, newActivityClass));
//         }
//     }
// 
// }


// Path: src/com/openxc/openxcdiagnostic/dash/DashboardActivity.java
import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;
import com.openxc.VehicleManager;
import com.openxc.measurements.AcceleratorPedalPosition;
import com.openxc.measurements.BrakePedalStatus;
import com.openxc.measurements.EngineSpeed;
import com.openxc.measurements.FuelConsumed;
import com.openxc.measurements.FuelLevel;
import com.openxc.measurements.HeadlampStatus;
import com.openxc.measurements.IgnitionStatus;
import com.openxc.measurements.Latitude;
import com.openxc.measurements.Longitude;
import com.openxc.measurements.Measurement;
import com.openxc.measurements.Odometer;
import com.openxc.measurements.ParkingBrakeStatus;
import com.openxc.measurements.SteeringWheelAngle;
import com.openxc.measurements.TorqueAtTransmission;
import com.openxc.measurements.TransmissionGearPosition;
import com.openxc.measurements.UnrecognizedMeasurementTypeException;
import com.openxc.measurements.VehicleSpeed;
import com.openxc.measurements.WindshieldWiperStatus;
import com.openxc.openxcdiagnostic.R;
import com.openxc.openxcdiagnostic.util.ActivityLauncher;
import com.openxc.remote.VehicleServiceException;


    @Override
    public void onResume() {
        super.onResume();
        bindService(new Intent(this, VehicleManager.class),
                mConnection, Context.BIND_AUTO_CREATE);

        try {
            mLocationManager.requestLocationUpdates(
                    LocationManager.GPS_PROVIDER, 0, 0,
                    mAndroidLocationListener);
        } catch(IllegalArgumentException e) {
            Log.w(TAG, "Vehicle location provider is unavailable");
        }
    }

    @Override
    public void onPause() {
        super.onPause();
        if(mIsBound) {
            Log.i(TAG, "Unbinding from vehicle service");
            unbindService(mConnection);
            mIsBound = false;
        }

        mLocationManager.removeUpdates(mAndroidLocationListener);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
    	ActivityLauncher.launchActivity(this, item.getItemId());