// Path: src/main/java/de/fahrgemeinschaft/ContactProvider.java
// public static final class CONTACT {
//     public static final String USER = "user";
//     public static final String EMAIL = "Email";
//     public static final String PLATE = "NumberPlate";
//     public static final String MOBILE = "Mobile";
//     public static final String LANDLINE = "Landline";
// }
// 
// Path: src/main/java/de/fahrgemeinschaft/util/SpinningZebraListFragment.java
// public interface ListFragmentCallback {
//     public void onListItemClick(int position, int id);
//     public void onSpinningWheelClick();
// }


import org.json.JSONException;
import org.json.JSONObject;
import org.teleportr.ConnectorService;
import org.teleportr.ConnectorService.ServiceCallback;
import org.teleportr.Ride.COLUMNS;
import org.teleportr.RidesProvider;
import android.app.NotificationManager;
import android.content.ComponentName;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.database.Cursor;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.IBinder;
import android.preference.PreferenceManager;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentManager.OnBackStackChangedListener;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.util.Log;
import android.view.View;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem;
import de.fahrgemeinschaft.ContactProvider.CONTACT;
import de.fahrgemeinschaft.util.SpinningZebraListFragment.ListFragmentCallback;
import de.keyboardsurfer.android.widget.crouton.Crouton;
import de.keyboardsurfer.android.widget.crouton.Style;

    class GetContactsFromMyridesTask extends AsyncTask<String, String, String> {

        private static final String EMPTY = "";

        @Override
        protected String doInBackground(String... params) {
            Log.d(TAG, "getting contacts from myrides");
            Cursor mr =  getContentResolver().query(RidesProvider
                            .getMyRidesUri(BaseActivity.this),
                                null, null, null, null);
            System.out.println("myrides: " + mr.getCount());
                for (int i = 0; i < mr.getCount(); i++) {
                    mr.moveToPosition(i);
                    try {
                        storeContacts(new JSONObject(
                            mr.getString(COLUMNS.DETAILS)));
                    } catch (JSONException e) {
                        Log.e(TAG, "error getting myride details");
                        e.printStackTrace();
                    }
                }
                PreferenceManager.getDefaultSharedPreferences(BaseActivity.this)
                        .edit().remove(ProfileFragment.INIT_CONTACTS).commit();
                Log.d(TAG, "got contacts from myrides");
            return null;
        }

        public void storeContacts(JSONObject details) throws JSONException {
            ContentValues cv = new ContentValues();
// Path: src/main/java/de/fahrgemeinschaft/ContactProvider.java
// public static final class CONTACT {
//     public static final String USER = "user";
//     public static final String EMAIL = "Email";
//     public static final String PLATE = "NumberPlate";
//     public static final String MOBILE = "Mobile";
//     public static final String LANDLINE = "Landline";
// }
// 
// Path: src/main/java/de/fahrgemeinschaft/util/SpinningZebraListFragment.java
// public interface ListFragmentCallback {
//     public void onListItemClick(int position, int id);
//     public void onSpinningWheelClick();
// }


// Path: src/main/java/de/fahrgemeinschaft/BaseActivity.java
import org.json.JSONException;
import org.json.JSONObject;
import org.teleportr.ConnectorService;
import org.teleportr.ConnectorService.ServiceCallback;
import org.teleportr.Ride.COLUMNS;
import org.teleportr.RidesProvider;
import android.app.NotificationManager;
import android.content.ComponentName;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.database.Cursor;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.IBinder;
import android.preference.PreferenceManager;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentManager.OnBackStackChangedListener;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.util.Log;
import android.view.View;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem;
import de.fahrgemeinschaft.ContactProvider.CONTACT;
import de.fahrgemeinschaft.util.SpinningZebraListFragment.ListFragmentCallback;
import de.keyboardsurfer.android.widget.crouton.Crouton;
import de.keyboardsurfer.android.widget.crouton.Style;


    class GetContactsFromMyridesTask extends AsyncTask<String, String, String> {

        private static final String EMPTY = "";

        @Override
        protected String doInBackground(String... params) {
            Log.d(TAG, "getting contacts from myrides");
            Cursor mr =  getContentResolver().query(RidesProvider
                            .getMyRidesUri(BaseActivity.this),
                                null, null, null, null);
            System.out.println("myrides: " + mr.getCount());
                for (int i = 0; i < mr.getCount(); i++) {
                    mr.moveToPosition(i);
                    try {
                        storeContacts(new JSONObject(
                            mr.getString(COLUMNS.DETAILS)));
                    } catch (JSONException e) {
                        Log.e(TAG, "error getting myride details");
                        e.printStackTrace();
                    }
                }
                PreferenceManager.getDefaultSharedPreferences(BaseActivity.this)
                        .edit().remove(ProfileFragment.INIT_CONTACTS).commit();
                Log.d(TAG, "got contacts from myrides");
            return null;
        }

        public void storeContacts(JSONObject details) throws JSONException {
            ContentValues cv = new ContentValues();
            if (details.has(CONTACT.EMAIL))